Skip to content

Commit 1342f9d

Browse files
ChenXiaoSongchucklever
authored andcommitted
nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops
Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 6477661 commit 1342f9d

3 files changed

Lines changed: 4 additions & 14 deletions

File tree

fs/nfsd/filecache.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
12121212
* scraping this file for info should test the labels to ensure they're
12131213
* getting the correct field.
12141214
*/
1215-
static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
1215+
int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
12161216
{
12171217
unsigned long releases = 0, pages_flushed = 0, evictions = 0;
12181218
unsigned long hits = 0, acquisitions = 0;
@@ -1259,8 +1259,3 @@ static int nfsd_file_cache_stats_show(struct seq_file *m, void *v)
12591259
seq_printf(m, "pages flushed: %lu\n", pages_flushed);
12601260
return 0;
12611261
}
1262-
1263-
int nfsd_file_cache_stats_open(struct inode *inode, struct file *file)
1264-
{
1265-
return single_open(file, nfsd_file_cache_stats_show, NULL);
1266-
}

fs/nfsd/filecache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
6060
unsigned int may_flags, struct nfsd_file **nfp);
6161
__be32 nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
6262
unsigned int may_flags, struct nfsd_file **nfp);
63-
int nfsd_file_cache_stats_open(struct inode *, struct file *);
63+
int nfsd_file_cache_stats_show(struct seq_file *m, void *v);
6464
#endif /* _FS_NFSD_FILECACHE_H */

fs/nfsd/nfsctl.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,7 @@ static const struct file_operations pool_stats_operations = {
206206

207207
DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats);
208208

209-
static const struct file_operations filecache_ops = {
210-
.open = nfsd_file_cache_stats_open,
211-
.read = seq_read,
212-
.llseek = seq_lseek,
213-
.release = single_release,
214-
};
209+
DEFINE_SHOW_ATTRIBUTE(nfsd_file_cache_stats);
215210

216211
/*----------------------------------------------------------------------------*/
217212
/*
@@ -1355,7 +1350,7 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
13551350
[NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
13561351
[NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
13571352
[NFSD_MaxConnections] = {"max_connections", &transaction_ops, S_IWUSR|S_IRUGO},
1358-
[NFSD_Filecache] = {"filecache", &filecache_ops, S_IRUGO},
1353+
[NFSD_Filecache] = {"filecache", &nfsd_file_cache_stats_fops, S_IRUGO},
13591354
#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
13601355
[NFSD_SupportedEnctypes] = {"supported_krb5_enctypes",
13611356
&supported_enctypes_fops, S_IRUGO},

0 commit comments

Comments
 (0)