From d8638fd870ecbedf4d104e7c3e0bf26124bec326 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Fri, 15 Sep 2017 19:53:50 +0000 Subject: [PATCH] LU-9771 clio: introduce CIT_GLIMPSE for glimpse It turned out that it's better to have a standaline I/O context for glimpse request. In that case, it's easier for glimpse to try a new mirror if the current one is out of access. Another problem in this patch is to zero cl_io data structure if the I/O starts from OSC layer. Signed-off-by: Jinshan Xiong Change-Id: Ieeac36d4af38bc04a01affb9e6d3d129bceeb74e Reviewed-on: https://review.whamcloud.com/29082 Reviewed-by: Bobi Jam Reviewed-by: Fan Yong Tested-by: Jenkins Tested-by: Maloo --- lustre/include/cl_object.h | 6 ++++-- lustre/llite/glimpse.c | 24 +++++++++++++----------- lustre/llite/vvp_io.c | 4 ++++ lustre/lov/lov_io.c | 11 +++++++++++ lustre/obdclass/cl_io.c | 1 + lustre/osc/osc_cache.c | 4 ++-- lustre/osc/osc_internal.h | 8 ++++++++ lustre/osc/osc_lock.c | 2 +- lustre/osc/osc_page.c | 2 +- 9 files changed, 45 insertions(+), 17 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 185ff8d..33281fc 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -1381,6 +1381,10 @@ enum cl_io_type { */ CIT_FSYNC, /** + * glimpse. An io context to acquire glimpse lock. + */ + CIT_GLIMPSE, + /** * Miscellaneous io. This is used for occasional io activity that * doesn't fit into other types. Currently this is used for: * @@ -1391,8 +1395,6 @@ enum cl_io_type { * - VM induced page write-out. An io context for writing page out * for memory cleansing; * - * - glimpse. An io context to acquire glimpse lock. - * * - grouplock. An io context to acquire group lock. * * CIT_MISC io is used simply as a context in which locks and pages diff --git a/lustre/llite/glimpse.c b/lustre/llite/glimpse.c index 76bf3ee..7c9ec0d 100644 --- a/lustre/llite/glimpse.c +++ b/lustre/llite/glimpse.c @@ -186,16 +186,19 @@ int cl_glimpse_size0(struct inode *inode, int agl) */ struct lu_env *env = NULL; struct cl_io *io = NULL; - __u16 refcheck; + __u16 refcheck; int result; ENTRY; - result = cl_io_get(inode, &env, &io, &refcheck); - if (result > 0) { - again: + result = cl_io_get(inode, &env, &io, &refcheck); + if (result <= 0) + RETURN(result); + + do { + io->ci_need_restart = 0; io->ci_verify_layout = 1; - result = cl_io_init(env, io, CIT_MISC, io->ci_obj); + result = cl_io_init(env, io, CIT_GLIMPSE, io->ci_obj); if (result > 0) /* * nothing to do for this io. This currently happens @@ -204,13 +207,12 @@ int cl_glimpse_size0(struct inode *inode, int agl) result = io->ci_result; else if (result == 0) result = cl_glimpse_lock(env, io, inode, io->ci_obj, - agl); + agl); OBD_FAIL_TIMEOUT(OBD_FAIL_GLIMPSE_DELAY, 2); - cl_io_fini(env, io); - if (unlikely(io->ci_need_restart)) - goto again; - cl_env_put(env, &refcheck); - } + cl_io_fini(env, io); + } while (unlikely(io->ci_need_restart)); + + cl_env_put(env, &refcheck); RETURN(result); } diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index c0dad2d..886b816 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -1408,6 +1408,9 @@ static const struct cl_io_operations vvp_io_ops = { .cio_start = vvp_io_fsync_start, .cio_fini = vvp_io_fini }, + [CIT_GLIMPSE] = { + .cio_fini = vvp_io_fini + }, [CIT_MISC] = { .cio_fini = vvp_io_fini }, @@ -1476,5 +1479,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, PFID(lu_object_fid(&obj->co_lu)), result); } + io->ci_result = result < 0 ? result : 0; RETURN(result); } diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index acddf1d..8cdfbf4 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -262,6 +262,7 @@ static int lov_io_slice_init(struct lov_io *lio, break; } + case CIT_GLIMPSE: case CIT_MISC: lio->lis_pos = 0; lio->lis_endpos = OBD_OBJECT_EOF; @@ -377,6 +378,8 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio, io->u.ci_ladvise.li_flags = parent->u.ci_ladvise.li_flags; break; } + case CIT_GLIMPSE: + case CIT_MISC: default: break; } @@ -1023,6 +1026,9 @@ static const struct cl_io_operations lov_io_ops = { .cio_start = lov_io_start, .cio_end = lov_io_end }, + [CIT_GLIMPSE] = { + .cio_fini = lov_io_fini, + }, [CIT_MISC] = { .cio_fini = lov_io_fini } @@ -1105,6 +1111,9 @@ static const struct cl_io_operations lov_empty_io_ops = { [CIT_LADVISE] = { .cio_fini = lov_empty_io_fini }, + [CIT_GLIMPSE] = { + .cio_fini = lov_empty_io_fini + }, [CIT_MISC] = { .cio_fini = lov_empty_io_fini } @@ -1148,6 +1157,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, default: LBUG(); case CIT_MISC: + case CIT_GLIMPSE: case CIT_READ: result = 0; break; @@ -1192,6 +1202,7 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, result = -EOPNOTSUPP; break; case CIT_MISC: + case CIT_GLIMPSE: case CIT_FSYNC: case CIT_LADVISE: case CIT_DATA_VERSION: diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index fc22b2c..54db7ac 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -122,6 +122,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) /* Check ignore layout change conf */ LASSERT(ergo(io->ci_ignore_layout || !io->ci_verify_layout, !io->ci_need_restart)); + case CIT_GLIMPSE: break; case CIT_LADVISE: break; diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index f35d7bf..d5b19e2 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -997,7 +997,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_info(env)->oti_io; + io = osc_env_thread_io(env); io->ci_obj = cl_object_top(osc2cl(obj)); io->ci_ignore_layout = 1; rc = cl_io_init(env, io, CIT_MISC, io->ci_obj); @@ -3289,7 +3289,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 = &info->oti_io; + struct cl_io *io = osc_env_thread_io(env); osc_page_gang_cbt cb; int res; int result; diff --git a/lustre/osc/osc_internal.h b/lustre/osc/osc_internal.h index 16b8666..20aadc8 100644 --- a/lustre/osc/osc_internal.h +++ b/lustre/osc/osc_internal.h @@ -98,6 +98,14 @@ static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;} extern struct lu_device_type osc_device_type; +static inline struct cl_io *osc_env_thread_io(const struct lu_env *env) +{ + struct cl_io *io = &osc_env_info(env)->oti_io; + + memset(io, 0, sizeof(*io)); + return io; +} + static inline int osc_is_object(const struct lu_object *obj) { return obj->lo_dev->ld_type == &osc_device_type; diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index e9d5ae1..ae62a40 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -623,7 +623,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, struct osc_object *oscobj, struct ldlm_extent *extent) { - struct cl_io *io = &osc_env_info(env)->oti_io; + struct cl_io *io = osc_env_thread_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 a141681..81d0c52 100644 --- a/lustre/osc/osc_page.c +++ b/lustre/osc/osc_page.c @@ -583,7 +583,7 @@ long osc_lru_shrink(const struct lu_env *env, struct client_obd *cli, } pvec = (struct cl_page **)osc_env_info(env)->oti_pvec; - io = &osc_env_info(env)->oti_io; + io = osc_env_thread_io(env); spin_lock(&cli->cl_lru_list_lock); if (force) -- 1.8.3.1