nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops
[ Upstream commit 64776611a06322b99386f8dfe3b3ba1aa0347a38 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
443e648425
commit
21e18dd5eb
@@ -84,6 +84,6 @@ int nfsd_reply_cache_init(struct nfsd_net *);
|
|||||||
void nfsd_reply_cache_shutdown(struct nfsd_net *);
|
void nfsd_reply_cache_shutdown(struct nfsd_net *);
|
||||||
int nfsd_cache_lookup(struct svc_rqst *);
|
int nfsd_cache_lookup(struct svc_rqst *);
|
||||||
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
|
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
|
||||||
int nfsd_reply_cache_stats_open(struct inode *, struct file *);
|
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v);
|
||||||
|
|
||||||
#endif /* NFSCACHE_H */
|
#endif /* NFSCACHE_H */
|
||||||
|
@@ -603,9 +603,10 @@ nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data)
|
|||||||
* scraping this file for info should test the labels to ensure they're
|
* scraping this file for info should test the labels to ensure they're
|
||||||
* getting the correct field.
|
* getting the correct field.
|
||||||
*/
|
*/
|
||||||
static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
|
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
struct nfsd_net *nn = m->private;
|
struct nfsd_net *nn = net_generic(file_inode(m->file)->i_sb->s_fs_info,
|
||||||
|
nfsd_net_id);
|
||||||
|
|
||||||
seq_printf(m, "max entries: %u\n", nn->max_drc_entries);
|
seq_printf(m, "max entries: %u\n", nn->max_drc_entries);
|
||||||
seq_printf(m, "num entries: %u\n",
|
seq_printf(m, "num entries: %u\n",
|
||||||
@@ -625,11 +626,3 @@ static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v)
|
|||||||
seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize);
|
seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nfsd_reply_cache_stats_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
struct nfsd_net *nn = net_generic(file_inode(file)->i_sb->s_fs_info,
|
|
||||||
nfsd_net_id);
|
|
||||||
|
|
||||||
return single_open(file, nfsd_reply_cache_stats_show, nn);
|
|
||||||
}
|
|
||||||
|
@@ -204,12 +204,7 @@ static const struct file_operations pool_stats_operations = {
|
|||||||
.release = nfsd_pool_stats_release,
|
.release = nfsd_pool_stats_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct file_operations reply_cache_stats_operations = {
|
DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats);
|
||||||
.open = nfsd_reply_cache_stats_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct file_operations filecache_ops = {
|
static const struct file_operations filecache_ops = {
|
||||||
.open = nfsd_file_cache_stats_open,
|
.open = nfsd_file_cache_stats_open,
|
||||||
@@ -1354,7 +1349,8 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
|
|||||||
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
|
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
|
||||||
[NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
|
[NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR},
|
||||||
[NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO},
|
[NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO},
|
||||||
[NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &reply_cache_stats_operations, S_IRUGO},
|
[NFSD_Reply_Cache_Stats] = {"reply_cache_stats",
|
||||||
|
&nfsd_reply_cache_stats_fops, S_IRUGO},
|
||||||
[NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
|
[NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR},
|
||||||
[NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
|
[NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO},
|
||||||
[NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
|
[NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO},
|
||||||
|
Reference in New Issue
Block a user