summaryrefslogtreecommitdiff
path: root/drivers/staging/lustre/lustre/osc/osc_lock.c
diff options
context:
space:
mode:
authorBruce Korb <bruce_korb@xyratex.com>2013-07-23 00:06:37 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 12:48:24 -0700
commitf2145eae3d4d7c93fcbd7013bbf31db76bdd0ad4 (patch)
treeb51973b13683180830b7b2cd6bcdcdf80b66e6f5 /drivers/staging/lustre/lustre/osc/osc_lock.c
parentdf9fcbeb7730ec77a8f643ff1e00b99167cbeabe (diff)
staging/lustre/dlmlock: compress out unused space
* lustre/include/lustre_dlm.h: Remove all bit fields and the unused weighing callback procedure. respell LDLM_AST_DISCARD_DATA as LDLM_FL_AST_DISCARD_DATA to match other flags. * .gitignore: ignore emacs temporary files * autogen.sh: rebuild the lock bits, if autogen is available. * contrib/bit-masks/lustre_dlm_flags.def: define the ldlm_lock flags * contrib/bit-masks/lustre_dlm_flags.tpl: template for emitting text * contrib/bit-masks/Makefile: construct the .c and .h files The .c file is for constructing a crash extension and is not preserved. * contrib/bit-masks/.gitignore: ignore built products * lustre/contrib/wireshark/packet-lustre.c: use built files instead of local versions of the defines. In the rest of the modified sources, replace flag field references with bit mask references. * lustre/osc/osc_lock.c: removed osc_lock_weigh, too Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2771 Lustre-change: http://review.whamcloud.com/5312 Signed-off-by: Bruce Korb <bruce_korb@xyratex.com> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Reviewed-by: Keith Mannthey <Keith.Mannthey@intel.com> Reviewed-by: Keith Mannthey <keith.mannthey@intel.com> Reviewed-by: <bruce.korb@gmail.com> Signed-off-by: Peng Tao <tao.peng@emc.com> Signed-off-by: Andreas Dilger <andreas.dilger@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lustre/osc/osc_lock.c')
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_lock.c124
1 files changed, 44 insertions, 80 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c
index 640bc3d34709..98478d24f9be 100644
--- a/drivers/staging/lustre/lustre/osc/osc_lock.c
+++ b/drivers/staging/lustre/lustre/osc/osc_lock.c
@@ -89,35 +89,49 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle)
*/
static int osc_lock_invariant(struct osc_lock *ols)
{
- struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle);
- struct ldlm_lock *olock = ols->ols_lock;
- int handle_used = lustre_handle_is_used(&ols->ols_handle);
-
- return
- ergo(osc_lock_is_lockless(ols),
- ols->ols_locklessable && ols->ols_lock == NULL) ||
- (ergo(olock != NULL, handle_used) &&
- ergo(olock != NULL,
- olock->l_handle.h_cookie == ols->ols_handle.cookie) &&
- /*
- * Check that ->ols_handle and ->ols_lock are consistent, but
- * take into account that they are set at the different time.
- */
- ergo(handle_used,
- ergo(lock != NULL && olock != NULL, lock == olock) &&
- ergo(lock == NULL, olock == NULL)) &&
- ergo(ols->ols_state == OLS_CANCELLED,
- olock == NULL && !handle_used) &&
- /*
- * DLM lock is destroyed only after we have seen cancellation
- * ast.
- */
- ergo(olock != NULL && ols->ols_state < OLS_CANCELLED,
- !olock->l_destroyed) &&
- ergo(ols->ols_state == OLS_GRANTED,
- olock != NULL &&
- olock->l_req_mode == olock->l_granted_mode &&
- ols->ols_hold));
+ struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle);
+ struct ldlm_lock *olock = ols->ols_lock;
+ int handle_used = lustre_handle_is_used(&ols->ols_handle);
+
+ if (ergo(osc_lock_is_lockless(ols),
+ ols->ols_locklessable && ols->ols_lock == NULL))
+ return 1;
+
+ /*
+ * If all the following "ergo"s are true, return 1, otherwise 0
+ */
+ if (! ergo(olock != NULL, handle_used))
+ return 0;
+
+ if (! ergo(olock != NULL,
+ olock->l_handle.h_cookie == ols->ols_handle.cookie))
+ return 0;
+
+ if (! ergo(handle_used,
+ ergo(lock != NULL && olock != NULL, lock == olock) &&
+ ergo(lock == NULL, olock == NULL)))
+ return 0;
+ /*
+ * Check that ->ols_handle and ->ols_lock are consistent, but
+ * take into account that they are set at the different time.
+ */
+ if (! ergo(ols->ols_state == OLS_CANCELLED,
+ olock == NULL && !handle_used))
+ return 0;
+ /*
+ * DLM lock is destroyed only after we have seen cancellation
+ * ast.
+ */
+ if (! ergo(olock != NULL && ols->ols_state < OLS_CANCELLED,
+ ((olock->l_flags & LDLM_FL_DESTROYED) == 0)))
+ return 0;
+
+ if (! ergo(ols->ols_state == OLS_GRANTED,
+ olock != NULL &&
+ olock->l_req_mode == olock->l_granted_mode &&
+ ols->ols_hold))
+ return 0;
+ return 1;
}
/*****************************************************************************
@@ -261,7 +275,7 @@ static __u64 osc_enq2ldlm_flags(__u32 enqflags)
if (enqflags & CEF_ASYNC)
result |= LDLM_FL_HAS_INTENT;
if (enqflags & CEF_DISCARD_DATA)
- result |= LDLM_AST_DISCARD_DATA;
+ result |= LDLM_FL_AST_DISCARD_DATA;
return result;
}
@@ -896,55 +910,6 @@ static unsigned long osc_lock_weigh(const struct lu_env *env,
return cl_object_header(slice->cls_obj)->coh_pages;
}
-/**
- * Get the weight of dlm lock for early cancellation.
- *
- * XXX: it should return the pages covered by this \a dlmlock.
- */
-static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock)
-{
- struct cl_env_nest nest;
- struct lu_env *env;
- struct osc_lock *lock;
- struct cl_lock *cll;
- unsigned long weight;
- ENTRY;
-
- might_sleep();
- /*
- * osc_ldlm_weigh_ast has a complex context since it might be called
- * because of lock canceling, or from user's input. We have to make
- * a new environment for it. Probably it is implementation safe to use
- * the upper context because cl_lock_put don't modify environment
- * variables. But in case of ..
- */
- env = cl_env_nested_get(&nest);
- if (IS_ERR(env))
- /* Mostly because lack of memory, tend to eliminate this lock*/
- RETURN(0);
-
- LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT);
- lock = osc_ast_data_get(dlmlock);
- if (lock == NULL) {
- /* cl_lock was destroyed because of memory pressure.
- * It is much reasonable to assign this type of lock
- * a lower cost.
- */
- GOTO(out, weight = 0);
- }
-
- cll = lock->ols_cl.cls_lock;
- cl_lock_mutex_get(env, cll);
- weight = cl_lock_weigh(env, cll);
- cl_lock_mutex_put(env, cll);
- osc_ast_data_put(env, lock);
- EXIT;
-
-out:
- cl_env_nested_put(&nest, env);
- return weight;
-}
-
static void osc_lock_build_einfo(const struct lu_env *env,
const struct cl_lock *clock,
struct osc_lock *lock,
@@ -966,7 +931,6 @@ static void osc_lock_build_einfo(const struct lu_env *env,
einfo->ei_cb_bl = osc_ldlm_blocking_ast;
einfo->ei_cb_cp = osc_ldlm_completion_ast;
einfo->ei_cb_gl = osc_ldlm_glimpse_ast;
- einfo->ei_cb_wg = osc_ldlm_weigh_ast;
einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */
}