nfs: Fix incorrect read-only status reporting in mountstats
Subsystems (5)
PATCH 1/1 nfs: Fix incorrect read-only status reporting in mountstats
In the process of read-only mounting of NFS, only the first generated superblock carries the ro flag passed from the user space. However, NFS mounting may generate multiple superblocks, and the last generated superblock is the one actually used. This leads to a situation where the superblock of a read-only NFS file system may not have the ro flag. Therefore, using s_flags to determine whether an NFS file system is read-only is incorrect.
Use mnt_flags instead of s_flags to decide whether the file system state displayed by the /proc/self/mountstats interface is read-only or not.
--- fs/nfs/internal.h | 2 +- fs/nfs/super.c | 12 ++++++------ fs/proc_namespace.c | 2 +- fs/smb/client/cifsfs.c | 2 +- include/linux/fs.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
fs/nfs/internal.h +1 -1
@@ -565,7 +565,7 @@ int nfs_statfs(struct dentry *, struct kstatfs *);int nfs_show_options (struct seq_file *,struct dentry *);int nfs_show_devname (struct seq_file *,struct dentry *);int nfs_show_path (struct seq_file *,struct dentry *); -int nfs_show_stats (struct seq_file *,struct dentry *); +int nfs_show_stats (struct seq_file *,struct vfsmount *);int nfs_reconfigure (struct fs_context *);/* write.c */
fs/nfs/super.c +6 -6
@@ -662,10 +662,10 @@ EXPORT_SYMBOL_GPL(nfs_show_path);/* * Present statistical information for this VFS mountpoint */ -int nfs_show_stats (struct seq_file *m,struct dentry *root) +int nfs_show_stats (struct seq_file *m,struct vfsmount *mnt) {int i, cpu; -struct nfs_server *nfss =NFS_SB (root->d_sb); +struct nfs_server *nfss =NFS_SB (mnt->mnt_sb);struct rpc_auth *auth = nfss->client->cl_auth;struct nfs_iostats totals = { };
@@ -675,10 +675,10 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)* Display all mount option settings */ seq_puts (m,"\n\topts:\t" ); -seq_puts (m,sb_rdonly (root->d_sb) ?"ro" :"rw" ); -seq_puts (m, root->d_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NOATIME ?",noatime" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" ); +seq_puts (m, (mnt->mnt_flags &MNT_READONLY ) ?"ro" :"rw" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NOATIME ?",noatime" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" );nfs_show_mount_options (m, nfss,1 );seq_printf (m,"\n\tage:\t%lu" , (jiffies - nfss->mount_time) /HZ );
fs/proc_namespace.c +1 -1
@@ -227,7 +227,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)/* optional statistics */ if (sb->s_op->show_stats) {seq_putc (m,' ' ); - err = sb->s_op->show_stats (m, mnt_path.dentry); + err = sb->s_op->show_stats (m, mnt); }seq_putc (m,'\n' );
fs/smb/client/cifsfs.c +1 -1
@@ -836,7 +836,7 @@ static int cifs_freeze(struct super_block *sb) }#ifdef CONFIG_CIFS_STATS2 -static int cifs_show_stats (struct seq_file *s,struct dentry *root) +static int cifs_show_stats (struct seq_file *s,struct vfsmount *mnt) {/* BB FIXME */ return 0 ;
include/linux/fs.h +1 -1
@@ -2308,7 +2308,7 @@ struct super_operations {int (*show_options)(struct seq_file *,struct dentry *);int (*show_devname)(struct seq_file *,struct dentry *);int (*show_path)(struct seq_file *,struct dentry *); -int (*show_stats)(struct seq_file *,struct dentry *); +int (*show_stats)(struct seq_file *,struct vfsmount *);#ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t );ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t );
Signature · 1 line
2.31.1
Do you have a repro scenario example of this for cifs.ko? the suggested change seems plausible, but wondering about how to recreate the case you mention where "mounting may generate multiple superblocks" (are there DFS examples that this would help?)
Quoted 109 lines · Li Lingfeng
In the process of read-only mounting of NFS, only the first generated superblock carries the ro flag passed from the user space. However, NFS mounting may generate multiple superblocks, and the last generated superblock is the one actually used. This leads to a situation where the superblock of a read-only NFS file system may not have the ro flag. Therefore, using
s_flagsto determine whether an NFS file system is read-only is incorrect.Use
mnt_flagsinstead ofs_flagsto decide whether the file system state displayed by the/proc/self/mountstatsinterface is read-only or not.Signed-off-by Li Lingfeng <[email protected]>--- fs/nfs/internal.h | 2 +- fs/nfs/super.c | 12 ++++++------ fs/proc_namespace.c | 2 +- fs/smb/client/cifsfs.c | 2 +- include/linux/fs.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)fs/nfs/internal.h +1
-1@@ -565,7 +565,7 @@ int nfs_statfs(struct dentry *, struct kstatfs *);int nfs_show_options (struct seq_file *,struct dentry *);int nfs_show_devname (struct seq_file *,struct dentry *);int nfs_show_path (struct seq_file *,struct dentry *); -int nfs_show_stats (struct seq_file *,struct dentry *); +int nfs_show_stats (struct seq_file *,struct vfsmount *);int nfs_reconfigure (struct fs_context *);/* write.c */ fs/nfs/super.c +6
-6@@ -662,10 +662,10 @@ EXPORT_SYMBOL_GPL(nfs_show_path);/* * Present statistical information for this VFS mountpoint */ -int nfs_show_stats (struct seq_file *m,struct dentry *root) +int nfs_show_stats (struct seq_file *m,struct vfsmount *mnt) {int i, cpu; -struct nfs_server *nfss =NFS_SB (root->d_sb); +struct nfs_server *nfss =NFS_SB (mnt->mnt_sb);struct rpc_auth *auth = nfss->client->cl_auth;struct nfs_iostats totals = { };@@ -675,10 +675,10 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)* Display all mount option settings */ seq_puts (m,"\n\topts:\t" ); -seq_puts (m,sb_rdonly (root->d_sb) ?"ro" :"rw" ); -seq_puts (m, root->d_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NOATIME ?",noatime" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" ); +seq_puts (m, (mnt->mnt_flags &MNT_READONLY ) ?"ro" :"rw" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NOATIME ?",noatime" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" );nfs_show_mount_options (m, nfss,1 );seq_printf (m,"\n\tage:\t%lu" , (jiffies - nfss->mount_time) /HZ );fs/proc_namespace.c +1
-1@@ -227,7 +227,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)/* optional statistics */ if (sb->s_op->show_stats) {seq_putc (m,' ' ); - err = sb->s_op->show_stats (m, mnt_path.dentry); + err = sb->s_op->show_stats (m, mnt); }seq_putc (m,'\n' );fs/smb/client/cifsfs.c +1
-1@@ -836,7 +836,7 @@ static int cifs_freeze(struct super_block *sb) }#ifdef CONFIG_CIFS_STATS2 -static int cifs_show_stats (struct seq_file *s,struct dentry *root) +static int cifs_show_stats (struct seq_file *s,struct vfsmount *mnt) {/* BB FIXME */ return 0 ;include/linux/fs.h +1
-2@@ -2308,7 +2308,7 @@ struct super_operations {int (*show_options)(struct seq_file *,struct dentry *);int (*show_devname)(struct seq_file *,struct dentry *);int (*show_path)(struct seq_file *,struct dentry *); -int (*show_stats)(struct seq_file *,struct dentry *); +int (*show_stats)(struct seq_file *,struct vfsmount *);#ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t );ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t ); --2.31.1
Signature · 3 lines
Thanks, Steve
Apologies, I'm not well-versed in CIFS, but cifs_show_stats lacks the intended implementation. From my understanding, altering the parameter list of the show_stats callback does not affect CIFS.
Thanks.
Quoted 115 lines · Steve French
Do you have a repro scenario example of this for cifs.ko? the suggested change seems plausible, but wondering about how to recreate the case you mention where "mounting may generate multiple superblocks" (are there DFS examples that this would help?)
Quoted 108 lines · Li Lingfeng
In the process of read-only mounting of NFS, only the first generated superblock carries the ro flag passed from the user space. However, NFS mounting may generate multiple superblocks, and the last generated superblock is the one actually used. This leads to a situation where the superblock of a read-only NFS file system may not have the ro flag. Therefore, using
s_flagsto determine whether an NFS file system is read-only is incorrect.Use
mnt_flagsinstead ofs_flagsto decide whether the file system state displayed by the/proc/self/mountstatsinterface is read-only or not.Signed-off-by Li Lingfeng <[email protected]>--- fs/nfs/internal.h | 2 +- fs/nfs/super.c | 12 ++++++------ fs/proc_namespace.c | 2 +- fs/smb/client/cifsfs.c | 2 +- include/linux/fs.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)fs/nfs/internal.h +1
-1@@ -565,7 +565,7 @@ int nfs_statfs(struct dentry *, struct kstatfs *);int nfs_show_options (struct seq_file *,struct dentry *);int nfs_show_devname (struct seq_file *,struct dentry *);int nfs_show_path (struct seq_file *,struct dentry *); -int nfs_show_stats (struct seq_file *,struct dentry *); +int nfs_show_stats (struct seq_file *,struct vfsmount *);int nfs_reconfigure (struct fs_context *);/* write.c */ fs/nfs/super.c +6
-6@@ -662,10 +662,10 @@ EXPORT_SYMBOL_GPL(nfs_show_path);/* * Present statistical information for this VFS mountpoint */ -int nfs_show_stats (struct seq_file *m,struct dentry *root) +int nfs_show_stats (struct seq_file *m,struct vfsmount *mnt) {int i, cpu; -struct nfs_server *nfss =NFS_SB (root->d_sb); +struct nfs_server *nfss =NFS_SB (mnt->mnt_sb);struct rpc_auth *auth = nfss->client->cl_auth;struct nfs_iostats totals = { };@@ -675,10 +675,10 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)* Display all mount option settings */ seq_puts (m,"\n\topts:\t" ); -seq_puts (m,sb_rdonly (root->d_sb) ?"ro" :"rw" ); -seq_puts (m, root->d_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NOATIME ?",noatime" :"" ); -seq_puts (m, root->d_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" ); +seq_puts (m, (mnt->mnt_flags &MNT_READONLY ) ?"ro" :"rw" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_SYNCHRONOUS ?",sync" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NOATIME ?",noatime" :"" ); +seq_puts (m, mnt->mnt_sb->s_flags &SB_NODIRATIME ?",nodiratime" :"" );nfs_show_mount_options (m, nfss,1 );seq_printf (m,"\n\tage:\t%lu" , (jiffies - nfss->mount_time) /HZ );fs/proc_namespace.c +1
-1@@ -227,7 +227,7 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt)/* optional statistics */ if (sb->s_op->show_stats) {seq_putc (m,' ' ); - err = sb->s_op->show_stats (m, mnt_path.dentry); + err = sb->s_op->show_stats (m, mnt); }seq_putc (m,'\n' );fs/smb/client/cifsfs.c +1
-1@@ -836,7 +836,7 @@ static int cifs_freeze(struct super_block *sb) }#ifdef CONFIG_CIFS_STATS2 -static int cifs_show_stats (struct seq_file *s,struct dentry *root) +static int cifs_show_stats (struct seq_file *s,struct vfsmount *mnt) {/* BB FIXME */ return 0 ;include/linux/fs.h +1
-2@@ -2308,7 +2308,7 @@ struct super_operations {int (*show_options)(struct seq_file *,struct dentry *);int (*show_devname)(struct seq_file *,struct dentry *);int (*show_path)(struct seq_file *,struct dentry *); -int (*show_stats)(struct seq_file *,struct dentry *); +int (*show_stats)(struct seq_file *,struct vfsmount *);#ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t );ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t ); --2.31.1