Commit 81102eb5 authored by Li Lingfeng's avatar Li Lingfeng
Browse files

nfs: pass flags to second superblock

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB42W1



--------------------------------

During the process of mounting an NFSv4 client, two superblocks will be
created in sequence. The first superblock corresponds to the root
directory exported by the server, and the second superblock corresponds to
the directory that will be actually mounted. The first superblock will
eventually be destroyed.
The flag passed from user mode will only be passed to the first
superblock, resulting in the actual used superblock not carrying the flag
passed from user mode(fs_context_for_submount() will set sb_flags as 0).

Since the superblock of NFS does not carry the ro tag, the file system
status displayed by /proc/self/mountstats shows that NFS is always in the
rw state, which may mislead users.

Pass sb_flags of the fc which carry flags passed by user to second
superblock to fix it.

Fixes: 281cad46 ("NFS: Create a submount rpc_op")
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 66eb0830
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -253,6 +253,8 @@ struct dentry *nfs4_try_mount(int flags, const char *dev_name,

	res = nfs_follow_remote_path(root_mnt, export_path);

	if (!IS_ERR(res))
		res->d_sb->s_flags = flags;
	dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n",
		 PTR_ERR_OR_ZERO(res),
		 IS_ERR(res) ? " [error]" : "");