From 2d686e9c9cc3c3c47cce92a0ff495b04efacd3a9 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 30 Oct 2014 15:00:22 +0800 Subject: [PATCH] LU-5823 clio: add cl_object_find_cbdata() * Delete obsolete obd_ops::o_find_cbdata interface. * Delete obsolete obd_ops::o_change_cbdata interface. * Add cl_object_find_cbdata(). Signed-off-by: Bobi Jam Change-Id: I2e64e2e9a112783cb5c66bf4580fd1aec794417b Reviewed-on: http://review.whamcloud.com/12494 Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 13 +++++- lustre/include/obd.h | 4 -- lustre/include/obd_class.h | 28 ------------ lustre/llite/dcache.c | 28 ++++++------ lustre/lov/lov_obd.c | 76 --------------------------------- lustre/lov/lov_object.c | 58 +++++++++++++++++++++++-- lustre/obdclass/cl_object.c | 24 +++++++++++ lustre/obdclass/lprocfs_status_server.c | 2 - lustre/osc/osc_object.c | 28 +++++++++++- lustre/osc/osc_request.c | 33 -------------- 10 files changed, 132 insertions(+), 162 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 7a8da87..028b4a2 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -103,6 +103,7 @@ #include #include #include +#include struct inode; @@ -402,6 +403,12 @@ struct cl_object_operations { */ int (*coo_getstripe)(const struct lu_env *env, struct cl_object *obj, struct lov_user_md __user *lum); + /** + * Find whether there is any callback data (ldlm lock) attached upon + * the object. + */ + int (*coo_find_cbdata)(const struct lu_env *env, struct cl_object *obj, + ldlm_iterator_t iter, void *data); }; /** @@ -2177,8 +2184,10 @@ int cl_conf_set (const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf); int cl_object_prune (const struct lu_env *env, struct cl_object *obj); void cl_object_kill (const struct lu_env *env, struct cl_object *obj); -int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, - struct lov_user_md __user *lum); +int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, + struct lov_user_md __user *lum); +int cl_object_find_cbdata(const struct lu_env *env, struct cl_object *obj, + ldlm_iterator_t iter, void *data); /** * Returns true, iff \a o0 and \a o1 are slices of the same object. diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 9ec325a..3b660e9 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -938,10 +938,6 @@ struct obd_ops { struct niobuf_remote *remote, int pages, struct niobuf_local *local, struct obd_trans_info *oti, int rc); - int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *, - ldlm_iterator_t it, void *data); - int (*o_find_cbdata)(struct obd_export *, struct lov_stripe_md *, - ldlm_iterator_t it, void *data); int (*o_init_export)(struct obd_export *exp); int (*o_destroy_export)(struct obd_export *exp); diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index dc9bb2d..cc4ab8d 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1269,34 +1269,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(rc); } -static inline int obd_change_cbdata(struct obd_export *exp, - struct lov_stripe_md *lsm, - ldlm_iterator_t it, void *data) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, change_cbdata); - EXP_COUNTER_INCREMENT(exp, change_cbdata); - - rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data); - RETURN(rc); -} - -static inline int obd_find_cbdata(struct obd_export *exp, - struct lov_stripe_md *lsm, - ldlm_iterator_t it, void *data) -{ - int rc; - ENTRY; - - EXP_CHECK_DT_OP(exp, find_cbdata); - EXP_COUNTER_INCREMENT(exp, find_cbdata); - - rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data); - RETURN(rc); -} - static inline void obd_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 1ad9659..074bc34 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -137,23 +137,27 @@ static inline int return_if_equal(struct ldlm_lock *lock, void *data) * < 0 error */ static int find_cbdata(struct inode *inode) { - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct lov_stripe_md *lsm; - int rc = 0; - ENTRY; + struct lu_env *env; + int refcheck; + struct ll_sb_info *sbi = ll_i2sbi(inode); + int rc = 0; + ENTRY; - LASSERT(inode); - rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), - return_if_equal, NULL); + LASSERT(inode); + rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), + return_if_equal, NULL); if (rc != 0) RETURN(rc); - lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) - RETURN(rc); + if (ll_i2info(inode)->lli_clob != NULL) { + env = cl_env_get(&refcheck); + if (IS_ERR(env)) + RETURN(PTR_ERR(env)); - rc = obd_find_cbdata(sbi->ll_dt_exp, lsm, return_if_equal, NULL); - ccc_inode_lsm_put(inode, lsm); + rc = cl_object_find_cbdata(env, ll_i2info(inode)->lli_clob, + return_if_equal, NULL); + cl_env_put(env, &refcheck); + } RETURN(rc); } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 1161be3..3f8bbb6 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1181,80 +1181,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, RETURN(0); } -static int lov_change_cbdata(struct obd_export *exp, - struct lov_stripe_md *lsm, ldlm_iterator_t it, - void *data) -{ - struct lov_obd *lov; - int rc = 0, i; - ENTRY; - - ASSERT_LSM_MAGIC(lsm); - - if (!exp || !exp->exp_obd) - RETURN(-ENODEV); - - lov = &exp->exp_obd->u.lov; - for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct lov_stripe_md submd; - struct lov_oinfo *loi = lsm->lsm_oinfo[i]; - - if (lov_oinfo_is_dummy(loi)) - continue; - - if (!lov->lov_tgts[loi->loi_ost_idx]) { - CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx); - continue; - } - - submd.lsm_oi = loi->loi_oi; - submd.lsm_stripe_count = 0; - rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, - &submd, it, data); - } - RETURN(rc); -} - -/* find any ldlm lock of the inode in lov - * return 0 not find - * 1 find one - * < 0 error */ -static int lov_find_cbdata(struct obd_export *exp, - struct lov_stripe_md *lsm, ldlm_iterator_t it, - void *data) -{ - struct lov_obd *lov; - int rc = 0, i; - ENTRY; - - ASSERT_LSM_MAGIC(lsm); - - if (!exp || !exp->exp_obd) - RETURN(-ENODEV); - - lov = &exp->exp_obd->u.lov; - for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct lov_stripe_md submd; - struct lov_oinfo *loi = lsm->lsm_oinfo[i]; - - if (lov_oinfo_is_dummy(loi)) - continue; - - if (!lov->lov_tgts[loi->loi_ost_idx]) { - CDEBUG(D_HA, "lov idx %d NULL\n", loi->loi_ost_idx); - continue; - } - - submd.lsm_oi = loi->loi_oi; - submd.lsm_stripe_count = 0; - rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, - &submd, it, data); - if (rc != 0) - RETURN(rc); - } - RETURN(rc); -} - int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; @@ -2147,8 +2073,6 @@ static struct obd_ops lov_obd_ops = { .o_unpackmd = lov_unpackmd, .o_getattr_async = lov_getattr_async, .o_setattr_async = lov_setattr_async, - .o_change_cbdata = lov_change_cbdata, - .o_find_cbdata = lov_find_cbdata, .o_iocontrol = lov_iocontrol, .o_get_info = lov_get_info, .o_set_info_async = lov_set_info_async, diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index aff9328..7d66e66 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -75,6 +75,8 @@ struct lov_layout_operations { struct cl_object *obj, struct cl_io *io); int (*llo_getattr)(const struct lu_env *env, struct cl_object *obj, struct cl_attr *attr); + int (*llo_find_cbdata)(const struct lu_env *env, struct cl_object *obj, + ldlm_iterator_t iter, void *data); }; static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov); @@ -575,6 +577,37 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, RETURN(result); } +static int lov_find_cbdata_empty(const struct lu_env *env, + struct cl_object *obj, ldlm_iterator_t iter, + void *data) +{ + return 0; +} + +static int lov_find_cbdata_raid0(const struct lu_env *env, + struct cl_object *obj, ldlm_iterator_t iter, + void *data) +{ + struct lov_object *lov = cl2lov(obj); + struct lov_layout_raid0 *r0 = lov_r0(lov); + struct cl_object *subobj; + int i; + int rc = 0; + + for (i = 0; i < r0->lo_nr; ++i) { + if (r0->lo_sub[i] == NULL) + continue; + + subobj = lovsub2cl(r0->lo_sub[i]); + + rc = cl_object_find_cbdata(env, subobj, iter, data); + if (rc != 0) + break; + } + + return rc; +} + const static struct lov_layout_operations lov_dispatch[] = { [LLT_EMPTY] = { .llo_init = lov_init_empty, @@ -585,7 +618,8 @@ const static struct lov_layout_operations lov_dispatch[] = { .llo_page_init = lov_page_init_empty, .llo_lock_init = lov_lock_init_empty, .llo_io_init = lov_io_init_empty, - .llo_getattr = lov_attr_get_empty + .llo_getattr = lov_attr_get_empty, + .llo_find_cbdata = lov_find_cbdata_empty }, [LLT_RAID0] = { .llo_init = lov_init_raid0, @@ -596,7 +630,8 @@ const static struct lov_layout_operations lov_dispatch[] = { .llo_page_init = lov_page_init_raid0, .llo_lock_init = lov_lock_init_raid0, .llo_io_init = lov_io_init_raid0, - .llo_getattr = lov_attr_get_raid0 + .llo_getattr = lov_attr_get_raid0, + .llo_find_cbdata = lov_find_cbdata_raid0 }, [LLT_RELEASED] = { .llo_init = lov_init_released, @@ -607,7 +642,8 @@ const static struct lov_layout_operations lov_dispatch[] = { .llo_page_init = lov_page_init_empty, .llo_lock_init = lov_lock_init_empty, .llo_io_init = lov_io_init_released, - .llo_getattr = lov_attr_get_empty + .llo_getattr = lov_attr_get_empty, + .llo_find_cbdata = lov_find_cbdata_empty } }; @@ -956,6 +992,19 @@ static int lov_object_getstripe(const struct lu_env *env, struct cl_object *obj, RETURN(rc); } +static int lov_object_find_cbdata(const struct lu_env *env, + struct cl_object *obj, ldlm_iterator_t iter, + void *data) +{ + int rc; + ENTRY; + + /* call cl_object_find_cbdata for sub obj */ + rc = LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_find_cbdata, + env, obj, iter, data); + RETURN(rc); +} + static const struct cl_object_operations lov_ops = { .coo_page_init = lov_page_init, .coo_lock_init = lov_lock_init, @@ -963,7 +1012,8 @@ static const struct cl_object_operations lov_ops = { .coo_attr_get = lov_attr_get, .coo_attr_update = lov_attr_update, .coo_conf_set = lov_conf_set, - .coo_getstripe = lov_object_getstripe + .coo_getstripe = lov_object_getstripe, + .coo_find_cbdata = lov_object_find_cbdata }; static const struct lu_object_operations lov_lu_obj_ops = { diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index e400f30..eb23c9b 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -363,6 +363,30 @@ int cl_object_getstripe(const struct lu_env *env, struct cl_object *obj, EXPORT_SYMBOL(cl_object_getstripe); /** + * Find whether there is any callback data (ldlm lock) attached upon this + * object. + */ +int cl_object_find_cbdata(const struct lu_env *env, struct cl_object *obj, + ldlm_iterator_t iter, void *data) +{ + struct lu_object_header *top; + int result = 0; + ENTRY; + + top = obj->co_lu.lo_header; + list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { + if (obj->co_ops->coo_find_cbdata != NULL) { + result = obj->co_ops->coo_find_cbdata(env, obj, iter, + data); + if (result != 0) + break; + } + } + RETURN(result); +} +EXPORT_SYMBOL(cl_object_find_cbdata); + +/** * Helper function removing all object locks, and marking object for * deletion. All object pages must have been deleted at this point. * diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index 00298d4..4939e1b 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -456,8 +456,6 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats) LPROCFS_OBD_OP_INIT(num_private_stats, stats, getattr_async); LPROCFS_OBD_OP_INIT(num_private_stats, stats, preprw); LPROCFS_OBD_OP_INIT(num_private_stats, stats, commitrw); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, change_cbdata); - LPROCFS_OBD_OP_INIT(num_private_stats, stats, find_cbdata); LPROCFS_OBD_OP_INIT(num_private_stats, stats, init_export); LPROCFS_OBD_OP_INIT(num_private_stats, stats, destroy_export); LPROCFS_OBD_OP_INIT(num_private_stats, stats, import_event); diff --git a/lustre/osc/osc_object.c b/lustre/osc/osc_object.c index 728b758..c03582a 100644 --- a/lustre/osc/osc_object.c +++ b/lustre/osc/osc_object.c @@ -230,6 +230,31 @@ static int osc_object_prune(const struct lu_env *env, struct cl_object *obj) osc_object_ast_clear, osc); return 0; } +/** + * Find any ldlm lock covers the osc object. + * \retval 0 not found + * \retval 1 find one + * \retval < 0 error + */ +static int osc_object_find_cbdata(const struct lu_env *env, + struct cl_object *obj, ldlm_iterator_t iter, + void *data) +{ + struct ldlm_res_id res_id; + struct obd_device *obd; + int rc = 0; + + ostid_build_res_name(&cl2osc(obj)->oo_oinfo->loi_oi, &res_id); + obd = obj->co_lu.lo_dev->ld_obd; + rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, iter, data); + if (rc == LDLM_ITER_STOP) + return 1; + + if (rc == LDLM_ITER_CONTINUE) + return 0; + + return rc; +} void osc_object_set_contended(struct osc_object *obj) { @@ -276,7 +301,8 @@ static const struct cl_object_operations osc_ops = { .coo_attr_get = osc_attr_get, .coo_attr_update = osc_attr_update, .coo_glimpse = osc_object_glimpse, - .coo_prune = osc_object_prune + .coo_prune = osc_object_prune, + .coo_find_cbdata = osc_object_find_cbdata }; static const struct lu_object_operations osc_lu_obj_ops = { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index a0d19d5..75d1290 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2026,37 +2026,6 @@ static int osc_set_data_with_check(struct lustre_handle *lockh, return set; } -static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, - ldlm_iterator_t replace, void *data) -{ - struct ldlm_res_id res_id; - struct obd_device *obd = class_exp2obd(exp); - - ostid_build_res_name(&lsm->lsm_oi, &res_id); - ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data); - return 0; -} - -/* find any ldlm lock of the inode in osc - * return 0 not find - * 1 find one - * < 0 error */ -static int osc_find_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm, - ldlm_iterator_t replace, void *data) -{ - struct ldlm_res_id res_id; - struct obd_device *obd = class_exp2obd(exp); - int rc = 0; - - ostid_build_res_name(&lsm->lsm_oi, &res_id); - rc = ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data); - if (rc == LDLM_ITER_STOP) - return(1); - if (rc == LDLM_ITER_CONTINUE) - return(0); - return(rc); -} - static int osc_enqueue_fini(struct ptlrpc_request *req, osc_enqueue_upcall_f upcall, void *cookie, struct lustre_handle *lockh, ldlm_mode_t mode, @@ -3105,8 +3074,6 @@ static struct obd_ops osc_obd_ops = { .o_getattr_async = osc_getattr_async, .o_setattr = osc_setattr, .o_setattr_async = osc_setattr_async, - .o_change_cbdata = osc_change_cbdata, - .o_find_cbdata = osc_find_cbdata, .o_iocontrol = osc_iocontrol, .o_get_info = osc_get_info, .o_set_info_async = osc_set_info_async, -- 1.8.3.1