Whamcloud - gitweb
b=19102 Set correct LOVEA default values for filesystem-wide.
authoryangsheng <Sheng.Yang@Sun.COM>
Mon, 17 May 2010 09:30:21 +0000 (17:30 +0800)
committerJohann Lombardi <johann@sun.com>
Tue, 18 May 2010 12:39:51 +0000 (14:39 +0200)
i=adilger
i=nathan

lustre/include/lustre_lib.h
lustre/mds/handler.c
lustre/mds/mds_internal.h
lustre/mds/mds_lov.c
lustre/mds/mds_reint.c
lustre/mgs/mgs_llog.c
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index a7f92ae..6d1463f 100644 (file)
@@ -528,6 +528,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 dcefe8a..6f24096 100644 (file)
@@ -582,7 +582,7 @@ int mds_get_md(struct obd_device *obd, struct inode *inode, void *md,
         rc = fsfilt_get_md(obd, inode, md, *size, "lov");
 
         if (rc == 0 && flags == MDS_GETATTR)
-                rc = mds_get_default_md(obd, md, &lmm_size);
+                rc = mds_get_default_md(obd, md);
 
         if (rc < 0) {
                 CERROR("Error %d reading eadata for ino %lu\n",
index 15da505..aaccc1d 100644 (file)
@@ -237,8 +237,7 @@ int mds_lov_start_synchronize(struct obd_device *obd,
 int mds_post_mds_lovconf(struct obd_device *obd);
 int mds_notify(struct obd_device *obd, struct obd_device *watched,
                enum obd_notify_event ev, void *data);
-int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
-                       int *lmmsize);
+int mds_get_default_md(struct obd_device *obd, struct lov_user_md *lmm);
 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
                        struct lov_mds_md *lmm, int lmm_size,
                        __u64 connect_flags);
index 4cec524..d01225c 100644 (file)
@@ -1214,26 +1214,31 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
         RETURN(rc);
 }
 
-int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
-                       int *size)
+int mds_get_default_md(struct obd_device *obd, struct lov_user_md *lum)
 {
         struct lov_desc *ldesc;
+        int rc, size = sizeof(*ldesc);
         ENTRY;
 
+        if (!lum)
+                RETURN(0);
+
         ldesc = &obd->u.mds.mds_lov_desc;
         LASSERT(ldesc != NULL);
 
-        if (!lmm)
-                RETURN(0);
+        rc = obd_get_info(obd->u.mds.mds_lov_exp, sizeof(KEY_LOVDESC),
+                          KEY_LOVDESC, &size, ldesc, NULL);
+        if (rc)
+                RETURN(rc);
 
-        lmm->lmm_magic = LOV_MAGIC_V1;
-        lmm->lmm_object_gr = 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_gr = 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));
 }
 
 /* Convert the on-disk LOV EA structre.
index 1added0..843ca39 100644 (file)
@@ -806,11 +806,10 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                  * (i.e. all default values specified) then delete default
                  * striping from dir. */
                 if (S_ISDIR(inode->i_mode) &&
-                    (lum->lmm_stripe_size == 0 &&
-                      lum->lmm_stripe_offset ==
-                      (typeof(lum->lmm_stripe_offset))(-1) &&
-                      lum->lmm_stripe_count == 0 &&
-                      le32_to_cpu(lum->lmm_magic) != LOV_USER_MAGIC_V3)){
+                    LOVEA_DELETE_VALUES(lum->lmm_stripe_size,
+                                        lum->lmm_stripe_count,
+                                        lum->lmm_stripe_offset) &&
+                    (le32_to_cpu(lum->lmm_magic) != LOV_USER_MAGIC_V3)) {
                         rc = fsfilt_set_md(obd, inode, handle, NULL, 0, "lov");
                         if (rc)
                                 GOTO(cleanup, rc);
index 5b8d038..054748e 100644 (file)
@@ -971,7 +971,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 e1f327b..0b5ecdd 100644 (file)
@@ -1238,6 +1238,22 @@ test_27y() {
 }
 run_test 27y "create files while OST0 is degraded and the rest inactive"
 
+test_27z() { # 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 27z "check filesystem-wide default LOV EA values"
+
 # createtest also checks that device nodes are created and
 # then visible correctly (#2091)
 test_28() { # bug 2091
index dbca1f4..478f692 100644 (file)
@@ -326,7 +326,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 65ea002..b54e2e2 100644 (file)
@@ -1410,8 +1410,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",
-                             lum->lmm_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",
+                                     lum->lmm_objects[0].l_ost_idx, nl);
         }
 
         if ((verbose & VERBOSE_POOL) && (pool_name != NULL)) {