Whamcloud - gitweb
b=19102 set default values of filesystem-wide for LOVEA.
authoryangsheng <Sheng.Yang@sun.com>
Fri, 13 Aug 2010 13:19:26 +0000 (17:19 +0400)
committerMikhail Pershin <tappro@sun.com>
Thu, 19 Aug 2010 06:41:23 +0000 (10:41 +0400)
i=adilger
i=nathan

lustre/include/lustre_lib.h
lustre/mdd/mdd_device.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mdd/mdd_object.c
lustre/mgs/mgs_llog.c
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index 02cc979..e9cb2dd 100644 (file)
@@ -536,6 +536,10 @@ static inline void obd_ioctl_freedata(char *buf, int len)
  * we define this to be 2T - 4k, which is the ext3 maxbytes. */
 #define LUSTRE_STRIPE_MAXBYTES 0x1fffffff000ULL
 
+/* Special values for remove LOV EA from disk */
+#define LOVEA_DELETE_VALUES(size, count, offset) (size == 0 && count == 0 && \
+                                                 offset == (typeof(offset))(-1))
+
 /* #define POISON_BULK 0 */
 
 /*
index 8ec669f..2c9ad6d 100644 (file)
@@ -744,9 +744,9 @@ static int obf_attr_get(const struct lu_env *env, struct md_object *obj,
                         return 0;
 
                 if (ma->ma_need & MA_LOV_DEF) {
-                        rc = mdd_get_default_md(mdd_obj, ma->ma_lmm,
-                                                &ma->ma_lmm_size);
+                        rc = mdd_get_default_md(mdd_obj, ma->ma_lmm);
                         if (rc > 0) {
+                                ma->ma_lmm_size = rc;
                                 ma->ma_valid |= MA_LOV;
                                 rc = 0;
                         }
index eaf6c96..03794a0 100644 (file)
@@ -374,8 +374,7 @@ extern const struct lu_device_operations mdd_lu_ops;
 struct mdd_object *mdd_object_find(const struct lu_env *env,
                                    struct mdd_device *d,
                                    const struct lu_fid *f);
-int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm,
-                       int *size);
+int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm);
 int mdd_readpage(const struct lu_env *env, struct md_object *obj,
                  const struct lu_rdpg *rdpg);
 
index 5b6c656..9638327 100644 (file)
@@ -274,8 +274,8 @@ static int mdd_lov_set_dir_md(const struct lu_env *env,
 
         /* if { size, offset, count } = { 0, -1, 0 } and no pool (i.e. all default
          * values specified) then delete default striping from dir. */
-        if (lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 &&
-            lum->lmm_stripe_offset == (typeof(lum->lmm_stripe_offset))(-1) &&
+        if (LOVEA_DELETE_VALUES(lum->lmm_stripe_size, lum->lmm_stripe_count,
+                                lum->lmm_stripe_offset) &&
             lum->lmm_magic != LOV_USER_MAGIC_V3) {
                 rc = mdd_xattr_set_txn(env, obj, &LU_BUF_NULL,
                                        XATTR_NAME_LOV, 0, handle);
index 6f57ea8..a735f7f 100644 (file)
@@ -606,29 +606,27 @@ int mdd_iattr_get(const struct lu_env *env, struct mdd_object *mdd_obj,
         RETURN(rc);
 }
 
-int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm,
-                       int *size)
+int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm)
 {
         struct lov_desc *ldesc;
         struct mdd_device *mdd = mdo2mdd(&mdd_obj->mod_obj);
+        struct lov_user_md *lum = (struct lov_user_md*)lmm;
         ENTRY;
 
+        if (!lum)
+                RETURN(0);
+
         ldesc = &mdd->mdd_obd_dev->u.mds.mds_lov_desc;
         LASSERT(ldesc != NULL);
 
-        if (!lmm) {
-                *size = 0;
-                RETURN(0);
-        }
-
-        lmm->lmm_magic = LOV_MAGIC_V1;
-        lmm->lmm_object_seq = LOV_OBJECT_GROUP_DEFAULT;
-        lmm->lmm_pattern = ldesc->ld_pattern;
-        lmm->lmm_stripe_size = ldesc->ld_default_stripe_size;
-        lmm->lmm_stripe_count = ldesc->ld_default_stripe_count;
-        *size = sizeof(struct lov_mds_md);
+        lum->lmm_magic = LOV_MAGIC_V1;
+        lum->lmm_object_seq = LOV_OBJECT_GROUP_DEFAULT;
+        lum->lmm_pattern = ldesc->ld_pattern;
+        lum->lmm_stripe_size = ldesc->ld_default_stripe_size;
+        lum->lmm_stripe_count = ldesc->ld_default_stripe_count;
+        lum->lmm_stripe_offset = ldesc->ld_default_stripe_offset;
 
-        RETURN(sizeof(struct lov_mds_md));
+        RETURN(sizeof(*lum));
 }
 
 /* get lov EA only */
@@ -644,9 +642,9 @@ static int __mdd_lmm_get(const struct lu_env *env,
         rc = mdd_get_md(env, mdd_obj, ma->ma_lmm, &ma->ma_lmm_size,
                         XATTR_NAME_LOV);
         if (rc == 0 && (ma->ma_need & MA_LOV_DEF))
-                rc = mdd_get_default_md(mdd_obj, ma->ma_lmm,
-                                        &ma->ma_lmm_size);
+                rc = mdd_get_default_md(mdd_obj, ma->ma_lmm);
         if (rc > 0) {
+                ma->ma_lmm_size = rc;
                 ma->ma_valid |= MA_LOV;
                 rc = 0;
         }
index a27969a..dc8ed62 100644 (file)
@@ -1306,7 +1306,7 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
         lovdesc->ld_default_stripe_count = 1;
         lovdesc->ld_pattern = LOV_PATTERN_RAID0;
         lovdesc->ld_default_stripe_size = 1024 * 1024;
-        lovdesc->ld_default_stripe_offset = 0;
+        lovdesc->ld_default_stripe_offset = -1;
         lovdesc->ld_qos_maxage = QOS_DEFAULT_MAXAGE;
         sprintf((char*)lovdesc->ld_uuid.uuid, "%s_UUID", lovname);
         /* can these be the same? */
index 8a22205..cf816a4 100755 (executable)
@@ -1362,6 +1362,22 @@ test_27z() {
 }
 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
 
+test_27A() { # b=19102
+        local restore_size=`$GETSTRIPE -s $MOUNT`
+        local restore_count=`$GETSTRIPE -c $MOUNT`
+        local restore_offset=`$GETSTRIPE -o $MOUNT`
+        $SETSTRIPE -c 0 -o -1 -s 0 $MOUNT
+        local default_size=`$GETSTRIPE -s $MOUNT`
+        local default_count=`$GETSTRIPE -c $MOUNT`
+        local default_offset=`$GETSTRIPE -o $MOUNT`
+        local dsize=$((1024 * 1024))
+        [ $default_size -eq $dsize ] || error "stripe size $default_size != $dsize"
+        [ $default_count -eq 1 ] || error "stripe count $default_count != 1"
+        [ $default_offset -eq -1 ] || error "stripe offset $default_offset != -1"
+        $SETSTRIPE -c $restore_count -o $restore_offset -s $restore_size $MOUNT
+}
+run_test 27A "check filesystem-wide default LOV EA values"
+
 # createtest also checks that device nodes are created and
 # then visible correctly (#2091)
 test_28() { # bug 2091
@@ -4772,7 +4788,7 @@ test_102k() {
         local default_size=`$GETSTRIPE -s $test_kdir`
         local default_count=`$GETSTRIPE -c $test_kdir`
         local default_offset=`$GETSTRIPE -o $test_kdir`
-        $SETSTRIPE -s 65536 -i 1 -c 2 $test_kdir || error 'dir setstripe failed'
+        $SETSTRIPE -s 65536 -i 1 -c $OSTCOUNT $test_kdir || error 'dir setstripe failed'
         setfattr -n trusted.lov $test_kdir
         local stripe_size=`$GETSTRIPE -s $test_kdir`
         local stripe_count=`$GETSTRIPE -c $test_kdir`
index f2b1748..7754ccd 100644 (file)
@@ -371,7 +371,7 @@ static int lfs_setstripe(int argc, char **argv)
         }
         /* get the stripe offset */
         if (stripe_off_arg != NULL) {
-                st_offset = strtoul(stripe_off_arg, &end, 0);
+                st_offset = strtol(stripe_off_arg, &end, 0);
                 if (*end != '\0') {
                         fprintf(stderr, "error: %s: bad stripe offset '%s'\n",
                                 argv[0], stripe_off_arg);
index 94be89b..a4c8cf6 100644 (file)
@@ -1423,8 +1423,14 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                 if (verbose & ~VERBOSE_OFFSET)
                         llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset:  ",
                                      prefix);
-                llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
-                             objects[0].l_ost_idx, nl);
+                if (is_dir) 
+                        llapi_printf(LLAPI_MSG_NORMAL, "%d%c",
+                                     lum->lmm_stripe_offset ==
+                                     (typeof(lum->lmm_stripe_offset))(-1) ? -1 :
+                                     lum->lmm_stripe_offset, nl);
+                else
+                        llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
+                                     objects[0].l_ost_idx, nl);
         }
 
         if ((verbose & VERBOSE_POOL) && (pool_name != NULL)) {