Whamcloud - gitweb
LU-6014 mdt: remove unused function
[fs/lustre-release.git] / lustre / lov / lov_ea.c
index 6ab28e9..2e2357c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_LOV
 
-#ifdef __KERNEL__
-#include <asm/div64.h>
+#include <linux/math64.h>
 #include <libcfs/libcfs.h>
-#else
-#include <liblustre.h>
-#endif
 
 #include <obd_class.h>
-#include <obd_lov.h>
 #include <lustre/lustre_idl.h>
 
 #include "lov_internal.h"
 
-struct lovea_unpack_args {
-        struct lov_stripe_md *lsm;
-        int                   cursor;
-};
-
 static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
                                  __u16 stripe_count)
 {
@@ -91,33 +81,33 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
 
 struct lov_stripe_md *lsm_alloc_plain(__u16 stripe_count, int *size)
 {
-        struct lov_stripe_md *lsm;
-        struct lov_oinfo     *loi;
-        int                   i, oinfo_ptrs_size;
+       struct lov_stripe_md *lsm;
+       struct lov_oinfo     *loi;
+       int                   i, oinfo_ptrs_size;
 
-        LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT);
+       LASSERT(stripe_count <= LOV_MAX_STRIPE_COUNT);
 
-        oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count;
-        *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size;
+       oinfo_ptrs_size = sizeof(struct lov_oinfo *) * stripe_count;
+       *size = sizeof(struct lov_stripe_md) + oinfo_ptrs_size;
 
-        OBD_ALLOC_LARGE(lsm, *size);
-        if (!lsm)
-                return NULL;;
+       OBD_ALLOC_LARGE(lsm, *size);
+       if (!lsm)
+               return NULL;
 
-        for (i = 0; i < stripe_count; i++) {
-               OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, __GFP_IO);
-                if (loi == NULL)
-                        goto err;
-                lsm->lsm_oinfo[i] = loi;
-        }
-        lsm->lsm_stripe_count = stripe_count;
-        return lsm;
+       for (i = 0; i < stripe_count; i++) {
+               OBD_SLAB_ALLOC_PTR_GFP(loi, lov_oinfo_slab, GFP_NOFS);
+               if (loi == NULL)
+                       goto err;
+               lsm->lsm_oinfo[i] = loi;
+       }
+       lsm->lsm_stripe_count = stripe_count;
+       return lsm;
 
 err:
-        while (--i >= 0)
-                OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi));
-        OBD_FREE_LARGE(lsm, *size);
-        return NULL;
+       while (--i >= 0)
+               OBD_SLAB_FREE(lsm->lsm_oinfo[i], lov_oinfo_slab, sizeof(*loi));
+       OBD_FREE_LARGE(lsm, *size);
+       return NULL;
 }
 
 void lsm_free_plain(struct lov_stripe_md *lsm)
@@ -148,34 +138,28 @@ static void lsm_unpackmd_common(struct lov_stripe_md *lsm,
 
 static void
 lsm_stripe_by_index_plain(struct lov_stripe_md *lsm, int *stripeno,
-                           obd_off *lov_off, obd_off *swidth)
+                         loff_t *lov_off, loff_t *swidth)
 {
-        if (swidth)
-                *swidth = (obd_off)lsm->lsm_stripe_size * lsm->lsm_stripe_count;
+       if (swidth != NULL)
+               *swidth = (loff_t)lsm->lsm_stripe_size * lsm->lsm_stripe_count;
 }
 
 static void
 lsm_stripe_by_offset_plain(struct lov_stripe_md *lsm, int *stripeno,
-                           obd_off *lov_off, obd_off *swidth)
-{
-        if (swidth)
-                *swidth = (obd_off)lsm->lsm_stripe_size * lsm->lsm_stripe_count;
-}
-
-static int lsm_destroy_plain(struct lov_stripe_md *lsm, struct obdo *oa,
-                             struct obd_export *md_exp)
+                          loff_t *lov_off, loff_t *swidth)
 {
-        return 0;
+       if (swidth != NULL)
+               *swidth = (loff_t)lsm->lsm_stripe_size * lsm->lsm_stripe_count;
 }
 
 /* Find minimum stripe maxbytes value.  For inactive or
- * reconnecting targets use LUSTRE_STRIPE_MAXBYTES. */
+ * reconnecting targets use LUSTRE_EXT3_STRIPE_MAXBYTES. */
 static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes)
 {
         struct obd_import *imp = tgt->ltd_obd->u.cli.cl_import;
 
         if (imp == NULL || !tgt->ltd_active) {
-                *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
+               *stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES;
                 return;
         }
 
@@ -186,7 +170,7 @@ static void lov_tgt_maxbytes(struct lov_tgt_desc *tgt, __u64 *stripe_maxbytes)
                if (*stripe_maxbytes > imp->imp_connect_data.ocd_maxbytes)
                        *stripe_maxbytes = imp->imp_connect_data.ocd_maxbytes;
        } else {
-               *stripe_maxbytes = LUSTRE_STRIPE_MAXBYTES;
+               *stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES;
        }
        spin_unlock(&imp->imp_lock);
 }
@@ -214,8 +198,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
        return lsm_lmm_verify_common(lmm, lmm_bytes, *stripe_count);
 }
 
-int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
-                    struct lov_mds_md_v1 *lmm)
+static int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
+                          struct lov_mds_md_v1 *lmm)
 {
         struct lov_oinfo *loi;
         int i;
@@ -232,6 +216,9 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
                loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
                loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
                         CERROR("OST index %d more than OST count %d\n",
                                loi->loi_ost_idx, lov->desc.ld_tgt_count);
@@ -257,7 +244,6 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
 
 const struct lsm_operations lsm_v1_ops = {
         .lsm_free            = lsm_free_plain,
-        .lsm_destroy         = lsm_destroy_plain,
         .lsm_stripe_by_index    = lsm_stripe_by_index_plain,
         .lsm_stripe_by_offset   = lsm_stripe_by_offset_plain,
         .lsm_lmm_verify         = lsm_lmm_verify_v1,
@@ -292,8 +278,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes,
                                     *stripe_count);
 }
 
-int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
-                    struct lov_mds_md *lmmv1)
+static int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
+                          struct lov_mds_md *lmmv1)
 {
         struct lov_mds_md_v3 *lmm;
         struct lov_oinfo *loi;
@@ -314,11 +300,14 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
                return -E2BIG;
 
         for (i = 0; i < stripe_count; i++) {
-                /* XXX LOV STACKING call down to osc_unpackmd() */
-                loi = lsm->lsm_oinfo[i];
+               /* XXX LOV STACKING call down to osc_unpackmd() */
+               loi = lsm->lsm_oinfo[i];
                ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi);
-                loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
-                loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+               loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
+               loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+               if (lov_oinfo_is_dummy(loi))
+                       continue;
+
                 if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
                         CERROR("OST index %d more than OST count %d\n",
                                loi->loi_ost_idx, lov->desc.ld_tgt_count);
@@ -344,10 +333,19 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
 
 const struct lsm_operations lsm_v3_ops = {
         .lsm_free            = lsm_free_plain,
-        .lsm_destroy         = lsm_destroy_plain,
         .lsm_stripe_by_index    = lsm_stripe_by_index_plain,
         .lsm_stripe_by_offset   = lsm_stripe_by_offset_plain,
         .lsm_lmm_verify         = lsm_lmm_verify_v3,
         .lsm_unpackmd           = lsm_unpackmd_v3,
 };
 
+void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
+{
+       CDEBUG(level, "lsm %p, objid "DOSTID", maxbytes "LPX64", magic 0x%08X,"
+              " stripe_size %u, stripe_count %u, refc: %d,"
+              " layout_gen %u, pool ["LOV_POOLNAMEF"]\n", lsm,
+              POSTID(&lsm->lsm_oi), lsm->lsm_maxbytes, lsm->lsm_magic,
+              lsm->lsm_stripe_size, lsm->lsm_stripe_count,
+              atomic_read(&lsm->lsm_refc), lsm->lsm_layout_gen,
+              lsm->lsm_pool_name);
+}