From f80de57540450eeac3a1c3a09efaac803c027f53 Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Tue, 26 Jun 2012 16:03:37 +0400 Subject: [PATCH] LU-1565 disabling ELC through procfs adding a possibility to disable ELC through procfs, for test purposes only. Change-Id: I45153d67f325bd464943c8f618d5c86dd663166e Reviewed-by: Andrew Perepechko Reviewed-by: Alexander Zarochentsev Signed-off-by: Vitaly Fertman Xyratex-bug-id: MRP-477 Reviewed-on: http://review.whamcloud.com/3188 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/include/lustre_dlm.h | 6 ++++++ lustre/ldlm/ldlm_request.c | 4 ++-- lustre/ldlm/ldlm_resource.c | 34 ++++++++++++++++++++++++++++++++++ lustre/mdc/mdc_reint.c | 10 ++++++++++ lustre/osc/osc_request.c | 9 +++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index b845b4c..c692f3d 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -572,6 +572,12 @@ static inline int ns_is_server(struct ldlm_namespace *ns) return ns->ns_client == LDLM_NAMESPACE_SERVER; } +static inline int ns_connect_cancelset(struct ldlm_namespace *ns) +{ + LASSERT(ns != NULL); + return !!(ns->ns_connect_flags & OBD_CONNECT_CANCELSET); +} + static inline int ns_connect_lru_resize(struct ldlm_namespace *ns) { LASSERT(ns != NULL); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 64dc539..81c2a15 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -718,7 +718,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, if (cancels == NULL) cancels = &head; - if (exp_connect_cancelset(exp)) { + if (ns_connect_cancelset(ns)) { /* Estimate the amount of available space in the request. */ req_capsule_filled_sizes(pill, RCL_CLIENT); avail = ldlm_capsule_handles_avail(pill, RCL_CLIENT, canceloff); @@ -748,7 +748,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, RETURN(rc); } - if (exp_connect_cancelset(exp)) { + if (ns_connect_cancelset(ns)) { if (canceloff) { dlm = req_capsule_client_get(pill, &RMF_DLM_REQ); LASSERT(dlm); diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 91b1327..76bbac8 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -270,6 +270,33 @@ static int lprocfs_wr_lru_size(struct file *file, const char *buffer, return count; } +static int lprocfs_rd_elc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + struct ldlm_namespace *ns = data; + unsigned int supp = ns_connect_cancelset(ns); + + return lprocfs_rd_uint(page, start, off, count, eof, &supp); +} + +static int lprocfs_wr_elc(struct file *file, const char *buffer, + unsigned long count, void *data) +{ + struct ldlm_namespace *ns = data; + unsigned int supp = -1; + int rc; + + rc = lprocfs_wr_uint(file, buffer, count, &supp); + if (rc < 0) + return rc; + + if (supp == 0) + ns->ns_connect_flags &= ~OBD_CONNECT_CANCELSET; + else if (ns->ns_orig_connect_flags & OBD_CONNECT_CANCELSET) + ns->ns_connect_flags |= OBD_CONNECT_CANCELSET; + return count; +} + void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) { struct proc_dir_entry *dir; @@ -338,6 +365,13 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) lock_vars[0].read_fptr = lprocfs_rd_uint; lock_vars[0].write_fptr = lprocfs_wr_uint; lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0); + + snprintf(lock_name, MAX_STRING_SIZE, "%s/early_lock_cancel", + ldlm_ns_name(ns)); + lock_vars[0].data = ns; + lock_vars[0].read_fptr = lprocfs_rd_elc; + lock_vars[0].write_fptr = lprocfs_wr_elc; + lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0); } else { snprintf(lock_name, MAX_STRING_SIZE, "%s/ctime_age_limit", ldlm_ns_name(ns)); diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c index 3d3c450..994aac6 100644 --- a/lustre/mdc/mdc_reint.c +++ b/lustre/mdc/mdc_reint.c @@ -74,12 +74,22 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, cfs_list_t *cancels, ldlm_mode_t mode, __u64 bits) { + struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; ldlm_policy_data_t policy = {{0}}; struct ldlm_res_id res_id; struct ldlm_resource *res; int count; ENTRY; + /* Return, i.e. cancel nothing, only if ELC is supported (flag in + * export) but disabled through procfs (flag in NS). + * + * This distinguishes from a case when ELC is not supported originally, + * when we still want to cancel locks in advance and just cancel them + * locally, without sending any RPC. */ + if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) + RETURN(0); + fid_build_reg_res_name(fid, &res_id); res = ldlm_resource_get(exp->exp_obd->obd_namespace, NULL, &res_id, 0, 0); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 2048278..4f896c3 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -662,6 +662,15 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, int count; ENTRY; + /* Return, i.e. cancel nothing, only if ELC is supported (flag in + * export) but disabled through procfs (flag in NS). + * + * This distinguishes from a case when ELC is not supported originally, + * when we still want to cancel locks in advance and just cancel them + * locally, without sending any RPC. */ + if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) + RETURN(0); + osc_build_res_name(oa->o_id, oa->o_seq, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if (res == NULL) -- 1.8.3.1