Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / lmv / lmv_obd.c
index 6cd9423..f9ae025 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2015, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -103,7 +99,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv,
                if (tgt == NULL || tgt->ltd_exp == NULL)
                        continue;
 
-               CDEBUG(D_INFO, "Target idx %d is %s conn "LPX64"\n", i,
+               CDEBUG(D_INFO, "Target idx %d is %s conn %#llx\n", i,
                       tgt->ltd_uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
 
                if (obd_uuid_equals(uuid, &tgt->ltd_uuid))
@@ -704,7 +700,7 @@ repeat_fid2path:
                *ptr = '/';
        }
 
-       CDEBUG(D_INFO, "%s: get path %s "DFID" rec: "LPU64" ln: %u\n",
+       CDEBUG(D_INFO, "%s: get path %s "DFID" rec: %llu ln: %u\n",
               tgt->ltd_exp->exp_obd->obd_name,
               gf->gf_u.gf_path, PFID(&gf->gf_fid), gf->gf_recno,
               gf->gf_linkno);
@@ -1170,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);
@@ -1180,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;
        }
 
@@ -1707,8 +1696,7 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
 
 static int
 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
-           const union ldlm_policy_data *policy,
-           struct lookup_intent *it, struct md_op_data *op_data,
+           const union ldlm_policy_data *policy, struct md_op_data *op_data,
            struct lustre_handle *lockh, __u64 extra_lock_flags)
 {
        struct obd_device        *obd = exp->exp_obd;
@@ -1717,17 +1705,16 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
        int                       rc;
        ENTRY;
 
-       CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
-              LL_IT2STR(it), PFID(&op_data->op_fid1));
+       CDEBUG(D_INODE, "ENQUEUE on "DFID"\n", PFID(&op_data->op_fid1));
 
        tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(tgt))
                RETURN(PTR_ERR(tgt));
 
-       CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%u\n",
-              LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
+       CDEBUG(D_INODE, "ENQUEUE on "DFID" -> mds #%u\n",
+              PFID(&op_data->op_fid1), tgt->ltd_idx);
 
-       rc = md_enqueue(tgt->ltd_exp, einfo, policy, it, op_data, lockh,
+       rc = md_enqueue(tgt->ltd_exp, einfo, policy, op_data, lockh,
                        extra_lock_flags);
 
        RETURN(rc);
@@ -2185,7 +2172,7 @@ next:
                        stripe_hash = le64_to_cpu(dp->ldp_hash_end);
 
                        kunmap(page);
-                       page_cache_release(page);
+                       put_page(page);
                        page = NULL;
 
                        /* reach the end of current stripe, go to next stripe */
@@ -2200,12 +2187,12 @@ next:
                            le64_to_cpu(ent->lde_hash)) {
                                min_ent = ent;
                                kunmap(min_page);
-                               page_cache_release(min_page);
+                               put_page(min_page);
                                min_idx = i;
                                min_page = page;
                        } else {
                                kunmap(page);
-                               page_cache_release(page);
+                               put_page(page);
                                page = NULL;
                        }
                } else {
@@ -2218,7 +2205,7 @@ next:
 out:
        if (*ppage != NULL) {
                kunmap(*ppage);
-               page_cache_release(*ppage);
+               put_page(*ppage);
        }
        *stripe_offset = min_idx;
        *entp = min_ent;
@@ -2283,7 +2270,7 @@ static int lmv_read_striped_page(struct obd_export *exp,
        dp->ldp_flags |= LDF_COLLIDE;
 
        area = dp + 1;
-       left_bytes = PAGE_CACHE_SIZE - sizeof(*dp);
+       left_bytes = PAGE_SIZE - sizeof(*dp);
        ent = area;
        last_ent = ent;
        do {
@@ -2344,7 +2331,7 @@ static int lmv_read_striped_page(struct obd_export *exp,
 out:
        if (min_ent_page != NULL) {
                kunmap(min_ent_page);
-               page_cache_release(min_ent_page);
+               put_page(min_ent_page);
        }
 
        if (unlikely(rc != 0)) {
@@ -2607,7 +2594,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
 
         obd = class_exp2obd(exp);
         if (obd == NULL) {
-                CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
+               CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n",
                        exp->exp_handle.h_cookie);
                 RETURN(-EINVAL);
         }
@@ -2679,7 +2666,7 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
 
        obd = class_exp2obd(exp);
        if (obd == NULL) {
-               CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
+               CDEBUG(D_IOCTL, "Invalid client cookie %#llx\n",
                       exp->exp_handle.h_cookie);
                RETURN(-EINVAL);
        }