Whamcloud - gitweb
LU-6142 llite: create file_operations registeration function. 08/40608/6
authorJames Simmons <jsimmons@infradead.org>
Thu, 4 Feb 2021 14:48:15 +0000 (09:48 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Mar 2021 18:33:26 +0000 (18:33 +0000)
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.

Change-Id: I0369a4f64de5233d5272bc403f222366f9559000
Test-Parameters: trivial
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/40608
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
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>
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c

index 7844800..5974934 100644 (file)
@@ -5236,7 +5236,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 = {
 #ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 # ifdef HAVE_SYNC_READ_WRITE
        .read           = new_sync_read,
@@ -5265,7 +5265,7 @@ const struct file_operations ll_file_operations = {
        .fallocate      = ll_fallocate,
 };
 
-const struct file_operations ll_file_operations_flock = {
+static const struct file_operations ll_file_operations_flock = {
 #ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 # ifdef HAVE_SYNC_READ_WRITE
        .read           = new_sync_read,
@@ -5297,7 +5297,7 @@ const struct file_operations ll_file_operations_flock = {
 };
 
 /* 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 = {
 #ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 # ifdef HAVE_SYNC_READ_WRITE
        .read           = new_sync_read,
@@ -5345,6 +5345,18 @@ const struct inode_operations ll_file_inode_operations = {
 #endif
 };
 
+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);
index 163f78b..4e52cbd 100644 (file)
@@ -1093,10 +1093,8 @@ struct ll_cl_context *ll_cl_find(struct file *file);
 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);
 extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
                           enum ldlm_mode l_req_mode);
 extern enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits,
index f7a7cb3..c6aff22 100644 (file)
@@ -361,13 +361,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
         */
        sb->s_flags |= SB_NOSEC;
 #endif
-
-       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)