From a1a6e9f43b60baf422dbe3faa65cecd71d4eba4d Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 13 Dec 2024 13:17:47 -0500 Subject: [PATCH] LU-18554 llite: improve *_env_thread_* names There are a number of {vvp, osc}_env_thread_{struct} helpers, all of which clear the struct (memset( 0 )) before returning the pointer. These names are confusing, improve them so I can stop making the mistake of assuming they just help get the struct from the env. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I0bdd8857d8ff076aac0872f8355317f800bfcaa5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57427 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Timothy Day Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/llite/file.c | 24 ++++++++++++------------ lustre/llite/glimpse.c | 4 ++-- lustre/llite/lcommon_cl.c | 2 +- lustre/llite/lcommon_misc.c | 4 ++-- lustre/llite/llite_lib.c | 4 ++-- lustre/llite/llite_mmap.c | 2 +- lustre/llite/rw.c | 6 +++--- lustre/llite/rw26.c | 2 +- lustre/llite/vvp_internal.h | 6 +++--- lustre/llite/vvp_io.c | 4 ++-- lustre/osc/osc_cache.c | 4 ++-- lustre/osc/osc_internal.h | 2 +- lustre/osc/osc_lock.c | 2 +- lustre/osc/osc_page.c | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index f1ccf66..82eb958 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -588,7 +588,7 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req) env = cl_env_get(&refcheck); if (IS_ERR(env)) RETURN_EXIT; - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = obj; rc = cl_io_init(env, io, CIT_MISC, obj); if (rc) @@ -1476,7 +1476,7 @@ static int ll_merge_attr_nolock(const struct lu_env *env, struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct cl_object *obj = lli->lli_clob; - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); s64 atime; s64 mtime; s64 ctime; @@ -1833,7 +1833,7 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, max_io_bytes = min_t(size_t, PTLRPC_MAX_BRW_PAGES * OBD_MAX_RIF_DEFAULT, sbi->ll_cache->ccc_lru_max >> 2) << PAGE_SHIFT; - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); if (iocb_ki_flags_check(flags, DIRECT)) { if (iocb_ki_flags_check(flags, APPEND)) dio_lock = true; @@ -1871,7 +1871,7 @@ restart: per_bytes = max_io_bytes; partial_io = true; } - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); ll_io_init(io, file, iot, args); io->ci_dio_aio = ci_dio_aio; io->ci_dio_lock = dio_lock; @@ -2143,7 +2143,7 @@ static int file_read_confine_iter(struct lu_env *env, struct kiocb *iocb, struct iov_iter *to) { struct cl_io *io; - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); struct file *file = iocb->ki_filp; struct inode *inode = file_inode(file); struct ll_inode_info *lli = ll_i2info(inode); @@ -2157,7 +2157,7 @@ static int file_read_confine_iter(struct lu_env *env, struct kiocb *iocb, if (!obj) RETURN(rc); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = obj; rc = cl_io_init(env, io, CIT_MISC, obj); if (rc < 0) @@ -3429,7 +3429,7 @@ ll_ioc_data_version(struct inode *inode, struct ioc_data_version *ioc) if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = obj; io->u.ci_data_version.dv_data_version = 0; io->u.ci_data_version.dv_layout_version = UINT_MAX; @@ -3877,7 +3877,7 @@ int ll_file_lock_ahead(struct file *file, struct llapi_lu_ladvise *ladvise) */ result = io->ci_result; } else if (result == 0) { - lock = vvp_env_lock(env); + lock = vvp_env_new_lock(env); descr = &lock->cll_descr; descr->cld_obj = io->ci_obj; @@ -4021,7 +4021,7 @@ static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; /* initialize parameters for ladvise */ @@ -5009,7 +5009,7 @@ static loff_t ll_lseek(struct file *file, loff_t offset, int whence) if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; ll_io_set_mirror(io, file); @@ -5153,7 +5153,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; cl_object_get(io->ci_obj); io->ci_ignore_layout = ignore_layout; @@ -6317,7 +6317,7 @@ static int cl_falloc(struct file *file, struct inode *inode, int mode, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; ll_io_set_mirror(io, file); diff --git a/lustre/llite/glimpse.c b/lustre/llite/glimpse.c index 275bf99..5c7bd73 100644 --- a/lustre/llite/glimpse.c +++ b/lustre/llite/glimpse.c @@ -80,7 +80,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, struct inode *inode, struct cl_object *clob, int agl) { const struct lu_fid *fid = lu_object_fid(&clob->co_lu); - struct cl_lock *lock = vvp_env_lock(env); + struct cl_lock *lock = vvp_env_new_lock(env); struct cl_lock_descr *descr = &lock->cll_descr; int result; @@ -160,7 +160,7 @@ int cl_io_get(struct inode *inode, struct lu_env **envout, if (S_ISREG(inode->i_mode)) { env = cl_env_get(refcheck); if (!IS_ERR(env)) { - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = clob; *envout = env; *ioout = io; diff --git a/lustre/llite/lcommon_cl.c b/lustre/llite/lcommon_cl.c index 046c068..1848abf 100644 --- a/lustre/llite/lcommon_cl.c +++ b/lustre/llite/lcommon_cl.c @@ -80,7 +80,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = obj; io->ci_verify_layout = 1; diff --git a/lustre/llite/lcommon_misc.c b/lustre/llite/lcommon_misc.c index c46e33a..24227c0 100644 --- a/lustre/llite/lcommon_misc.c +++ b/lustre/llite/lcommon_misc.c @@ -137,7 +137,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, if (IS_ERR(env)) return PTR_ERR(env); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = obj; rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); @@ -150,7 +150,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, return rc; } - lock = vvp_env_lock(env); + lock = vvp_env_new_lock(env); descr = &lock->cll_descr; descr->cld_obj = obj; descr->cld_start = 0; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 0def180..de47597 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2104,13 +2104,13 @@ static int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = clob; rc = cl_io_rw_init(env, io, CIT_WRITE, from, PAGE_SIZE); if (rc) GOTO(putenv, rc); - lock = vvp_env_lock(env); + lock = vvp_env_new_lock(env); descr = &lock->cll_descr; descr->cld_obj = io->ci_obj; descr->cld_start = from >> PAGE_SHIFT; diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index a4e2cf5..bd2b485 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -111,7 +111,7 @@ ll_fault_io_init(struct lu_env *env, struct vm_area_struct *vma, RETURN(ERR_PTR(-EOPNOTSUPP)); restart: - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = ll_i2info(inode)->lli_clob; LASSERT(io->ci_obj != NULL); diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 9eb2461..40a74a5 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -592,7 +592,7 @@ static int ll_readahead_file_kms(const struct lu_env *env, { struct cl_object *clob; struct inode *inode; - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); int ret; clob = io->ci_obj; @@ -647,7 +647,7 @@ static void ll_readahead_handle_work(struct work_struct *wq) if (IS_ERR(env)) GOTO(out_free_work, rc = PTR_ERR(env)); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); ll_io_init(io, file, CIT_READ, NULL); rc = ll_readahead_file_kms(env, io, &kms); @@ -1510,7 +1510,7 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) clob = ll_i2info(inode)->lli_clob; LASSERT(clob != NULL); - io = vvp_env_thread_io(env); + io = vvp_env_new_io(env); io->ci_obj = clob; io->ci_ignore_layout = 1; result = cl_io_init(env, io, CIT_MISC, clob); diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 1ce7e4e..d8ead87 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -734,7 +734,7 @@ ll_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, static int ll_prepare_partial_page(const struct lu_env *env, struct cl_io *io, struct cl_page *pg, struct file *file) { - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); struct cl_object *obj = io->ci_obj; loff_t offset = cl_page_index(pg) << PAGE_SHIFT; int result; diff --git a/lustre/llite/vvp_internal.h b/lustre/llite/vvp_internal.h index 3717e3a..eedd441 100644 --- a/lustre/llite/vvp_internal.h +++ b/lustre/llite/vvp_internal.h @@ -133,7 +133,7 @@ static inline struct vvp_thread_info *vvp_env_info(const struct lu_env *env) return vti; } -static inline struct cl_lock *vvp_env_lock(const struct lu_env *env) +static inline struct cl_lock *vvp_env_new_lock(const struct lu_env *env) { struct cl_lock *lock = &vvp_env_info(env)->vti_lock; @@ -142,7 +142,7 @@ static inline struct cl_lock *vvp_env_lock(const struct lu_env *env) return lock; } -static inline struct cl_attr *vvp_env_thread_attr(const struct lu_env *env) +static inline struct cl_attr *vvp_env_new_attr(const struct lu_env *env) { struct cl_attr *attr = &vvp_env_info(env)->vti_attr; @@ -151,7 +151,7 @@ static inline struct cl_attr *vvp_env_thread_attr(const struct lu_env *env) return attr; } -static inline struct cl_io *vvp_env_thread_io(const struct lu_env *env) +static inline struct cl_io *vvp_env_new_io(const struct lu_env *env) { struct cl_io *io = &vvp_env_info(env)->vti_io; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index a292c08..6220228 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -122,7 +122,7 @@ static int vvp_prep_size(const struct lu_env *env, struct cl_object *obj, struct cl_io *io, loff_t start, size_t bytes, int *exceed) { - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); struct inode *inode = vvp_object_inode(obj); loff_t pos = start + bytes - 1; loff_t kms; @@ -703,7 +703,7 @@ static int vvp_io_setattr_time(const struct lu_env *env, { struct cl_io *io = ios->cis_io; struct cl_object *obj = io->ci_obj; - struct cl_attr *attr = vvp_env_thread_attr(env); + struct cl_attr *attr = vvp_env_new_attr(env); int result; unsigned int valid = CAT_CTIME; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 83951f1..ea32832 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -966,7 +966,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, if (IS_ERR(env)) RETURN(PTR_ERR(env)); - io = osc_env_thread_io(env); + io = osc_env_new_io(env); io->ci_obj = cl_object_top(osc2cl(obj)); io->ci_ignore_layout = 1; fbatch = &osc_env_info(env)->oti_fbatch; @@ -3308,7 +3308,7 @@ int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc, pgoff_t start, pgoff_t end, bool discard) { struct osc_thread_info *info = osc_env_info(env); - struct cl_io *io = osc_env_thread_io(env); + struct cl_io *io = osc_env_new_io(env); osc_page_gang_cbt cb; int result; diff --git a/lustre/osc/osc_internal.h b/lustre/osc/osc_internal.h index a576bbd..30c60c9 100644 --- a/lustre/osc/osc_internal.h +++ b/lustre/osc/osc_internal.h @@ -83,7 +83,7 @@ int osc_tunables_init(struct obd_device *obd); extern struct lu_device_type osc_device_type; -static inline struct cl_io *osc_env_thread_io(const struct lu_env *env) +static inline struct cl_io *osc_env_new_io(const struct lu_env *env) { struct cl_io *io = &osc_env_info(env)->oti_io; diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index 5a0480e..6a8081e 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -646,7 +646,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, struct osc_object *oscobj, loff_t start, loff_t end) { - struct cl_io *io = osc_env_thread_io(env); + struct cl_io *io = osc_env_new_io(env); struct cl_object *obj = cl_object_top(&oscobj->oo_cl); pgoff_t page_index; int result; diff --git a/lustre/osc/osc_page.c b/lustre/osc/osc_page.c index 2ddac2b..e9b6240 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -686,7 +686,7 @@ static long osc_lru_list_shrink(const struct lu_env *env, RETURN(0); pvec = (struct cl_page **)osc_env_info(env)->oti_pvec; - io = osc_env_thread_io(env); + io = osc_env_new_io(env); spin_lock(&cli->cl_lru_list_lock); if (force && reason == SK_REASON_NORMAL_LRU) -- 1.8.3.1