From 978428ed047602a311f016fe7f4cf7d21f5599b6 Mon Sep 17 00:00:00 2001 From: Mikhal Pershin Date: Thu, 22 Dec 2016 14:15:11 +0300 Subject: [PATCH] LU-3285 lvbo: pass lock as parameter to lvbo_update() LVBO lvbo_update call was using ldlm_resource as parameter, the ldlm_lock parameter is added to recognize DoM resource in MDT LVBO functions and perform DoM specific actions. Signed-off-by: Mikhal Pershin Change-Id: Id1cfee12bfc13893206c771f45acf7dd44da56ba Reviewed-on: https://review.whamcloud.com/28016 Reviewed-by: Jinshan Xiong Reviewed-by: Lai Siyao Tested-by: Jenkins Tested-by: Maloo --- lustre/include/lustre_dlm.h | 29 +++++++++++++++++------------ lustre/ldlm/ldlm_lock.c | 2 +- lustre/ldlm/ldlm_lockd.c | 10 ++++++---- lustre/mdt/mdt_lvb.c | 1 + lustre/ofd/ofd_lvb.c | 6 +++--- 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 17b51ae..2d0952e 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -289,11 +289,10 @@ typedef int (*ldlm_cancel_cbt)(struct ldlm_lock *lock); * of ldlm_[res_]lvbo_[init,update,fill]() functions. */ struct ldlm_valblock_ops { - int (*lvbo_init)(struct ldlm_resource *res); - int (*lvbo_update)(struct ldlm_resource *res, - struct ptlrpc_request *r, - int increase); - int (*lvbo_free)(struct ldlm_resource *res); + int (*lvbo_init)(struct ldlm_resource *res); + int (*lvbo_update)(struct ldlm_resource *res, struct ldlm_lock *lock, + struct ptlrpc_request *r, int increase); + int (*lvbo_free)(struct ldlm_resource *res); /* Return size of lvb data appropriate RPC size can be reserved */ int (*lvbo_size)(struct ldlm_lock *lock); /* Called to fill in lvb data to RPC buffer @buf */ @@ -1360,9 +1359,11 @@ ldlm_handle2lock_long(const struct lustre_handle *h, __u64 flags) * Update Lock Value Block Operations (LVBO) on a resource taking into account * data from request \a r */ -static inline int ldlm_res_lvbo_update(struct ldlm_resource *res, - struct ptlrpc_request *req, int increase) +static inline int ldlm_lvbo_update(struct ldlm_resource *res, + struct ldlm_lock *lock, + struct ptlrpc_request *req, int increase) { + struct ldlm_namespace *ns = ldlm_res_to_ns(res); int rc; /* delayed lvb init may be required */ @@ -1372,14 +1373,18 @@ static inline int ldlm_res_lvbo_update(struct ldlm_resource *res, return rc; } - if (ldlm_res_to_ns(res)->ns_lvbo && - ldlm_res_to_ns(res)->ns_lvbo->lvbo_update) { - return ldlm_res_to_ns(res)->ns_lvbo->lvbo_update(res, req, - increase); - } + if (ns->ns_lvbo && ns->ns_lvbo->lvbo_update) + return ns->ns_lvbo->lvbo_update(res, lock, req, increase); + return 0; } +static inline int ldlm_res_lvbo_update(struct ldlm_resource *res, + struct ptlrpc_request *req, int increase) +{ + return ldlm_lvbo_update(res, NULL, req, increase); +} + int ldlm_error2errno(enum ldlm_error error); enum ldlm_error ldlm_errno2error(int err_no); /* don't call it `errno': this * confuses user-space. */ diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 8d427ec..141de60 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -2441,7 +2441,7 @@ static void ldlm_cancel_lock_for_export(struct obd_export *exp, res = ldlm_resource_getref(lock->l_resource); - ldlm_res_lvbo_update(res, NULL, 1); + ldlm_lvbo_update(res, lock, NULL, 1); ldlm_lock_cancel(lock); if (!exp->exp_obd->obd_stopping) ldlm_reprocess_all(res); diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 3e80cb2..04e3c8e 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -713,7 +713,7 @@ static int ldlm_handle_ast_error(struct ldlm_lock *lock, /* update lvbo to return proper attributes. * see bug 23174 */ ldlm_resource_getref(res); - ldlm_res_lvbo_update(res, NULL, 1); + ldlm_lvbo_update(res, lock, NULL, 1); ldlm_resource_putref(res); } ldlm_lock_cancel(lock); @@ -748,11 +748,11 @@ static int ldlm_cb_interpret(const struct lu_env *env, } else if (rc == -ELDLM_NO_LOCK_DATA) { LDLM_DEBUG(lock, "lost race - client has a lock but no " "inode"); - ldlm_res_lvbo_update(lock->l_resource, NULL, 1); + ldlm_lvbo_update(lock->l_resource, lock, NULL, 1); } else if (rc != 0) { rc = ldlm_handle_ast_error(lock, req, rc, "glimpse"); } else { - rc = ldlm_res_lvbo_update(lock->l_resource, req, 1); + rc = ldlm_lvbo_update(lock->l_resource, lock, req, 1); } break; case LDLM_BL_CALLBACK: @@ -1690,7 +1690,9 @@ int ldlm_request_cancel(struct ptlrpc_request *req, if (res != NULL) { ldlm_resource_getref(res); LDLM_RESOURCE_ADDREF(res); - ldlm_res_lvbo_update(res, NULL, 1); + + if (!ldlm_is_discard_data(lock)) + ldlm_lvbo_update(res, lock, NULL, 1); } pres = res; } diff --git a/lustre/mdt/mdt_lvb.c b/lustre/mdt/mdt_lvb.c index d4c5097..31c2438 100644 --- a/lustre/mdt/mdt_lvb.c +++ b/lustre/mdt/mdt_lvb.c @@ -51,6 +51,7 @@ static int mdt_lvbo_init(struct ldlm_resource *res) } static int mdt_lvbo_update(struct ldlm_resource *res, + struct ldlm_lock *lock, struct ptlrpc_request *req, int increase_only) { diff --git a/lustre/ofd/ofd_lvb.c b/lustre/ofd/ofd_lvb.c index b1d50eb..c4e43b4 100644 --- a/lustre/ofd/ofd_lvb.c +++ b/lustre/ofd/ofd_lvb.c @@ -77,7 +77,7 @@ static int ofd_lvbo_free(struct ldlm_resource *res) * * Called with res->lr_lvb_sem held. * - * \param[in] res LDLM resource + * \param[in] lock LDLM lock on resource * * \retval 0 on successful setup * \retval negative value on error @@ -172,14 +172,14 @@ out_env: * \a req != NULL : called by the DLM itself after a glimpse callback * \a req == NULL : called by the OFD after a disk write * - * \param[in] res LDLM resource + * \param[in] lock LDLM lock * \param[in] req PTLRPC request * \param[in] increase_only don't allow LVB values to decrease * * \retval 0 on successful setup * \retval negative value on error */ -static int ofd_lvbo_update(struct ldlm_resource *res, +static int ofd_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock, struct ptlrpc_request *req, int increase_only) { struct ofd_device *ofd; -- 1.8.3.1