From: James Simmons Date: Thu, 4 Feb 2021 14:48:15 +0000 (-0500) Subject: LU-6142 llite: create file_operations registeration function. X-Git-Tag: 2.14.51~39 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=cfa2c25f1b9b03442cf354bccd062088983057b9 LU-6142 llite: create file_operations registeration function. 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 Reviewed-on: https://review.whamcloud.com/40608 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 7844800..5974934 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 163f78b..4e52cbd 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -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, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index f7a7cb3..c6aff22 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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)