From 76b7ce7c6faa1860fe489c7e5e2ee302d6af6bcc Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Fri, 16 Oct 2020 10:34:04 +1100 Subject: [PATCH] LU-6142 lustre: remove ll_file_*_flag wrappers. ll_file_{test,set,clear,test_and_set}_flag are simple wrappers around the various *_bit() functions. They don't aid readability and the convention in the kernel is to use the *_bit() functions directly. Signed-off-by: Mr NeilBrown Change-Id: I0d50f8936ad9f97882f4771dd3210cc05fe43989 Reviewed-on: https://review.whamcloud.com/40292 Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/crypto.c | 2 +- lustre/llite/file.c | 14 +++++++------- lustre/llite/llite_foreign.c | 8 ++++---- lustre/llite/llite_internal.h | 24 ------------------------ lustre/llite/llite_lib.c | 12 ++++++------ lustre/llite/llite_mmap.c | 2 +- lustre/llite/namei.c | 2 +- lustre/llite/pcc.c | 2 +- lustre/llite/statahead.c | 2 +- lustre/llite/vvp_io.c | 8 ++++---- lustre/llite/xattr.c | 2 +- lustre/llite/xattr_cache.c | 6 +++--- 12 files changed, 30 insertions(+), 54 deletions(-) diff --git a/lustre/llite/crypto.c b/lustre/llite/crypto.c index 7e743c8..3f69d39 100644 --- a/lustre/llite/crypto.c +++ b/lustre/llite/crypto.c @@ -105,7 +105,7 @@ static int ll_set_context(struct inode *inode, const void *ctx, size_t len, return -EPERM; dentry = (struct dentry *)fs_data; - ll_file_set_flag(ll_i2info(inode), LLIF_SET_ENC_CTX); + set_bit(LLIF_SET_ENC_CTX, &ll_i2info(inode)->lli_flags); rc = ll_vfs_setxattr(dentry, inode, LL_XATTR_NAME_ENCRYPTION_CONTEXT, ctx, len, XATTR_CREATE); if (rc) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 975112b..990b082 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -112,12 +112,12 @@ static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, op_data->op_xvalid |= OP_XVALID_CTIME_SET; op_data->op_attr_blocks = inode->i_blocks; op_data->op_attr_flags = ll_inode_to_ext_flags(inode->i_flags); - if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT)) + if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) op_data->op_attr_flags |= LUSTRE_PROJINHERIT_FL; op_data->op_open_handle = och->och_open_handle; if (och->och_flags & FMODE_WRITE && - ll_file_test_and_clear_flag(ll_i2info(inode), LLIF_DATA_MODIFIED)) + test_and_clear_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags)) /* For HSM: if inode data has been modified, pack it so that * MDT can set data dirty flag in the archive. */ op_data->op_bias |= MDS_DATA_MODIFIED; @@ -1365,7 +1365,7 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode) * POSIX. Solving this problem needs to send an RPC to MDT for each * read, this will hurt performance. */ - if (ll_file_test_and_clear_flag(lli, LLIF_UPDATE_ATIME) || + if (test_and_clear_bit(LLIF_UPDATE_ATIME, &lli->lli_flags) || inode->i_atime.tv_sec < lli->lli_atime) inode->i_atime.tv_sec = lli->lli_atime; @@ -1883,7 +1883,7 @@ static ssize_t ll_do_tiny_write(struct kiocb *iocb, struct iov_iter *iter) ll_heat_add(inode, CIT_WRITE, result); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_WRITE_BYTES, result); - ll_file_set_flag(ll_i2info(inode), LLIF_DATA_MODIFIED); + set_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags); } CDEBUG(D_VFSTRACE, "result: %zu, original count %zu\n", result, count); @@ -3229,7 +3229,7 @@ int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd, RETURN(-EFAULT); fsxattr.fsx_xflags = ll_inode_flags_to_xflags(inode->i_flags); - if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT)) + if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) fsxattr.fsx_xflags |= FS_XFLAG_PROJINHERIT; fsxattr.fsx_projid = ll_i2info(inode)->lli_projid; if (copy_to_user((struct fsxattr __user *)arg, @@ -3252,7 +3252,7 @@ int ll_ioctl_check_project(struct inode *inode, struct fsxattr *fa) if (ll_i2info(inode)->lli_projid != fa->fsx_projid) return -EINVAL; - if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT)) { + if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) { if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT)) return -EINVAL; } else { @@ -4930,7 +4930,7 @@ int ll_getattr_dentry(struct dentry *de, struct kstat *stat, u32 request_mask, * restore the MDT holds the layout lock so the glimpse will * block up to the end of restore (getattr will block) */ - if (!ll_file_test_flag(lli, LLIF_FILE_RESTORING)) { + if (!test_bit(LLIF_FILE_RESTORING, &lli->lli_flags)) { rc = ll_glimpse_size(inode); if (rc < 0) RETURN(rc); diff --git a/lustre/llite/llite_foreign.c b/lustre/llite/llite_foreign.c index d231284..9e2a7cb 100644 --- a/lustre/llite/llite_foreign.c +++ b/lustre/llite/llite_foreign.c @@ -157,14 +157,14 @@ static bool should_preserve_foreign_file(struct lov_foreign_md *lfm, if (unset) if (lfm->lfm_type == LU_FOREIGN_TYPE_SYMLINK) { - ll_file_set_flag(lli, LLIF_FOREIGN_REMOVABLE); + set_bit(LLIF_FOREIGN_REMOVABLE, &lli->lli_flags); return true; } else { return false; } else return lfm->lfm_type == LU_FOREIGN_TYPE_SYMLINK && - !ll_file_test_flag(lli, LLIF_FOREIGN_REMOVABLE); + !test_bit(LLIF_FOREIGN_REMOVABLE, &lli->lli_flags); } static bool should_preserve_foreign_dir(struct lmv_foreign_md *lfm, @@ -174,14 +174,14 @@ static bool should_preserve_foreign_dir(struct lmv_foreign_md *lfm, if (unset) if (lfm->lfm_type == LU_FOREIGN_TYPE_SYMLINK) { - ll_file_set_flag(lli, LLIF_FOREIGN_REMOVABLE); + set_bit(LLIF_FOREIGN_REMOVABLE, &lli->lli_flags); return true; } else { return false; } else return lfm->lfm_type == LU_FOREIGN_TYPE_SYMLINK && - !ll_file_test_flag(lli, LLIF_FOREIGN_REMOVABLE); + !test_bit(LLIF_FOREIGN_REMOVABLE, &lli->lli_flags); } /* XXX diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index d8a1d9b..f37e7ce 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -410,30 +410,6 @@ enum ll_file_flags { }; -static inline void ll_file_set_flag(struct ll_inode_info *lli, - enum ll_file_flags flag) -{ - set_bit(flag, &lli->lli_flags); -} - -static inline void ll_file_clear_flag(struct ll_inode_info *lli, - enum ll_file_flags flag) -{ - clear_bit(flag, &lli->lli_flags); -} - -static inline bool ll_file_test_flag(struct ll_inode_info *lli, - enum ll_file_flags flag) -{ - return test_bit(flag, &lli->lli_flags); -} - -static inline bool ll_file_test_and_clear_flag(struct ll_inode_info *lli, - enum ll_file_flags flag) -{ - return test_and_clear_bit(flag, &lli->lli_flags); -} - int ll_xattr_cache_destroy(struct inode *inode); int ll_xattr_cache_get(struct inode *inode, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 2783678..0fbf1b1 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2084,7 +2084,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, */ xvalid |= OP_XVALID_OWNEROVERRIDE; op_data->op_bias |= MDS_DATA_MODIFIED; - ll_file_clear_flag(lli, LLIF_DATA_MODIFIED); + clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags); } if (attr->ia_valid & ATTR_FILE) { @@ -2169,7 +2169,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, * LLIF_DATA_MODIFIED is not set(see vvp_io_setattr_fini()). * This way we can save an RPC for common open + trunc * operation. */ - if (ll_file_test_and_clear_flag(lli, LLIF_DATA_MODIFIED)) { + if (test_and_clear_bit(LLIF_DATA_MODIFIED, &lli->lli_flags)) { struct hsm_state_set hss = { .hss_valid = HSS_SETMASK, .hss_setmask = HS_DIRTY, @@ -2416,9 +2416,9 @@ void ll_update_inode_flags(struct inode *inode, unsigned int ext_flags) ext_flags |= ll_inode_to_ext_flags(inode->i_flags) & LUSTRE_ENCRYPT_FL; inode->i_flags = ll_ext_to_inode_flags(ext_flags); if (ext_flags & LUSTRE_PROJINHERIT_FL) - ll_file_set_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT); + set_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags); else - ll_file_clear_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT); + clear_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags); } int ll_update_inode(struct inode *inode, struct lustre_md *md) @@ -2534,9 +2534,9 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md) * glimpsing updated attrs */ if (body->mbo_t_state & MS_RESTORE) - ll_file_set_flag(lli, LLIF_FILE_RESTORING); + set_bit(LLIF_FILE_RESTORING, &lli->lli_flags); else - ll_file_clear_flag(lli, LLIF_FILE_RESTORING); + clear_bit(LLIF_FILE_RESTORING, &lli->lli_flags); } return 0; diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index caaa8f4..f43c277 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -207,7 +207,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, } if (result == 0) - ll_file_set_flag(lli, LLIF_DATA_MODIFIED); + set_bit(LLIF_DATA_MODIFIED, &lli->lli_flags); } EXIT; diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index b743aa8..59b6d8e 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -316,7 +316,7 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, __u64 to_cancel) lli = ll_i2info(inode); if (bits & MDS_INODELOCK_UPDATE) - ll_file_set_flag(lli, LLIF_UPDATE_ATIME); + set_bit(LLIF_UPDATE_ATIME, &lli->lli_flags); if ((bits & MDS_INODELOCK_UPDATE) && S_ISDIR(inode->i_mode)) { CDEBUG(D_INODE, "invalidating inode "DFID" lli = %p, " diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 3bfc05b..93fad9a 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -1760,7 +1760,7 @@ int pcc_inode_getattr(struct inode *inode, u32 request_mask, GOTO(out, rc); ll_inode_size_lock(inode); - if (ll_file_test_and_clear_flag(lli, LLIF_UPDATE_ATIME) || + if (test_and_clear_bit(LLIF_UPDATE_ATIME, &lli->lli_flags) || inode->i_atime.tv_sec < lli->lli_atime) inode->i_atime.tv_sec = lli->lli_atime; diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 43db649..40feefb 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -577,7 +577,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) * the MDT holds the layout lock so the glimpse will block up to the * end of restore (statahead/agl will block) */ - if (ll_file_test_flag(lli, LLIF_FILE_RESTORING)) { + if (test_bit(LLIF_FILE_RESTORING, &lli->lli_flags)) { lli->lli_agl_index = 0; iput(inode); RETURN_EXIT; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 468fb7a..f36d036 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -352,8 +352,8 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) /* today successful restore is the only possible * case */ /* restore was done, clear restoring state */ - ll_file_clear_flag(ll_i2info(vvp_object_inode(obj)), - LLIF_FILE_RESTORING); + clear_bit(LLIF_FILE_RESTORING, + &ll_i2info(vvp_object_inode(obj))->lli_flags); } GOTO(out, 0); } @@ -780,7 +780,7 @@ static void vvp_io_setattr_fini(const struct lu_env *env, if (restore_needed && !ios->cis_io->ci_restore_needed) { /* restore finished, set data modified flag for HSM */ - ll_file_set_flag(ll_i2info(inode), LLIF_DATA_MODIFIED); + set_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags); } } @@ -1304,7 +1304,7 @@ static int vvp_io_write_start(const struct lu_env *env, vio->vui_iocb->ki_pos = pos + io->ci_nob - nob; } if (result > 0 || result == -EIOCBQUEUED) { - ll_file_set_flag(ll_i2info(inode), LLIF_DATA_MODIFIED); + set_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags); if (result != -EIOCBQUEUED && result < cnt) io->ci_continue = 0; diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 8aeb09e..7392391 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -155,7 +155,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, */ if (handler->flags == XATTR_SECURITY_T && !strcmp(name, "c") && - !ll_file_test_and_clear_flag(ll_i2info(inode), LLIF_SET_ENC_CTX)) + !test_and_clear_bit(LLIF_SET_ENC_CTX, &ll_i2info(inode)->lli_flags)) RETURN(-EPERM); fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name); diff --git a/lustre/llite/xattr_cache.c b/lustre/llite/xattr_cache.c index 3489f0b..835c737 100644 --- a/lustre/llite/xattr_cache.c +++ b/lustre/llite/xattr_cache.c @@ -85,7 +85,7 @@ static void ll_xattr_cache_init(struct ll_inode_info *lli) LASSERT(lli != NULL); INIT_LIST_HEAD(&lli->lli_xattrs); - ll_file_set_flag(lli, LLIF_XATTR_CACHE); + set_bit(LLIF_XATTR_CACHE, &lli->lli_flags); } /** @@ -257,7 +257,7 @@ static int ll_xattr_cache_list(struct list_head *cache, */ static int ll_xattr_cache_valid(struct ll_inode_info *lli) { - return ll_file_test_flag(lli, LLIF_XATTR_CACHE); + return test_bit(LLIF_XATTR_CACHE, &lli->lli_flags); } /** @@ -277,7 +277,7 @@ static int ll_xattr_cache_destroy_locked(struct ll_inode_info *lli) while (ll_xattr_cache_del(&lli->lli_xattrs, NULL) == 0) /* empty loop */ ; - ll_file_clear_flag(lli, LLIF_XATTR_CACHE); + clear_bit(LLIF_XATTR_CACHE, &lli->lli_flags); RETURN(0); } -- 1.8.3.1