Make mount.zfs(8) calling zfs_mount_at for legacy mounts as well
Commit 329e2ffa4b
has made mount.zfs(8) to
call libzfs function 'zfs_mount_at', in order to propagate dataset
properties into mount options. This fix however, is limited to a special
use case where mount.zfs(8) is used in initrd with option '-o zfsutil'.
If either initrd or the user need to use mount.zfs(8) to mount a file
system with 'mountpoint' set to 'legacy', '-o zfsutil' can't be used and
the original issue #7947 will still happen.
Since the existing code already excluded the possibility of calling
'zfs_mount_at' when it was invoked as a helper program from zfs(8), by
checking 'ZFS_MOUNT_HELPER' environment variable, it makes no sense to
avoid calling 'zfs_mount_at' without '-o zfsutil'.
An exception however, is when mount.zfs(8) was invoked with '-o remount'
to update the mount options for an existing mount point. In this case
call mount(2) directly without modifying the mount options passed from
command line.
Furthermore, don't run mount.zfs(8) helper for automounting snapshot.
The above change to make mount.zfs(8) to call 'zfs_mount_at'
apparently caused it to trigger an automount for the snapshot
directory. When the helper was invoked as a result of a snapshot
automount, an infinite recursion will occur.
Since the need of invoking user mode mount(8) for automounting was to
overcome that the 'vfs_kern_mount' being GPL-only, just run mount(8)
without the mount.zfs(8) helper by adding option '-i'.
Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: WHR <whr@rivoreo.one>
Closes #16393
This commit is contained in:
parent
cb36f4f352
commit
34118eac06
|
@ -269,8 +269,7 @@ main(int argc, char **argv)
|
|||
return (MOUNT_USAGE);
|
||||
}
|
||||
|
||||
if (!zfsutil || sloppy ||
|
||||
libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
|
||||
if (sloppy || libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
|
||||
zfs_adjust_mount_options(zhp, mntpoint, mntopts, mtabopt);
|
||||
}
|
||||
|
||||
|
@ -337,7 +336,7 @@ main(int argc, char **argv)
|
|||
dataset, mntpoint, mntflags, zfsflags, mntopts, mtabopt);
|
||||
|
||||
if (!fake) {
|
||||
if (zfsutil && !sloppy &&
|
||||
if (!remount && !sloppy &&
|
||||
!libzfs_envvar_is_set("ZFS_MOUNT_HELPER")) {
|
||||
error = zfs_mount_at(zhp, mntopts, mntflags, mntpoint);
|
||||
if (error) {
|
||||
|
|
|
@ -1101,8 +1101,8 @@ zfsctl_snapshot_mount(struct path *path, int flags)
|
|||
zfsvfs_t *snap_zfsvfs;
|
||||
zfs_snapentry_t *se;
|
||||
char *full_name, *full_path;
|
||||
char *argv[] = { "/usr/bin/env", "mount", "-t", "zfs", "-n", NULL, NULL,
|
||||
NULL };
|
||||
char *argv[] = { "/usr/bin/env", "mount", "-i", "-t", "zfs", "-n",
|
||||
NULL, NULL, NULL };
|
||||
char *envp[] = { NULL };
|
||||
int error;
|
||||
struct path spath;
|
||||
|
@ -1153,8 +1153,8 @@ zfsctl_snapshot_mount(struct path *path, int flags)
|
|||
* value from call_usermodehelper() will be (exitcode << 8 + signal).
|
||||
*/
|
||||
dprintf("mount; name=%s path=%s\n", full_name, full_path);
|
||||
argv[5] = full_name;
|
||||
argv[6] = full_path;
|
||||
argv[6] = full_name;
|
||||
argv[7] = full_path;
|
||||
error = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
|
||||
if (error) {
|
||||
if (!(error & MOUNT_BUSY << 8)) {
|
||||
|
|
Loading…
Reference in New Issue