Whamcloud - gitweb
b=11694
authorpravins <pravins>
Fri, 11 Jan 2008 13:48:24 +0000 (13:48 +0000)
committerpravins <pravins>
Fri, 11 Jan 2008 13:48:24 +0000 (13:48 +0000)
i=adilger
i=nathan.rutman

This patch for lfs getstripe to return default values for
directories instead of "no stripe info".

lustre/include/lustre/lustre_idl.h
lustre/include/md_object.h
lustre/mdd/mdd_object.c
lustre/mdt/mdt_handler.c
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index f314110..193ce82 100644 (file)
@@ -722,6 +722,9 @@ extern void lustre_swab_obdo (struct obdo *o);
 #define LOV_PATTERN_FIRST 0x100   /* first stripe is not in round-robin */
 #define LOV_PATTERN_CMOBD 0x200
 
+#define LOV_OBJECT_GROUP_DEFAULT ~0ULL
+#define LOV_OBJECT_GROUP_CLEAR 0ULL
+
 #define lov_ost_data lov_ost_data_v1
 struct lov_ost_data_v1 {          /* per-stripe data structure (little-endian)*/
         __u64 l_object_id;        /* OST object ID */
index 7fa59b2..42fbe90 100644 (file)
@@ -101,7 +101,8 @@ enum ma_valid {
         MA_COOKIE    = (1 << 2),
         MA_FLAGS     = (1 << 3),
         MA_LMV       = (1 << 4),
-        MA_ACL_DEF   = (1 << 5)
+        MA_ACL_DEF   = (1 << 5),
+        MA_LOV_DEF   = (1 << 6)
 };
 
 typedef enum {
index be12358..c10d4bc 100644 (file)
@@ -285,6 +285,29 @@ int mdd_iattr_get(const struct lu_env *env, struct mdd_object *mdd_obj,
         RETURN(rc);
 }
 
+static int mdd_get_default_md(struct mdd_object *mdd_obj,
+                struct lov_mds_md *lmm, int *size)
+{
+        struct lov_desc *ldesc;
+        struct mdd_device *mdd = mdo2mdd(&mdd_obj->mod_obj);
+        ENTRY;
+
+        ldesc = &mdd->mdd_obd_dev->u.mds.mds_lov_desc;
+        LASSERT(ldesc != NULL);
+
+        if (!lmm)
+                RETURN(0);
+
+        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);
+
+        RETURN(sizeof(struct lov_mds_md));
+}
+
 /* get lov EA only */
 static int __mdd_lmm_get(const struct lu_env *env,
                          struct mdd_object *mdd_obj, struct md_attr *ma)
@@ -297,6 +320,12 @@ static int __mdd_lmm_get(const struct lu_env *env,
 
         rc = mdd_get_md(env, mdd_obj, ma->ma_lmm, &ma->ma_lmm_size,
                         MDS_LOV_MD_NAME);
+
+        if (rc == 0 && (ma->ma_need & MA_LOV_DEF)) {
+                rc = mdd_get_default_md(mdd_obj, ma->ma_lmm,
+                                &ma->ma_lmm_size);
+        }
+
         if (rc > 0) {
                 ma->ma_valid |= MA_LOV;
                 rc = 0;
index f4d0262..206b5bd 100644 (file)
@@ -449,6 +449,12 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
                 ma->ma_need = MA_LOV | MA_INODE;
         }
 
+        if (S_ISDIR(lu_object_attr(&next->mo_lu)) &&
+            reqbody->valid & OBD_MD_FLDIREA  &&
+            lustre_msg_get_opc(req->rq_reqmsg) == MDS_GETATTR) {
+                /* get default stripe info for this dir. */
+                ma->ma_need |= MA_LOV_DEF;
+        }
         rc = mo_attr_get(env, next, ma);
         if (unlikely(rc)) {
                 CERROR("getattr error for "DFID": %d\n",
index 764e413..bae0863 100644 (file)
@@ -2811,7 +2811,7 @@ test_65e() {
        mkdir -p $DIR/d65
 
        $SETSTRIPE $DIR/d65 || error "setstripe"
-        $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || error "no stripe info failed"
+        $GETSTRIPE -v $DIR/d65 | grep "Default" || error "no stripe info failed"
        touch $DIR/d65/f6
        $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
 }
@@ -2827,7 +2827,7 @@ test_65g() {
         mkdir -p $DIR/d65
         $SETSTRIPE $DIR/d65 -s $(($STRIPESIZE * 2)) -i 0 -c 1 || error "setstripe"
         $SETSTRIPE -d $DIR/d65 || error "setstripe"
-        $GETSTRIPE -v $DIR/d65 | grep "has no stripe info" || \
+        $GETSTRIPE -v $DIR/d65 | grep "Default" || \
                error "delete default stripe failed"
 }
 run_test 65g "directory setstripe -d ==========================="
index 8efe2db..185be04 100644 (file)
@@ -518,8 +518,12 @@ void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *path, int is_dir,
         /* if it's a directory */
         if (is_dir) {
                 if (obdstripe == 1) {
+                        if (lum->lmm_object_gr == LOV_OBJECT_GROUP_DEFAULT) {
+                                llapi_printf(LLAPI_MSG_NORMAL, "(Default) ");
+                                lum->lmm_object_gr = LOV_OBJECT_GROUP_CLEAR;
+                        }
                         llapi_printf(LLAPI_MSG_NORMAL, 
-                                     "default stripe_count: %d stripe_size: %u "
+                                     "stripe_count: %d stripe_size: %u "
                                      "stripe_offset: %d\n",
                                      lum->lmm_stripe_count == (__u16)-1 ? -1 :
                                      lum->lmm_stripe_count,