Skip to content

Commit 6477661

Browse files
ChenXiaoSongchucklever
authored andcommitted
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops
Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. nfsd_net is converted from seq_file->file instead of seq_file->private in nfsd_reply_cache_stats_show(). Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> [ cel: reduce line length ] Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 1d7f6b3 commit 6477661

3 files changed

Lines changed: 7 additions & 18 deletions

File tree

fs/nfsd/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ int nfsd_reply_cache_init(struct nfsd_net *);
8484
void nfsd_reply_cache_shutdown(struct nfsd_net *);
8585
int nfsd_cache_lookup(struct svc_rqst *);
8686
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
87-
int nfsd_reply_cache_stats_open(struct inode *, struct file *);
87+
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v);
8888

8989
#endif /* NFSCACHE_H */

fs/nfsd/nfscache.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data)
604604
* scraping this file for info should test the labels to ensure they're
605605
* getting the correct field.
606606
*/
607-
static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
607+
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
608608
{
609-
struct nfsd_net *nn = m->private;
609+
struct nfsd_net *nn = net_generic(file_inode(m->file)->i_sb->s_fs_info,
610+
nfsd_net_id);
610611

611612
seq_printf(m, "max entries: %u\n", nn->max_drc_entries);
612613
seq_printf(m, "num entries: %u\n",
@@ -626,11 +627,3 @@ static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
626627
seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize);
627628
return 0;
628629
}
629-
630-
int nfsd_reply_cache_stats_open(struct inode *inode, struct file *file)
631-
{
632-
struct nfsd_net *nn = net_generic(file_inode(file)->i_sb->s_fs_info,
633-
nfsd_net_id);
634-
635-
return single_open(file, nfsd_reply_cache_stats_show, nn);
636-
}

fs/nfsd/nfsctl.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ static const struct file_operations pool_stats_operations = {
204204
.release = nfsd_pool_stats_release,
205205
};
206206

207-
static const struct file_operations reply_cache_stats_operations = {
208-
.open = nfsd_reply_cache_stats_open,
209-
.read = seq_read,
210-
.llseek = seq_lseek,
211-
.release = single_release,
212-
};
207+
DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats);
213208

214209
static const struct file_operations filecache_ops = {
215210
.open = nfsd_file_cache_stats_open,
@@ -1354,7 +1349,8 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
13541349
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
13551350
[NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
13561351
[NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO},
1357-
[NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &reply_cache_stats_operations, S_IRUGO},
1352+
[NFSD_Reply_Cache_Stats] = {"reply_cache_stats",
1353+
&nfsd_reply_cache_stats_fops, S_IRUGO},
13581354
[NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
13591355
[NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
13601356
[NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},

0 commit comments

Comments
 (0)