Whamcloud - gitweb
LU-64 Modify the behavior of ioctl on directories without EA set.
authorPrakash Surya <surya1@llnl.gov>
Wed, 27 Apr 2011 18:03:32 +0000 (11:03 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 7 Jun 2011 03:04:06 +0000 (20:04 -0700)
This patch introduces the following functionality:

1. If an ioctl is performed to obtain the stripe attributes for a
   directory, then the following 3 possibilities can occur:
   a. If the directory in question DOES have it's EA set, then these
      EA values are returned to userspace.
   b. If the directory in question DOES NOT have it's EA set, AND it
      IS the root directory of the filesystem, then the filesystem's
      default EA values are returned to userspace.
   c. If the directory in question DOES NOT have it's EA set, AND it
      IS NOT the root directory of the filesystem, then no EA values
      are returned to userspace. Rather, an error is returned from
      the ioctl and errno is set to ENODATA.
2. lfs getstripe was updated to reflect this change in the ioctl
   interface.
   a. If lfs getstipe --raw is called on a directory other than the
      root directory of the filesystem, and this directory does not
      have any EA set, the filesystem's default values will not be
      printed. Rather, the raw values which mean "use the default"
      will be printed (e.g. stripe count: 0, stripe size: 0, stripe
      offset: -1).

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Change-Id: Ieaaeaf54cce88f406008af4a926fac561900afc9
Reviewed-on: http://review.whamcloud.com/576
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdd/mdd_object.c
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index 8f8a424..10fea55 100644 (file)
@@ -608,6 +608,14 @@ int mdd_get_default_md(struct mdd_object *mdd_obj, struct lov_mds_md *lmm)
         RETURN(sizeof(*lum));
 }
 
+static int is_rootdir(struct mdd_object *mdd_obj)
+{
+        const struct mdd_device *mdd_dev = mdd_obj2mdd_dev(mdd_obj);
+        const struct lu_fid *fid = mdo2fid(mdd_obj);
+
+        return lu_fid_eq(&mdd_dev->mdd_root_fid, fid);
+}
+
 /* get lov EA only */
 static int __mdd_lmm_get(const struct lu_env *env,
                          struct mdd_object *mdd_obj, struct md_attr *ma)
@@ -620,7 +628,7 @@ 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))
+        if (rc == 0 && (ma->ma_need & MA_LOV_DEF) && is_rootdir(mdd_obj))
                 rc = mdd_get_default_md(mdd_obj, ma->ma_lmm);
         if (rc > 0) {
                 ma->ma_lmm_size = rc;
index 75506b6..ea9feda 100644 (file)
@@ -7751,6 +7751,18 @@ test_204d() {
 }
 run_test 204d "Print default stripe count and size ============="
 
+test_204e() {
+       mkdir -p $DIR/$tdir
+       $SETSTRIPE -d $DIR/$tdir
+
+       check_raw_stripe_attr count
+       check_raw_stripe_attr size
+       check_raw_stripe_attr offset
+
+       return 0
+}
+run_test 204e "Print raw stripe attributes ================="
+
 test_204f() {
        mkdir -p $DIR/$tdir
        $SETSTRIPE --count 1 $DIR/$tdir
index aec243b..1c903f8 100644 (file)
@@ -2291,7 +2291,23 @@ static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
         }
 
         if (ret) {
-                if (errno == ENODATA) {
+                if (errno == ENODATA && d != NULL) {
+                        /* We need to "fake" the "use the default" values
+                         * since the lmm struct is zeroed out at this point.
+                         * The magic needs to be set in order to satisfy
+                         * a check later on in the code path.
+                         * The object_seq needs to be set for the "(Default)"
+                         * prefix to be displayed. */
+                        struct lov_user_md *lmm = &param->lmd->lmd_lmm;
+                        lmm->lmm_magic = LOV_MAGIC_V1;
+                        if (!param->raw)
+                                lmm->lmm_object_seq = LOV_OBJECT_GROUP_DEFAULT;
+                        lmm->lmm_stripe_count = 0;
+                        lmm->lmm_stripe_size = 0;
+                        lmm->lmm_stripe_offset = -1;
+                        goto dump;
+
+                } else if (errno == ENODATA && parent != NULL) {
                         if (!param->obduuid)
                                 llapi_printf(LLAPI_MSG_NORMAL,
                                              "%s has no stripe info\n", path);
@@ -2315,6 +2331,7 @@ static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
                 return ret;
         }
 
+dump:
         if (!param->get_mdt_index)
                 llapi_lov_dump_user_lmm(param, path, d ? 1 : 0);