summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2019-06-22 16:41:21 -0700
committerTony Hutter <[email protected]>2019-09-25 11:27:48 -0700
commit95fcb04215015950b3388ba0a6edad8e1b463415 (patch)
tree4883c19844cce6e23882805e684bc4dbe02c64a5 /cmd
parentd053481523b369b7c00f5fd1c1b1ae54876b8f69 (diff)
Let zfs mount all tolerate in-progress mounts
The zfs-mount service can unexpectedly fail to start when zfs encounters a mount that is in progress. This service uses zfs mount -a, which has a window between the time it checks if the dataset was mounted and when the actual mount (via mount.zfs binary) occurs. The reason for the racing mounts is that both zfs-mount.target and zfs-share.target are allowed to execute concurrently after the import. This is more of an issue with the relatively recent addition of parallel mounting, and we should consider serializing the mount and share targets. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: John Kennedy <[email protected]> Reviewed-by: Allan Jude <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #8881
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zfs/zfs_main.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 214a437c5..074216055 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -6446,8 +6446,25 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
return (1);
}
- if (zfs_mount(zhp, options, flags) != 0)
+ if (zfs_mount(zhp, options, flags) != 0) {
+ /*
+ * Check if a mount sneaked in after we checked
+ */
+ if (!explicit &&
+ libzfs_errno(g_zfs) == EZFS_MOUNTFAILED) {
+ usleep(10 * MILLISEC);
+ libzfs_mnttab_cache(g_zfs, B_FALSE);
+
+ if (zfs_is_mounted(zhp, NULL)) {
+ (void) fprintf(stderr, gettext(
+ "Ignoring previous 'already "
+ "mounted' error for '%s'\n"),
+ zfs_get_name(zhp));
+ return (0);
+ }
+ }
return (1);
+ }
break;
}