From 4b5105a7f7e844dba5165de656490072bd49b047 Mon Sep 17 00:00:00 2001 From: Umer Saleem Date: Tue, 15 Aug 2023 18:01:19 +0500 Subject: [PATCH] Ignore errors due to sharesmb on pool import For users who have sharesmb property set to on, when trying to import the pool on TrueNAS, they run into error and pool import fails because the samba usershares path on Linux, i.e. /var/lib/samba/usershares does not exist on TrueNAS SCALE. To resolve this issue, do not return the error while enabling the SMB shares, instead print the error message and continue. Since we rely on middleware to manage the SMB shares, returing the error results in failure of overall command, even though imported pool shows up in zpool list. Signed-off-by: Umer Saleem --- lib/libzfs/libzfs_mount.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 5d1fe651c97e..494f9af81547 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -738,10 +738,26 @@ zfs_share(zfs_handle_t *zhp, const enum sa_protocol *proto) err = sa_enable_share(zfs_get_name(zhp), mountpoint, shareopts, *curr_proto); if (err != SA_OK) { - return (zfs_error_fmt(zhp->zfs_hdl, - proto_table[*curr_proto].p_share_err, - dgettext(TEXT_DOMAIN, "cannot share '%s: %s'"), - zfs_get_name(zhp), sa_errorstr(err))); + /* + * For TrueNAS, do not return the error encountered + * while enabling the SMB share, instead print the + * error message and continue. We rely on middleware + * to manage the SMB shares. Returning this error + * from here results in failure of overall command, + * even though pool shows up in zpool list. + */ + if (proto_table[*curr_proto].p_prop == ZFS_PROP_SHARESMB) + zfs_error_fmt(zhp->zfs_hdl, + proto_table[*curr_proto].p_share_err, + dgettext(TEXT_DOMAIN, + "cannot share '%s: %s'"), + zfs_get_name(zhp), sa_errorstr(err)); + else + return (zfs_error_fmt(zhp->zfs_hdl, + proto_table[*curr_proto].p_share_err, + dgettext(TEXT_DOMAIN, + "cannot share '%s: %s'"), + zfs_get_name(zhp), sa_errorstr(err))); } }