diff options
author | Dan McDonald <danmcd@joyent.com> | 2021-01-20 10:46:23 -0500 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2021-01-20 10:46:23 -0500 |
commit | c85996c970d16f2bbde7e025b3f18fdaef5a2e71 (patch) | |
tree | 935eea5cba80972827e1fd528ab3d3cec4e7295d | |
parent | 4b15627ff0a1429ed6b071009361c2ec6cc3de5d (diff) | |
parent | 0b35c8bcd86de836ba2ab241e3b4ac7955c4148c (diff) | |
download | illumos-joyent-c85996c970d16f2bbde7e025b3f18fdaef5a2e71.tar.gz |
[illumos-gate merge]
commit 0b35c8bcd86de836ba2ab241e3b4ac7955c4148c
13424 unix: multiply-defined symbols
commit f976337ad91e7232287bf3bc0e038987a11a8949
13451 beadm needs to do more with temporary BE activation
commit ee6e522102d701504922a982938c5873c599b3ff
13422 ufs: symbol 'iuniqtime' is multiply-defined
-rw-r--r-- | usr/src/cmd/beadm/beadm.c | 27 | ||||
-rw-r--r-- | usr/src/lib/libbe/common/be_create.c | 25 | ||||
-rw-r--r-- | usr/src/lib/libbe/common/be_rename.c | 39 | ||||
-rw-r--r-- | usr/src/man/man1m/beadm.1m | 22 | ||||
-rw-r--r-- | usr/src/uts/common/fs/ufs/ufs_inode.c | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/fs/ufs_inode.h | 10 | ||||
-rw-r--r-- | usr/src/uts/i86pc/os/startup.c | 6 | ||||
-rw-r--r-- | usr/src/uts/i86pc/sys/cpupm_throttle.h | 2 | ||||
-rw-r--r-- | usr/src/uts/i86pc/sys/machsystm.h | 8 |
9 files changed, 119 insertions, 27 deletions
diff --git a/usr/src/cmd/beadm/beadm.c b/usr/src/cmd/beadm/beadm.c index 8a89c380b4..825a564c4b 100644 --- a/usr/src/cmd/beadm/beadm.c +++ b/usr/src/cmd/beadm/beadm.c @@ -26,7 +26,7 @@ * Copyright 2015 Gary Mills * Copyright (c) 2015 by Delphix. All rights reserved. * Copyright 2017 Jason King - * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. * Copyright (c) 2018, Joyent, Inc. */ @@ -130,14 +130,14 @@ usage(void) "\tsubcommands:\n" "\n" "\tbeadm activate [-v] [-t | -T] beName\n" - "\tbeadm create [-a] [-d BE_desc]\n" + "\tbeadm create [-a | -t] [-d BE_desc]\n" "\t\t[-o property=value] ... [-p zpool] \n" "\t\t[-e nonActiveBe | beName@snapshot] [-v] beName\n" "\tbeadm create [-d BE_desc]\n" "\t\t[-o property=value] ... [-p zpool] [-v] beName@snapshot\n" "\tbeadm destroy [-Ffsv] beName \n" "\tbeadm destroy [-Fv] beName@snapshot \n" - "\tbeadm list [[-a] | [-d] [-s]] [-H]\n" + "\tbeadm list [-a | -ds] [-H]\n" "\t\t[-k|-K date | name | space] [-v] [beName]\n" "\tbeadm mount [-s ro|rw] [-v] beName [mountpoint]\n" "\tbeadm unmount [-fv] beName | mountpoint\n" @@ -762,6 +762,7 @@ be_do_create(int argc, char **argv) nvlist_t *be_attrs; nvlist_t *zfs_props = NULL; boolean_t activate = B_FALSE; + boolean_t t_activate = B_FALSE; boolean_t is_snap = B_FALSE; int c; int err = 1; @@ -774,7 +775,7 @@ be_do_create(int argc, char **argv) char *propval = NULL; char *strval = NULL; - while ((c = getopt(argc, argv, "ad:e:io:p:v")) != -1) { + while ((c = getopt(argc, argv, "ad:e:io:p:tv")) != -1) { switch (c) { case 'a': activate = B_TRUE; @@ -812,6 +813,9 @@ be_do_create(int argc, char **argv) case 'p': nbe_zpool = optarg; break; + case 't': + t_activate = B_TRUE; + break; case 'v': libbe_print_errors(B_TRUE); break; @@ -821,6 +825,13 @@ be_do_create(int argc, char **argv) } } + if (activate && t_activate) { + (void) fprintf(stderr, + _("create: -a and -t are mutually exclusive\n")); + usage(); + goto out2; + } + argc -= optind; argv += optind; @@ -934,6 +945,14 @@ be_do_create(int argc, char **argv) err = be_do_activate(2, args); goto out; } + if (!is_snap && t_activate) { + char *args[] = { "activate", "-t", "", NULL }; + args[2] = nbe_name; + optind = 1; + + err = be_do_activate(3, args); + goto out; + } (void) printf(_("Created successfully\n")); break; diff --git a/usr/src/lib/libbe/common/be_create.c b/usr/src/lib/libbe/common/be_create.c index 4c69ac38f6..4158ddb677 100644 --- a/usr/src/lib/libbe/common/be_create.c +++ b/usr/src/lib/libbe/common/be_create.c @@ -24,7 +24,7 @@ * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014, 2015 by Delphix. All rights reserved. * Copyright (c) 2016 Martin Matuska. All rights reserved. - * Copyright 2019 OmniOS Community Edition (OmniOSce) Association. + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ /* @@ -50,6 +50,7 @@ #include <libbe.h> #include <libbe_priv.h> +#include <libzfsbootenv.h> /* Library wide variables */ libzfs_handle_t *g_zfs = NULL; @@ -472,6 +473,28 @@ be_destroy(nvlist_t *be_attrs) } } + /* + * Detect if the BE to destroy is referenced in the pool's nextboot + * field, and unset it if so. + */ + if (getzoneid() == GLOBAL_ZONEID) { + char *nextboot = NULL; + + if (lzbe_get_boot_device(bt.obe_zpool, &nextboot) == 0 && + nextboot != NULL && strcmp(nextboot, bt.obe_root_ds) == 0) { + if (lzbe_set_boot_device(bt.obe_zpool, + lzbe_add, "") != 0) { + be_print_err(gettext("be_destroy: failed to " + "remove temporary activation for " + "dataset %s on pool %s\n"), + bt.obe_root_ds, bt.obe_zpool); + free(nextboot); + return (BE_ERR_UNKNOWN); + } + } + free(nextboot); + } + /* Get handle to BE's root dataset */ if ((zhp = zfs_open(g_zfs, bt.obe_root_ds, ZFS_TYPE_FILESYSTEM)) == NULL) { diff --git a/usr/src/lib/libbe/common/be_rename.c b/usr/src/lib/libbe/common/be_rename.c index 64c26943bf..f0cd781b22 100644 --- a/usr/src/lib/libbe/common/be_rename.c +++ b/usr/src/lib/libbe/common/be_rename.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright 2021 OmniOS Community Edition (OmniOSce) Association. */ #include <assert.h> @@ -37,6 +38,7 @@ #include <libbe.h> #include <libbe_priv.h> +#include <libzfsbootenv.h> /* ******************************************************************** */ /* Public Functions */ @@ -185,13 +187,48 @@ be_rename(nvlist_t *be_attrs) goto done; } + /* Change the nextboot property on the pool if necessary */ + if (getzoneid() == GLOBAL_ZONEID) { + char *nextboot = NULL; + int rv = 0; + + if (lzbe_get_boot_device(bt.obe_zpool, &nextboot) == 0 && + nextboot != NULL && strcmp(nextboot, bt.obe_root_ds) == 0) { + if ((rv = lzbe_set_boot_device(bt.obe_zpool, + lzbe_add, "")) != 0) { + be_print_err(gettext("be_rename: failed to " + "remove temporary activation for " + "dataset %s on pool %s\n"), + bt.obe_root_ds, bt.obe_zpool); + } + if (rv == 0 && (rv = lzbe_set_boot_device(bt.nbe_zpool, + lzbe_add, bt.nbe_root_ds)) != 0) { + be_print_err(gettext("be_rename: failed to " + "enable temporary activation for " + "dataset %s on pool %s\n"), + bt.nbe_root_ds, bt.nbe_zpool); + } + } + free(nextboot); + switch (rv) { + case 0: + break; + case ENOMEM: + ret = BE_ERR_NOMEM; + goto done; + default: + ret = BE_ERR_UNKNOWN; + goto done; + } + } + /* Refresh handle to BE's root dataset after the rename */ ZFS_CLOSE(zhp); if ((zhp = zfs_open(g_zfs, bt.nbe_root_ds, ZFS_TYPE_FILESYSTEM)) == NULL) { be_print_err(gettext("be_rename: failed to " "open BE root dataset (%s): %s\n"), - bt.obe_root_ds, libzfs_error_description(g_zfs)); + bt.nbe_root_ds, libzfs_error_description(g_zfs)); ret = zfs_err_to_be_err(g_zfs); goto done; } diff --git a/usr/src/man/man1m/beadm.1m b/usr/src/man/man1m/beadm.1m index 250f4b4400..7ae39cf455 100644 --- a/usr/src/man/man1m/beadm.1m +++ b/usr/src/man/man1m/beadm.1m @@ -1,12 +1,13 @@ '\" te .\" Copyright 2013 Nexenta Systems, Inc. All rights reserved. .\" Copyright 2016 Toomas Soome <tsoome@me.com> -.TH BEADM 1M "May 2, 2020" +.\" Copyright 2021 OmniOS Community Edition (OmniOSce) Association. +.TH BEADM 1M "Jan 14, 2021" .SH NAME beadm \- utility for managing zfs boot environments .SH SYNOPSIS .nf -\fBbeadm\fR \fBcreate\fR [\fB-a\fR] [\fB-d\fR \fIdescription\fR] +\fBbeadm\fR \fBcreate\fR [\fB-a\fR | \fB-t\fR] [\fB-d\fR \fIdescription\fR] [\fB-e\fR \fInon-activeBeName\fR | \fIbeName@snapshot\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-p\fR \fIzpool\fR] [\fB-v\fR] \fIbeName\fR @@ -161,7 +162,7 @@ Displays command usage. .sp .ne 2 .na -\fBbeadm\fR \fBcreate\fR [\fB-a\fR] [\fB-d\fR \fIdescription\fR] +\fBbeadm\fR \fBcreate\fR [\fB-a\fR | \fB-t\fR] [\fB-d\fR \fIdescription\fR] [\fB-e\fR \fInon-activeBeName\fR | \fIbeName@snapshot\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-p\fR \fIzpool\fR] [\fB-v\fR] \fIbeName\fR @@ -184,8 +185,8 @@ option is not provided, \fIbeName\fR will be used as the title. .ad .sp .6 .RS 4n -Activate the newly created BE upon creation. The default is to not activate -the newly created BE. +Activate the newly created BE. The default is to not activate +the newly created BE. See also \fB-t\fR. .RE .sp .ne 2 @@ -239,6 +240,17 @@ default behavior is to create the new BE in the same pool as as the origin BE. This option is not supported in non-global zone. .RE +.ne 2 +.na +\fB-t\fR +.ad +.sp .6 +.RS 4n +Temporarily activate the newly created BE. The new BE will be +used for the next boot only and the temporary activation will be automatically +removed. The default is to not activate the newly created BE. See also +\fB-a\fR. +.RE .sp .ne 2 .na diff --git a/usr/src/uts/common/fs/ufs/ufs_inode.c b/usr/src/uts/common/fs/ufs/ufs_inode.c index 05f23a6d29..ea42eed6e4 100644 --- a/usr/src/uts/common/fs/ufs/ufs_inode.c +++ b/usr/src/uts/common/fs/ufs/ufs_inode.c @@ -24,7 +24,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * University Copyright- Copyright (c) 1982, 1986, 1988 @@ -107,6 +107,7 @@ union ihead *ihead; /* inode LRU cache, Chris Maltby */ kmutex_t *ih_lock; /* protect inode cache hash table */ static int ino_hashlen = 4; /* desired average hash chain length */ int inohsz; /* number of buckets in the hash table */ +struct timeval32 iuniqtime; kmutex_t ufs_scan_lock; /* stop racing multiple ufs_scan_inodes() */ kmutex_t ufs_iuniqtime_lock; /* protect iuniqtime */ @@ -838,8 +839,8 @@ ufs_iupdat(struct inode *ip, int waitfor) struct buf *bp; struct fs *fp; struct dinode *dp; - struct ufsvfs *ufsvfsp = ip->i_ufsvfs; - int i; + struct ufsvfs *ufsvfsp = ip->i_ufsvfs; + int i; int do_trans_times; ushort_t flag; o_uid_t suid; diff --git a/usr/src/uts/common/sys/fs/ufs_inode.h b/usr/src/uts/common/sys/fs/ufs_inode.h index bfdd32fa4a..a3aa0fd80c 100644 --- a/usr/src/uts/common/sys/fs/ufs_inode.h +++ b/usr/src/uts/common/sys/fs/ufs_inode.h @@ -137,7 +137,7 @@ extern "C" { * bmap routines. * * SVR4 Extended Fundamental Type (EFT) support: - * The inode structure has been enhanced to support + * The inode structure has been enhanced to support * 32-bit user-id, 32-bit group-id, and 32-bit device number. * Standard SVR4 ufs also supports 32-bit mode field. For the reason * of backward compatibility with the previous ufs disk format, @@ -189,7 +189,7 @@ extern "C" { #define i_fs i_ufsvfs->vfs_bufp->b_un.b_fs #define i_vfs i_vnode->v_vfsp -struct icommon { +struct icommon { o_mode_t ic_smode; /* 0: mode and type of file */ short ic_nlink; /* 2: number of links to file */ o_uid_t ic_suid; /* 4: owner's user id */ @@ -240,7 +240,7 @@ typedef struct inode { struct inode *i_chain[2]; /* must be first */ struct inode *i_freef; /* free list forward - must be before i_ic */ struct inode *i_freeb; /* free list back - must be before i_ic */ - struct icommon i_ic; /* Must be here */ + struct icommon i_ic; /* Must be here */ struct vnode *i_vnode; /* vnode associated with this inode */ struct vnode *i_devvp; /* vnode for block I/O */ dev_t i_dev; /* device where inode resides */ @@ -518,7 +518,7 @@ extern int vttoif_tab[]; * (Note that UFS's concept of time only keeps 32 bits of seconds * in the on-disk format). */ -struct timeval32 iuniqtime; +extern struct timeval32 iuniqtime; extern kmutex_t ufs_iuniqtime_lock; #define ITIMES_NOLOCK(ip) ufs_itimes_nolock(ip) @@ -786,7 +786,7 @@ typedef struct ufsvfs { */ clock_t vfs_lastwhinetime; - int vfs_nolog_si; /* not logging summary info */ + int vfs_nolog_si; /* not logging summary info */ int vfs_validfs; /* indicates mounted fs */ /* diff --git a/usr/src/uts/i86pc/os/startup.c b/usr/src/uts/i86pc/os/startup.c index ac0ff1716a..3664fd3abf 100644 --- a/usr/src/uts/i86pc/os/startup.c +++ b/usr/src/uts/i86pc/os/startup.c @@ -235,8 +235,8 @@ static void layout_kernel_va(void); pgcnt_t physmem = PHYSMEM; pgcnt_t obp_pages; /* Memory used by PROM for its text and data */ -char *kobj_file_buf; -int kobj_file_bufsize; /* set in /etc/system */ +extern char *kobj_file_buf; +extern int kobj_file_bufsize; /* set in /etc/system */ /* Global variables for MP support. Used in mp_startup */ caddr_t rm_platter_va = 0; @@ -321,7 +321,7 @@ static struct seg *segmap = &kmapseg; /* easier to use name for in here */ struct seg *segkp = &kpseg; /* Pageable kernel virtual memory segment */ -struct seg kvseg_core; /* Segment used for the core heap */ +extern struct seg kvseg_core; /* Segment used for the core heap */ struct seg kpmseg; /* Segment used for physical mapping */ struct seg *segkpm = &kpmseg; /* 64bit kernel physical mapping segment */ diff --git a/usr/src/uts/i86pc/sys/cpupm_throttle.h b/usr/src/uts/i86pc/sys/cpupm_throttle.h index 5a607158da..7f9006759f 100644 --- a/usr/src/uts/i86pc/sys/cpupm_throttle.h +++ b/usr/src/uts/i86pc/sys/cpupm_throttle.h @@ -32,7 +32,7 @@ extern "C" { #endif -cpupm_state_ops_t cpupm_throttle_ops; +extern cpupm_state_ops_t cpupm_throttle_ops; extern void cpupm_throttle_manage_notification(void *); diff --git a/usr/src/uts/i86pc/sys/machsystm.h b/usr/src/uts/i86pc/sys/machsystm.h index 5f286ca4c6..e1a84f991a 100644 --- a/usr/src/uts/i86pc/sys/machsystm.h +++ b/usr/src/uts/i86pc/sys/machsystm.h @@ -135,10 +135,10 @@ extern uintptr_t (*get_intr_handler)(int, short); /* * Dispatcher hooks. */ -void (*idle_cpu)(); -void (*non_deep_idle_cpu)(); -void (*disp_enq_thread)(cpu_t *, int); -void (*non_deep_idle_disp_enq_thread)(cpu_t *, int); +extern void (*idle_cpu)(); +extern void (*non_deep_idle_cpu)(); +extern void (*disp_enq_thread)(cpu_t *, int); +extern void (*non_deep_idle_disp_enq_thread)(cpu_t *, int); #ifndef __xpv extern unsigned int microdata; |