- struct mdt_lock_handle *lh)
-{
- mdl_mode_t mode;
- ENTRY;
-
- /*
- * Any dir access needs couple of locks:
- *
- * 1) on part of dir we gonna take lookup/modify;
- *
- * 2) on whole dir to protect it from concurrent splitting and/or to
- * flush client's cache for readdir().
- *
- * so, for a given mode and object this routine decides what lock mode
- * to use for lock #2:
- *
- * 1) if caller's gonna lookup in dir then we need to protect dir from
- * being splitted only - LCK_CR
- *
- * 2) if caller's gonna modify dir then we need to protect dir from
- * being splitted and to flush cache - LCK_CW
- *
- * 3) if caller's gonna modify dir and that dir seems ready for
- * splitting then we need to protect it from any type of access
- * (lookup/modify/split) - LCK_EX --bzzz
- */
-
- LASSERT(lh->mlh_reg_mode != LCK_MINMODE);
- LASSERT(lh->mlh_pdo_mode == LCK_MINMODE);
-
- /*
- * Ask underlaying level its opinion about preferable PDO lock mode
- * having access type passed as regular lock mode:
- *
- * - MDL_MINMODE means that lower layer does not want to specify lock
- * mode;
- *
- * - MDL_NL means that no PDO lock should be taken. This is used in some
- * cases. Say, for non-splittable directories no need to use PDO locks
- * at all.
- */
- mode = mdo_lock_mode(info->mti_env, mdt_object_child(o),
- mdt_dlm_mode2mdl_mode(lh->mlh_reg_mode));
-
- if (mode != MDL_MINMODE) {
- lh->mlh_pdo_mode = mdt_mdl_mode2dlm_mode(mode);
- } else {
- /*
- * Lower layer does not want to specify locking mode. We do it
- * our selves. No special protection is needed, just flush
- * client's cache on modification and allow concurrent
- * mondification.
- */
- switch (lh->mlh_reg_mode) {
- case LCK_EX:
- lh->mlh_pdo_mode = LCK_EX;
- break;
- case LCK_PR:
- lh->mlh_pdo_mode = LCK_CR;
- break;
- case LCK_PW:
- lh->mlh_pdo_mode = LCK_CW;
- break;
- default:
- CERROR("Not expected lock type (0x%x)\n",
- (int)lh->mlh_reg_mode);
- LBUG();
- }
- }
-
- LASSERT(lh->mlh_pdo_mode != LCK_MINMODE);
- EXIT;
+ struct mdt_lock_handle *lh)
+{
+ mdl_mode_t mode;
+
+ ENTRY;
+
+ /*
+ * Any dir access needs couple of locks:
+ *
+ * 1) on part of dir we gonna take lookup/modify;
+ *
+ * 2) on whole dir to protect it from concurrent splitting and/or to
+ * flush client's cache for readdir().
+ *
+ * so, for a given mode and object this routine decides what lock mode
+ * to use for lock #2:
+ *
+ * 1) if caller's gonna lookup in dir then we need to protect dir from
+ * being splitted only - LCK_CR
+ *
+ * 2) if caller's gonna modify dir then we need to protect dir from
+ * being splitted and to flush cache - LCK_CW
+ *
+ * 3) if caller's gonna modify dir and that dir seems ready for
+ * splitting then we need to protect it from any type of access
+ * (lookup/modify/split) - LCK_EX --bzzz
+ */
+
+ LASSERT(lh->mlh_reg_mode != LCK_MINMODE);
+ LASSERT(lh->mlh_pdo_mode == LCK_MINMODE);
+
+ /*
+ * Ask underlaying level its opinion about preferable PDO lock mode
+ * having access type passed as regular lock mode:
+ *
+ * - MDL_MINMODE means that lower layer does not want to specify lock
+ * mode;
+ *
+ * - MDL_NL means that no PDO lock should be taken. This is used in some
+ * cases. Say, for non-splittable directories no need to use PDO locks
+ * at all.
+ */
+ mode = mdo_lock_mode(info->mti_env, mdt_object_child(o),
+ mdt_dlm_mode2mdl_mode(lh->mlh_reg_mode));
+
+ if (mode != MDL_MINMODE) {
+ lh->mlh_pdo_mode = mdt_mdl_mode2dlm_mode(mode);
+ } else {
+ /*
+ * Lower layer does not want to specify locking mode. We do it
+ * our selves. No special protection is needed, just flush
+ * client's cache on modification and allow concurrent
+ * mondification.
+ */
+ switch (lh->mlh_reg_mode) {
+ case LCK_EX:
+ lh->mlh_pdo_mode = LCK_EX;
+ break;
+ case LCK_PR:
+ lh->mlh_pdo_mode = LCK_CR;
+ break;
+ case LCK_PW:
+ lh->mlh_pdo_mode = LCK_CW;
+ break;
+ default:
+ CERROR("Not expected lock type (0x%x)\n",
+ (int)lh->mlh_reg_mode);
+ LBUG();
+ }
+ }
+
+ LASSERT(lh->mlh_pdo_mode != LCK_MINMODE);
+ EXIT;
+}
+
+/**
+ * Check whether \a o is directory stripe object.
+ *
+ * \param[in] info thread environment
+ * \param[in] o MDT object
+ *
+ * \retval 1 is directory stripe.
+ * \retval 0 isn't directory stripe.
+ * \retval < 1 error code
+ */
+static int mdt_is_dir_stripe(struct mdt_thread_info *info,
+ struct mdt_object *o)
+{
+ struct md_attr *ma = &info->mti_attr;
+ struct lmv_mds_md_v1 *lmv;
+ int rc;
+
+ rc = mdt_stripe_get(info, o, ma, XATTR_NAME_LMV);
+ if (rc < 0)
+ return rc;
+
+ if (!(ma->ma_valid & MA_LMV))
+ return 0;
+
+ lmv = &ma->ma_lmv->lmv_md_v1;
+
+ if (!lmv_is_sane2(lmv))
+ return -EBADF;
+
+ if (le32_to_cpu(lmv->lmv_magic) == LMV_MAGIC_STRIPE)
+ return 1;
+
+ return 0;