Whamcloud - gitweb
LU-5916 lod: inherit default pool setting properly 46/12746/7
authorNiu Yawei <yawei.niu@intel.com>
Mon, 17 Nov 2014 06:59:44 +0000 (01:59 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 19 Dec 2014 15:04:28 +0000 (15:04 +0000)
When parent directory has no default striping but has only
default pool setting, the pool setting should be inherited
by subdir properly.

This patch fixed the problem by changing the
LOVEA_DELETE_VALUES() to check pool name as well, and it
removed the unused function lod_store_def_striping().

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I7ce5251b6c601309aeb91a1b903bde02d0712e25
Reviewed-on: http://review.whamcloud.com/12746
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/mdd/mdd_dir.c
lustre/tests/sanity.sh

index 36dfee2..3c35585 100644 (file)
@@ -46,8 +46,9 @@
 #define LOV_USES_DEFAULT_STRIPE         1
 
 /* Special values to remove LOV EA from disk */
-#define LOVEA_DELETE_VALUES(size, count, offset)                       \
-       ((size) == 0 && (count) == 0 && (offset) == (typeof(offset))(-1))
+#define LOVEA_DELETE_VALUES(size, count, offset, pool)                 \
+       ((size) == 0 && (count) == 0 &&                                 \
+        (offset) == (typeof(offset))(-1) && (pool) == NULL)
 
 #define LMVEA_DELETE_VALUES(count, offset)                             \
        ((count) == 0 && (offset) == (typeof(offset))(-1))
@@ -434,8 +435,6 @@ int lod_parse_dir_striping(const struct lu_env *env, struct lod_object *lo,
                           const struct lu_buf *buf);
 int lod_initialize_objects(const struct lu_env *env, struct lod_object *mo,
                           struct lov_ost_data_v1 *objs);
-int lod_store_def_striping(const struct lu_env *env, struct dt_object *dt,
-                          struct thandle *th);
 int lod_verify_striping(struct lod_device *d, const struct lu_buf *buf,
                        bool is_from_disk);
 int lod_generate_and_set_lovea(const struct lu_env *env,
index 2196e79..e755388 100644 (file)
@@ -739,72 +739,6 @@ repeat:
 }
 
 /**
- * Store default striping.
- *
- * Store default striping for the files in the given directory. The data
- * are stored in the LOD-object representing the directory (ldo_def_* fields).
- * If default striping matches virtual fs-wide default striping, then we
- * store nothing. This mean that the files in the directory will be created
- * with filesystem-wide default striping. The transaction must be started.
- *
- * \param[in] env              execution environment for this thread
- * \param[in] dt               dt object representing directory in LOD layer
- * \param[in] th               transaction handle
- *
- * \retval                     0 if stored successfully or no need to store
- * \retval                     negative error number on failure
- */
-int lod_store_def_striping(const struct lu_env *env, struct dt_object *dt,
-                          struct thandle *th)
-{
-       struct lod_thread_info  *info = lod_env_info(env);
-       struct lod_object       *lo = lod_dt_obj(dt);
-       struct dt_object        *next = dt_object_child(dt);
-       struct lov_user_md_v3   *v3;
-       int                      rc;
-       ENTRY;
-
-       if (S_ISDIR(dt->do_lu.lo_header->loh_attr))
-               RETURN(-ENOTDIR);
-       /*
-        * store striping defaults into new directory
-        * used to implement defaults inheritance
-        */
-
-       /* probably nothing to inherite */
-       if (lo->ldo_striping_cached == 0)
-               RETURN(0);
-
-       if (LOVEA_DELETE_VALUES(lo->ldo_def_stripe_size, lo->ldo_def_stripenr,
-                               lo->ldo_def_stripe_offset))
-               RETURN(0);
-
-       v3 = info->lti_ea_store;
-       if (info->lti_ea_store_size < sizeof(*v3)) {
-               rc = lod_ea_store_resize(info, sizeof(*v3));
-               if (rc != 0)
-                       RETURN(rc);
-               v3 = info->lti_ea_store;
-       }
-       memset(v3, 0, sizeof(*v3));
-       v3->lmm_magic = cpu_to_le32(LOV_USER_MAGIC_V3);
-       v3->lmm_stripe_count = cpu_to_le16(lo->ldo_def_stripenr);
-       v3->lmm_stripe_offset = cpu_to_le16(lo->ldo_def_stripe_offset);
-       v3->lmm_stripe_size = cpu_to_le32(lo->ldo_def_stripe_size);
-       if (lo->ldo_pool != NULL) {
-               strlcpy(v3->lmm_pool_name, lo->ldo_pool,
-                       sizeof(v3->lmm_pool_name));
-               v3->lmm_pool_name[sizeof(v3->lmm_pool_name) - 1] = '\0';
-       }
-       info->lti_buf.lb_buf = v3;
-       info->lti_buf.lb_len = sizeof(*v3);
-       rc = dt_xattr_set(env, next, &info->lti_buf, XATTR_NAME_LOV, 0, th,
-                       BYPASS_CAPA);
-
-       RETURN(rc);
-}
-
-/**
  * Verify the target index is present in the current configuration.
  *
  * \param[in] md               LOD device where the target table is stored
index 4cb4d06..086b93c 100644 (file)
@@ -1837,7 +1837,8 @@ next:
                if (lo->ldo_striping_cached &&
                    !LOVEA_DELETE_VALUES(lo->ldo_def_stripe_size,
                                         lo->ldo_def_stripenr,
-                                        lo->ldo_def_stripe_offset)) {
+                                        lo->ldo_def_stripe_offset,
+                                        lo->ldo_pool)) {
                        struct lov_user_md_v3   *v3;
 
                        /* sigh, lti_ea_store has been used for lmv_buf,
@@ -2257,6 +2258,7 @@ static int lod_xattr_set_lov_on_dir(const struct lu_env *env,
        struct lod_object       *l = lod_dt_obj(dt);
        struct lov_user_md_v1   *lum;
        struct lov_user_md_v3   *v3 = NULL;
+       const char              *pool_name = NULL;
        int                      rc;
        ENTRY;
 
@@ -2272,8 +2274,11 @@ static int lod_xattr_set_lov_on_dir(const struct lu_env *env,
        if (rc)
                RETURN(rc);
 
-       if (lum->lmm_magic == LOV_USER_MAGIC_V3)
+       if (lum->lmm_magic == LOV_USER_MAGIC_V3) {
                v3 = buf->lb_buf;
+               if (v3->lmm_pool_name[0] != '\0')
+                       pool_name = v3->lmm_pool_name;
+       }
 
        /* if { size, offset, count } = { 0, -1, 0 } and no pool
         * (i.e. all default values specified) then delete default
@@ -2285,10 +2290,8 @@ static int lod_xattr_set_lov_on_dir(const struct lu_env *env,
                (int)lum->lmm_stripe_offset,
                v3 ? "from" : "", v3 ? v3->lmm_pool_name : "");
 
-       if (LOVEA_DELETE_VALUES((lum->lmm_stripe_size),
-                               (lum->lmm_stripe_count),
-                               (lum->lmm_stripe_offset)) &&
-                       lum->lmm_magic == LOV_USER_MAGIC_V1) {
+       if (LOVEA_DELETE_VALUES(lum->lmm_stripe_size, lum->lmm_stripe_count,
+                               lum->lmm_stripe_offset, pool_name)) {
                rc = lod_xattr_del_internal(env, dt, name, th, capa);
                if (rc == -ENODATA)
                        rc = 0;
@@ -2459,7 +2462,8 @@ static int lod_xattr_set_lmv(const struct lu_env *env, struct dt_object *dt,
                if (lo->ldo_striping_cached &&
                    !LOVEA_DELETE_VALUES(lo->ldo_def_stripe_size,
                                         lo->ldo_def_stripenr,
-                                        lo->ldo_def_stripe_offset)) {
+                                        lo->ldo_def_stripe_offset,
+                                        lo->ldo_pool)) {
                        struct lov_user_md_v3   *v3;
 
                        /* sigh, lti_ea_store has been used for lmv_buf,
@@ -2659,7 +2663,8 @@ int lod_dir_striping_create_internal(const struct lu_env *env,
        if (lo->ldo_striping_cached &&
            !LOVEA_DELETE_VALUES(lo->ldo_def_stripe_size,
                                 lo->ldo_def_stripenr,
-                                lo->ldo_def_stripe_offset)) {
+                                lo->ldo_def_stripe_offset,
+                                lo->ldo_pool)) {
                struct lov_user_md_v3 *v3 = info->lti_ea_store;
 
                if (info->lti_ea_store_size < sizeof(*v3)) {
index d651bc1..9744718 100644 (file)
@@ -2168,9 +2168,11 @@ static int mdd_object_create(const struct lu_env *env, struct mdd_object *pobj,
        /* During creation, there are only a few cases we need do xattr_set to
         * create stripes.
         * 1. regular file: see comments above.
-        * 2. create striped directory with provided stripeEA.
-        * 3. create striped directory because inherit default layout from the
-        * parent. */
+        * 2. dir: inherit default striping or pool settings from parent.
+        * 3. create striped directory with provided stripeEA.
+        * 4. create striped directory because inherit default layout from the
+        * parent.
+        */
        if (spec->no_create ||
            (S_ISREG(attr->la_mode) && spec->sp_cr_flags & MDS_OPEN_HAS_EA) ||
            S_ISDIR(attr->la_mode)) {
index d008c32..66c9642 100644 (file)
@@ -11137,6 +11137,7 @@ test_200() {
        local ost_range="$first_ost $last_ost $ost_step"
        local test_path=$POOL_ROOT/$POOL_DIR_NAME
        local file_dir=$POOL_ROOT/file_tst
+       local subdir=$test_path/subdir
 
        local rc=0
        while : ; do
@@ -11147,6 +11148,8 @@ test_200() {
                mkdir -p $test_path
                pool_set_dir      $POOL $test_path      || { rc=$? ; break; }
                pool_check_dir    $POOL $test_path      || { rc=$? ; break; }
+               mkdir -p $subdir
+               pool_check_dir    $POOL $subdir         || { rc=$? ; break; }
                pool_dir_rel_path $POOL $POOL_DIR_NAME $POOL_ROOT \
                                                        || { rc=$? ; break; }
                # former test_200e test_200f