Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / lmv / lmv_obd.c
index 344af42..f9ae025 100644 (file)
@@ -1166,7 +1166,9 @@ hsm_req_err:
 static int lmv_placement_policy(struct obd_device *obd,
                                struct md_op_data *op_data, u32 *mds)
 {
-       struct lmv_obd          *lmv = &obd->u.lmv;
+       struct lmv_obd     *lmv = &obd->u.lmv;
+       struct lmv_user_md *lum;
+
        ENTRY;
 
        LASSERT(mds != NULL);
@@ -1176,31 +1178,22 @@ static int lmv_placement_policy(struct obd_device *obd,
                RETURN(0);
        }
 
-       if (op_data->op_default_stripe_offset != -1) {
+       lum = op_data->op_data;
+       /* Choose MDS by
+        * 1. See if the stripe offset is specified by lum.
+        * 2. Then check if there is default stripe offset.
+        * 3. Finally choose MDS by name hash if the parent
+        *    is striped directory. (see lmv_locate_mds()). */
+       if (op_data->op_cli_flags & CLI_SET_MEA && lum != NULL &&
+           le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) {
+               *mds = le32_to_cpu(lum->lum_stripe_offset);
+       } else if (op_data->op_default_stripe_offset != (__u32)-1) {
                *mds = op_data->op_default_stripe_offset;
-               RETURN(0);
-       }
-
-       /**
-        * If stripe_offset is provided during setdirstripe
-        * (setdirstripe -i xx), xx MDS will be choosen.
-        */
-       if (op_data->op_cli_flags & CLI_SET_MEA && op_data->op_data != NULL) {
-               struct lmv_user_md *lum;
-
-               lum = op_data->op_data;
-
-               if (le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) {
-                       *mds = le32_to_cpu(lum->lum_stripe_offset);
-               } else {
-                       /* -1 means default, which will be in the same MDT with
-                        * the stripe */
-                       *mds = op_data->op_mds;
-                       lum->lum_stripe_offset = cpu_to_le32(op_data->op_mds);
-               }
+               op_data->op_mds = *mds;
+               /* Correct the stripe offset in lum */
+               if (lum != NULL)
+                       lum->lum_stripe_offset = cpu_to_le32(*mds);
        } else {
-               /* Allocate new fid on target according to operation type and
-                * parent home mds. */
                *mds = op_data->op_mds;
        }