ITADN

`mount -o rw` doesn't grant write permissions for files in a `readonly=on` dataset since 2.4.2

#18557Openfbq 创建于 2026-05-18
Type: Defect
F
fbqcommented
<!-- Please fill out the following template, which will help other contributors address your issue. --> <!-- Thank you for reporting an issue. *IMPORTANT* - Please check our issue tracker before opening a new issue. Additional valuable information can be found in the OpenZFS documentation and mailing list archives. Please fill in as much of the template as possible. --> ### System information <!-- add version after "|" character --> Type | Version/Name --- | --- Distribution Name | Ubuntu Distribution Version | 24.04 Kernel Version | 7.0.7 Architecture | x86_64 OpenZFS Version | 2.4.2 <!-- Command to find OpenZFS version: zfs version Commands to find kernel version: uname -r # Linux freebsd-version -r # FreeBSD --> ### Describe the problem you're observing I'm not sure whether the behavior is expected, but previously (in .2.4.1), when I `mount -o rw` a `readonly=on` dataset, I have the write permissions to the files. I.e. the mount option overwrites the dataset readonly setting. However in 2.4.2, `mount -o rw` on a `readonly=on` dataset doesn't give me write permissions to the files. ### Describe how to reproduce the problem ```shell # dd if=/dev/zero of=/test-disk.img bs=1M count=1024 # 1G disk file for testing # zpool create -m none mytest /test-disk.img # zfs create -o mountpoint=/test -u -o readonly=on mytest/ro # mkdir /test # zfs mount -o rw mytest/ro # touch /test/a ``` The `touch` command will fail on 2.4.2 with "touch: cannot touch '/test/a': Read-only file system", but will succeed on 2.4.1. ### Include any warning/errors/backtraces from the system logs <!-- *IMPORTANT* - Please mark logs and text output from terminal commands or else Github will not display them correctly. An example is provided below. Example: ``` this is an example how log text should be marked (wrap it with ```) ``` --> ### Possible reasons code [here](https://github.com/openzfs/zfs/blob/master/module/os/linux/zfs/zpl_super.c#L887-L889): ``` if (fc->sb_flags & SB_RDONLY) { vfs->vfs_readonly = B_TRUE; vfs->vfs_do_readonly = B_TRUE; } ``` `->vfs_do_readonly` is only set to be `B_TRUE` when mounting with `mount -o ro`. I.e. `->vfs_do_readonly` is false when `mount -o rw` hence the `readonly_changed_cb()` in `zfs_register_callbacks()` won't be executed.
2 条评论