aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorUmer Saleem <[email protected]>2023-09-02 05:25:11 +0500
committerBrian Behlendorf <[email protected]>2023-09-02 10:30:38 -0700
commit32949f2560bf35ec86dfa5d984514908e0eb3ecc (patch)
tree43435e2d6cbe4b3906581eab8ca33e15c521fbe4 /cmd
parent79ac1b29d5b586fcc63032bfaa385eef4e489a52 (diff)
Relax error reporting in zpool import and zpool split
For zpool import and zpool split, zpool_enable_datasets is called to mount and share all datasets in a pool. If there is an error while mounting or sharing any dataset in the pool, the status of import or split is reported as failure. However, the changes do show up in zpool list. This commit updates the error reporting in zpool import and zpool split path. More descriptive messages are shown to user in case there is an error during mount or share. Errors in mount or share do not effect the overall status of zpool import and zpool split. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Signed-off-by: Umer Saleem <[email protected]> Closes #15216
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zpool/zpool_main.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 10a3b5b14..6d0dae8d8 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -3143,6 +3143,7 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
nvlist_t *props, int flags)
{
int ret = 0;
+ int ms_status = 0;
zpool_handle_t *zhp;
const char *name;
uint64_t version;
@@ -3232,10 +3233,15 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
ret = 1;
if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL &&
- !(flags & ZFS_IMPORT_ONLY) &&
- zpool_enable_datasets(zhp, mntopts, 0) != 0) {
- zpool_close(zhp);
- return (1);
+ !(flags & ZFS_IMPORT_ONLY)) {
+ ms_status = zpool_enable_datasets(zhp, mntopts, 0);
+ if (ms_status == EZFS_SHAREFAILED) {
+ (void) fprintf(stderr, gettext("Import was "
+ "successful, but unable to share some datasets"));
+ } else if (ms_status == EZFS_MOUNTFAILED) {
+ (void) fprintf(stderr, gettext("Import was "
+ "successful, but unable to mount some datasets"));
+ }
}
zpool_close(zhp);
@@ -6755,6 +6761,7 @@ zpool_do_split(int argc, char **argv)
char *mntopts = NULL;
splitflags_t flags;
int c, ret = 0;
+ int ms_status = 0;
boolean_t loadkeys = B_FALSE;
zpool_handle_t *zhp;
nvlist_t *config, *props = NULL;
@@ -6891,13 +6898,18 @@ zpool_do_split(int argc, char **argv)
ret = 1;
}
- if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL &&
- zpool_enable_datasets(zhp, mntopts, 0) != 0) {
- ret = 1;
- (void) fprintf(stderr, gettext("Split was successful, but "
- "the datasets could not all be mounted\n"));
- (void) fprintf(stderr, gettext("Try doing '%s' with a "
- "different altroot\n"), "zpool import");
+ if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL) {
+ ms_status = zpool_enable_datasets(zhp, mntopts, 0);
+ if (ms_status == EZFS_SHAREFAILED) {
+ (void) fprintf(stderr, gettext("Split was successful, "
+ "datasets are mounted but sharing of some datasets "
+ "has failed\n"));
+ } else if (ms_status == EZFS_MOUNTFAILED) {
+ (void) fprintf(stderr, gettext("Split was successful"
+ ", but some datasets could not be mounted\n"));
+ (void) fprintf(stderr, gettext("Try doing '%s' with a "
+ "different altroot\n"), "zpool import");
+ }
}
zpool_close(zhp);
nvlist_free(config);