mirror_zfs/lib
Ameer Hamza 1eace59060
libzfs: use mount_setattr for selective remount including legacy mounts
When a namespace property is changed via zfs set, libzfs remounts the
filesystem to propagate the new VFS mount flags. The current approach
uses mount(2) with MS_REMOUNT, which reads all namespace properties
from ZFS and applies them together. This has two problems:

1. Linux VFS resets unspecified per-mount flags on remount. If an
   administrator sets a temporary flag (e.g. mount -o remount,noatime),
   a subsequent zfs set on any namespace property clobbers it.

2. Two concurrent zfs set operations on different namespace properties
   can overwrite each other's mount flags.

Additionally, legacy datasets (mountpoint=legacy) were never remounted
on namespace property changes since zfs_is_mountable() returns false
for them.

Add zfs_mount_setattr() which uses mount_setattr(2) to selectively
update only the mount flags that correspond to the changed property.
For legacy datasets, /proc/mounts is iterated to update all
mountpoints. On kernels without mount_setattr (ENOSYS), non-legacy
datasets fall back to a full remount; legacy mounts are skipped to
avoid clobbering temporary flags.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #18257
2026-03-09 11:06:22 -07:00
..
libavl build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
libbtree Move range_tree, btree, highbit64 to common code 2026-02-22 11:43:51 -08:00
libefi build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
libicp build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
libnvpair build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
librange_tree Move range_tree, btree, highbit64 to common code 2026-02-22 11:43:51 -08:00
libspl simd: detect and surface support for Intel SHA512 extensions 2026-02-25 12:47:48 -08:00
libzdb More consistent use of TREE_* macros in AVL comparators 2026-03-03 09:08:23 -08:00
libzfs libzfs: use mount_setattr for selective remount including legacy mounts 2026-03-09 11:06:22 -07:00
libzfs_core Implement lzc_send_progress 2026-03-06 11:05:58 -08:00
libzfsbootenv build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
libzpool libzpool: lift zfs_file ops out to separate source file 2026-03-05 18:07:46 -08:00
libzstd Zstd: Integrate v1.5.7 into the ZFS build system 2026-01-20 13:41:06 -08:00
libzutil build: add SPDX license tags to build system files 2026-01-08 15:08:03 -08:00
Makefile.am Move range_tree, btree, highbit64 to common code 2026-02-22 11:43:51 -08:00