diff mbox series

[17/49] lustre: llite: create file_operations registration function.

Message ID 1618459361-17909-18-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to OpenSFS as of March 30 2021 | expand

Commit Message

James Simmons April 15, 2021, 4:02 a.m. UTC
Create new ll_register_file_operations() to set sbi->ll_ops to the
correct struct file_operations. We can make all the struct
file_operations static.

WC-bug-id: https://jira.whamcloud.com/browse/LU-6142
Lustre-commit: cfa2c25f1b9b0344 ("LU-6142 llite: create file_operations registration function.")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/40608
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 fs/lustre/llite/file.c           | 18 +++++++++++++++---
 fs/lustre/llite/llite_internal.h |  4 +---
 fs/lustre/llite/llite_lib.c      |  7 +------
 3 files changed, 17 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index 0d866ec..767eafa 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -5116,7 +5116,7 @@  int ll_inode_permission(struct inode *inode, int mask)
 }
 
 /* -o localflock - only provides locally consistent flock locks */
-const struct file_operations ll_file_operations = {
+static const struct file_operations ll_file_operations = {
 	.read_iter		= ll_file_read_iter,
 	.write_iter		= ll_file_write_iter,
 	.unlocked_ioctl		= ll_file_ioctl,
@@ -5130,7 +5130,7 @@  int ll_inode_permission(struct inode *inode, int mask)
 	.fallocate		= ll_fallocate,
 };
 
-const struct file_operations ll_file_operations_flock = {
+static const struct file_operations ll_file_operations_flock = {
 	.read_iter		= ll_file_read_iter,
 	.write_iter		= ll_file_write_iter,
 	.unlocked_ioctl		= ll_file_ioctl,
@@ -5147,7 +5147,7 @@  int ll_inode_permission(struct inode *inode, int mask)
 };
 
 /* These are for -o noflock - to return ENOSYS on flock calls */
-const struct file_operations ll_file_operations_noflock = {
+static const struct file_operations ll_file_operations_noflock = {
 	.read_iter		= ll_file_read_iter,
 	.write_iter		= ll_file_write_iter,
 	.unlocked_ioctl		= ll_file_ioctl,
@@ -5172,6 +5172,18 @@  int ll_inode_permission(struct inode *inode, int mask)
 	.get_acl		= ll_get_acl,
 };
 
+const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi)
+{
+	const struct file_operations *fops = &ll_file_operations_noflock;
+
+	if (sbi->ll_flags & LL_SBI_FLOCK)
+		fops = &ll_file_operations_flock;
+	else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
+		fops = &ll_file_operations;
+
+	return fops;
+}
+
 int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf)
 {
 	struct ll_inode_info *lli = ll_i2info(inode);
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 041f6d3..0d97253 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -1049,10 +1049,8 @@  void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io,
 extern const struct address_space_operations ll_aops;
 
 /* llite/file.c */
-extern const struct file_operations ll_file_operations;
-extern const struct file_operations ll_file_operations_flock;
-extern const struct file_operations ll_file_operations_noflock;
 extern const struct inode_operations ll_file_inode_operations;
+const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi);
 int ll_have_md_lock(struct inode *inode, u64 *bits,
 		    enum ldlm_mode l_req_mode);
 enum ldlm_mode ll_take_md_lock(struct inode *inode, u64 bits,
diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index e7c1b73..e15962e 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -293,12 +293,7 @@  static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 	 */
 	sb->s_flags |= SB_NOSEC;
 
-	if (sbi->ll_flags & LL_SBI_FLOCK)
-		sbi->ll_fop = &ll_file_operations_flock;
-	else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
-		sbi->ll_fop = &ll_file_operations;
-	else
-		sbi->ll_fop = &ll_file_operations_noflock;
+	sbi->ll_fop = ll_select_file_operations(sbi);
 
 	/* always ping even if server suppress_pings */
 	if (sbi->ll_flags & LL_SBI_ALWAYS_PING)