Patch "nfs: ignore SB_RDONLY when mounting nfs" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nfs: ignore SB_RDONLY when mounting nfs

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfs-ignore-sb_rdonly-when-mounting-nfs.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f04db3557f089f8cac7fd1efa0ce9980ff967221
Author: Li Lingfeng <lilingfeng3@xxxxxxxxxx>
Date:   Thu Nov 14 12:53:03 2024 +0800

    nfs: ignore SB_RDONLY when mounting nfs
    
    [ Upstream commit 52cb7f8f177878b4f22397b9c4d2c8f743766be3 ]
    
    When exporting only one file system with fsid=0 on the server side, the
    client alternately uses the ro/rw mount options to perform the mount
    operation, and a new vfsmount is generated each time.
    
    It can be reproduced as follows:
    [root@localhost ~]# mount /dev/sda /mnt2
    [root@localhost ~]# echo "/mnt2 *(rw,no_root_squash,fsid=0)" >/etc/exports
    [root@localhost ~]# systemctl restart nfs-server
    [root@localhost ~]# mount -t nfs -o ro,vers=4 127.0.0.1:/ /mnt/sdaa
    [root@localhost ~]# mount -t nfs -o rw,vers=4 127.0.0.1:/ /mnt/sdaa
    [root@localhost ~]# mount -t nfs -o ro,vers=4 127.0.0.1:/ /mnt/sdaa
    [root@localhost ~]# mount -t nfs -o rw,vers=4 127.0.0.1:/ /mnt/sdaa
    [root@localhost ~]# mount | grep nfs4
    127.0.0.1:/ on /mnt/sdaa type nfs4 (ro,relatime,vers=4.2,rsize=1048576,...
    127.0.0.1:/ on /mnt/sdaa type nfs4 (rw,relatime,vers=4.2,rsize=1048576,...
    127.0.0.1:/ on /mnt/sdaa type nfs4 (ro,relatime,vers=4.2,rsize=1048576,...
    127.0.0.1:/ on /mnt/sdaa type nfs4 (rw,relatime,vers=4.2,rsize=1048576,...
    [root@localhost ~]#
    
    We expected that after mounting with the ro option, using the rw option to
    mount again would return EBUSY, but the actual situation was not the case.
    
    As shown above, when mounting for the first time, a superblock with the ro
    flag will be generated, and at the same time, in do_new_mount_fc -->
    do_add_mount, it detects that the superblock corresponding to the current
    target directory is inconsistent with the currently generated one
    (path->mnt->mnt_sb != newmnt->mnt.mnt_sb), and a new vfsmount will be
    generated.
    
    When mounting with the rw option for the second time, since no matching
    superblock can be found in the fs_supers list, a new superblock with the
    rw flag will be generated again. The superblock in use (ro) is different
    from the newly generated superblock (rw), and a new vfsmount will be
    generated again.
    
    When mounting with the ro option for the third time, the superblock (ro)
    is found in fs_supers, the superblock in use (rw) is different from the
    found superblock (ro), and a new vfsmount will be generated again.
    
    We can switch between ro/rw through remount, and only one superblock needs
    to be generated, thus avoiding the problem of repeated generation of
    vfsmount caused by switching superblocks.
    
    Furthermore, This can also resolve the issue described in the link.
    
    Fixes: 275a5d24bf56 ("NFS: Error when mounting the same filesystem with different options")
    Link: https://lore.kernel.org/all/20240604112636.236517-3-lilingfeng@xxxxxxxxxxxxxxx/
    Signed-off-by: Li Lingfeng <lilingfeng3@xxxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 430733e3eff26..6bcc4b0e00ab7 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -12,7 +12,7 @@
 #include <linux/nfslocalio.h>
 #include <linux/wait_bit.h>
 
-#define NFS_SB_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
+#define NFS_SB_MASK (SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
 
 extern const struct export_operations nfs_export_ops;
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux