Whamcloud - gitweb
LU-11482 flr: Inherit flags from template 26/33326/10
authorPatrick Farrell <paf@cray.com>
Thu, 11 Oct 2018 11:55:42 +0000 (06:55 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 23 Oct 2018 05:19:07 +0000 (05:19 +0000)
New files created in directories with a default layout
should inherit the per-component layout flags.

This allows us to set the prefer or nosync flags in a
default layout and apply them to files created in that
directory.

Cray-bug-id: LUS-6574
Signed-off-by: Patrick Farrell <paf@cray.com>
Change-Id: I053ca0f3db3e0967799f469feeb4f1f12b144be7
Reviewed-on: https://review.whamcloud.com/33326
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lod/lod_object.c
lustre/tests/sanity-flr.sh

index 61a565f..61eaa8b 100644 (file)
@@ -607,6 +607,11 @@ enum lov_comp_md_entry_flags {
 /* The flags are for mirrors */
 #define LCME_MIRROR_FLAGS      (LCME_FL_NOSYNC)
 
 /* The flags are for mirrors */
 #define LCME_MIRROR_FLAGS      (LCME_FL_NOSYNC)
 
+/* These flags have meaning when set in a default layout and will be inherited
+ * from the default/template layout set on a directory.
+ */
+#define LCME_TEMPLATE_FLAGS    (LCME_FL_PREF_RW | LCME_FL_NOSYNC)
+
 /* the highest bit in obdo::o_layout_version is used to mark if the file is
  * being resynced. */
 #define LU_LAYOUT_RESYNC       LCME_FL_NEG
 /* the highest bit in obdo::o_layout_version is used to mark if the file is
  * being resynced. */
 #define LU_LAYOUT_RESYNC       LCME_FL_NEG
index 61ab51d..847625b 100644 (file)
@@ -4466,7 +4466,6 @@ static int lod_get_default_lov_striping(const struct lu_env *env,
 
        for (i = 0; i < comp_cnt; i++) {
                struct lod_layout_component *lod_comp;
 
        for (i = 0; i < comp_cnt; i++) {
                struct lod_layout_component *lod_comp;
-               struct lu_extent *ext;
                char *pool;
 
                lod_comp = &lds->lds_def_comp_entries[i];
                char *pool;
 
                lod_comp = &lds->lds_def_comp_entries[i];
@@ -4480,8 +4479,12 @@ static int lod_get_default_lov_striping(const struct lu_env *env,
                if (composite) {
                        v1 = (struct lov_user_md *)((char *)comp_v1 +
                                        comp_v1->lcm_entries[i].lcme_offset);
                if (composite) {
                        v1 = (struct lov_user_md *)((char *)comp_v1 +
                                        comp_v1->lcm_entries[i].lcme_offset);
-                       ext = &comp_v1->lcm_entries[i].lcme_extent;
-                       lod_comp->llc_extent = *ext;
+                       lod_comp->llc_extent =
+                                       comp_v1->lcm_entries[i].lcme_extent;
+                       /* We only inherit certain flags from the layout */
+                       lod_comp->llc_flags =
+                                       comp_v1->lcm_entries[i].lcme_flags &
+                                       LCME_TEMPLATE_FLAGS;
                }
 
                if (v1->lmm_pattern != LOV_PATTERN_RAID0 &&
                }
 
                if (v1->lmm_pattern != LOV_PATTERN_RAID0 &&
@@ -4624,8 +4627,9 @@ static void lod_striping_from_default(struct lod_object *lo,
                        struct lod_layout_component *def_comp =
                                                &lds->lds_def_comp_entries[i];
 
                        struct lod_layout_component *def_comp =
                                                &lds->lds_def_comp_entries[i];
 
-                       CDEBUG(D_LAYOUT, "Inherite from default: size:%hu "
-                              "nr:%u offset:%u pattern %#x %s\n",
+                       CDEBUG(D_LAYOUT, "Inherit from default: flags=%#x "
+                              "size=%hu nr=%u offset=%u pattern=%#x pool=%s\n",
+                              def_comp->llc_flags,
                               def_comp->llc_stripe_size,
                               def_comp->llc_stripe_count,
                               def_comp->llc_stripe_offset,
                               def_comp->llc_stripe_size,
                               def_comp->llc_stripe_count,
                               def_comp->llc_stripe_offset,
index a763206..d48003b 100644 (file)
@@ -674,10 +674,19 @@ test_0g() {
 run_test 0g "lfs mirror create flags support"
 
 test_0h() {
 run_test 0g "lfs mirror create flags support"
 
 test_0h() {
-       local tf=$DIR/$tfile
+       local td=$DIR/$tdir
+       local tf=$td/$tfile
+       local ids
+       local i
 
 
-       $LFS mirror create -N -E 1M -S 1M --flags=prefer -E eof -N2 $tf ||
-               error "create mirrored file $tf failed"
+       # create parent directory
+       test_mkdir $td || error "mkdir $td failed"
+
+       $LFS setstripe -N -E 1M -S 1M --flags=prefer -E eof -N2 $td ||
+               error "set default mirrored layout on directory $td failed"
+
+       # verify flags are inherited from the directory
+       touch $tf
 
        verify_comp_attr lcme_flags $tf 0x10001 prefer
        verify_comp_attr lcme_flags $tf 0x10002 prefer
 
        verify_comp_attr lcme_flags $tf 0x10001 prefer
        verify_comp_attr lcme_flags $tf 0x10002 prefer