static mdl_mode_t cml_lock_mode(const struct lu_env *env,
struct md_object *mo, mdl_mode_t lm)
{
+#if defined(HAVE_SPLIT_SUPPORT) && defined(CONFIG_PDIROPS)
+ struct md_attr *ma = &cmm_env_info(env)->cmi_ma;
+ int rc, split;
ENTRY;
-#ifdef HAVE_SPLIT_SUPPORT
- {
- struct md_attr *ma = &cmm_env_info(env)->cmi_ma;
- int rc, split;
- memset(ma, 0, sizeof(*ma));
+ memset(ma, 0, sizeof(*ma));
- /*
- * Check only if we need protection from split. If not - mdt
- * handles other cases.
- */
- rc = cmm_expect_splitting(env, mo, ma, &split);
- if (rc) {
- CERROR("Can't check for possible split, error %d\n",
- rc);
- RETURN(MDL_MINMODE);
- }
-
- if (lm == MDL_PW && split == CMM_EXPECT_SPLIT)
- RETURN(MDL_EX);
+ /*
+ * Check only if we need protection from split. If not - mdt
+ * handles other cases.
+ */
+ rc = cmm_expect_splitting(env, mo, ma, &split);
+ if (rc) {
+ CERROR("Can't check for possible split, error %d\n",
+ rc);
+ RETURN(MDL_MINMODE);
}
-#endif
+
+ if (lm == MDL_PW && split == CMM_EXPECT_SPLIT)
+ RETURN(MDL_EX);
RETURN(MDL_MINMODE);
+#endif
+ return MDL_MINMODE;
}
static int cml_create(const struct lu_env *env,
{
lh->mlh_reg_mode = lm;
lh->mlh_type = MDT_PDO_LOCK;
- lh->mlh_pdo_hash = (name != NULL && namelen > 0 ?
- full_name_hash(name, namelen - 1) : 0);
+
+ if (name != NULL) {
+ LASSERT(namelen > 0);
+ lh->mlh_pdo_hash = full_name_hash(name, namelen - 1);
+ } else {
+ LASSERT(namelen == 0);
+ lh->mlh_pdo_hash = 0ull;
+ }
}
#ifdef CONFIG_PDIROPS