Whamcloud - gitweb
LU-1565 disabling ELC through procfs
authorVitaly Fertman <vitaly_fertman@xyratex.com>
Tue, 26 Jun 2012 12:03:37 +0000 (16:03 +0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 28 Nov 2012 20:41:32 +0000 (15:41 -0500)
adding a possibility to disable ELC through procfs, for test purposes only.

Change-Id: I45153d67f325bd464943c8f618d5c86dd663166e
Reviewed-by: Andrew Perepechko <Andrew_Perepechko@xyratex.com>
Reviewed-by: Alexander Zarochentsev <Alexander_Zarochentsev@xyratex.com>
Signed-off-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Xyratex-bug-id: MRP-477
Reviewed-on: http://review.whamcloud.com/3188
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <tappro@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_request.c
lustre/ldlm/ldlm_resource.c
lustre/mdc/mdc_reint.c
lustre/osc/osc_request.c

index b845b4c..c692f3d 100644 (file)
@@ -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);
index 64dc539..81c2a15 100644 (file)
@@ -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);
index 91b1327..76bbac8 100644 (file)
@@ -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));
index 3d3c450..994aac6 100644 (file)
@@ -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);
index 2048278..4f896c3 100644 (file)
@@ -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)