Skip to content

Commit 9beeaab

Browse files
ChenXiaoSongchucklever
authored andcommitted
nfsd: use DEFINE_SHOW_ATTRIBUTE to define export_features_fops and supported_enctypes_fops
Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com> [ cel: reduce line length ] Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 0cfb0c4 commit 9beeaab

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

fs/nfsd/nfsctl.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,7 @@ static int export_features_show(struct seq_file *m, void *v)
185185
return 0;
186186
}
187187

188-
static int export_features_open(struct inode *inode, struct file *file)
189-
{
190-
return single_open(file, export_features_show, NULL);
191-
}
192-
193-
static const struct file_operations export_features_operations = {
194-
.open = export_features_open,
195-
.read = seq_read,
196-
.llseek = seq_lseek,
197-
.release = single_release,
198-
};
188+
DEFINE_SHOW_ATTRIBUTE(export_features);
199189

200190
#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
201191
static int supported_enctypes_show(struct seq_file *m, void *v)
@@ -204,17 +194,7 @@ static int supported_enctypes_show(struct seq_file *m, void *v)
204194
return 0;
205195
}
206196

207-
static int supported_enctypes_open(struct inode *inode, struct file *file)
208-
{
209-
return single_open(file, supported_enctypes_show, NULL);
210-
}
211-
212-
static const struct file_operations supported_enctypes_ops = {
213-
.open = supported_enctypes_open,
214-
.read = seq_read,
215-
.llseek = seq_lseek,
216-
.release = single_release,
217-
};
197+
DEFINE_SHOW_ATTRIBUTE(supported_enctypes);
218198
#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
219199

220200
static const struct file_operations pool_stats_operations = {
@@ -1365,7 +1345,7 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
13651345
/* Per-export io stats use same ops as exports file */
13661346
[NFSD_Export_Stats] = {"export_stats", &exports_nfsd_operations, S_IRUGO},
13671347
[NFSD_Export_features] = {"export_features",
1368-
&export_features_operations, S_IRUGO},
1348+
&export_features_fops, S_IRUGO},
13691349
[NFSD_FO_UnlockIP] = {"unlock_ip",
13701350
&transaction_ops, S_IWUSR|S_IRUSR},
13711351
[NFSD_FO_UnlockFS] = {"unlock_filesystem",
@@ -1381,7 +1361,8 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc)
13811361
[NFSD_MaxConnections] = {"max_connections", &transaction_ops, S_IWUSR|S_IRUGO},
13821362
[NFSD_Filecache] = {"filecache", &filecache_ops, S_IRUGO},
13831363
#if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE)
1384-
[NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO},
1364+
[NFSD_SupportedEnctypes] = {"supported_krb5_enctypes",
1365+
&supported_enctypes_fops, S_IRUGO},
13851366
#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
13861367
#ifdef CONFIG_NFSD_V4
13871368
[NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR},

0 commit comments

Comments
 (0)