Whamcloud - gitweb
EX-9708 utils: lfs setstripe adds -E with -Z
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 30 May 2024 17:04:27 +0000 (11:04 -0600)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 6 Jun 2024 08:16:18 +0000 (08:16 +0000)
When specifying a layout with "lfs setstripe -Z" it will ignore
this option if no PFL component is specified with "-E".

Instead, "lfs setstripe -Z" should automatically upgrade the file
layout to a PFL layout so the compression parameters are saved.

Test-Parameters: trivial testlist=sanity-compr
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I29cc373fabd352d6f8b6781c238806b75cce7057
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55264
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
lustre/tests/sanity-compr.sh
lustre/utils/lfs.c

index aa442ad..ed8d0c3 100644 (file)
@@ -1219,6 +1219,21 @@ test_1008() {
 }
 run_test 1008 "validate directory space usage reduction with compression"
 
+test_1014() {
+       (( MDS1_VERSION >= $(version_code 2.14.0-ddn128) )) ||
+               skip "Need MDS version at least 2.14.0-ddn128"
+       $LFS setstripe -Z lz4:3 $DIR/$tfile || error "setstripe -Z failed"
+       $LFS setstripe -E eof -Z lz4:3 $DIR/$tfile.2 ||
+               error "setstripe -E eof -Z failed"
+       $LFS getstripe -Z $DIR/$tfile
+
+       local def=$($LFS getstripe -Z $DIR/$tfile)
+       local eof=$($LFS getstripe -Z $DIR/$tfile.2)
+
+       [[ "$def" == "$eof" ]] || error "default '$def' != eof '$eof'"
+}
+run_test 1014 "add PFL for compressed layout"
+
 test_1020() {
        (( MDS1_VERSION >= $(version_code 2.14.0-ddn128) )) ||
                skip "Need MDS version at least 2.14.0-ddn128"
@@ -1303,7 +1318,7 @@ test_1020() {
        # (( r_chunks == w_chunks )) ||
        #       error "num of chunks does not match. '$r_chunks' != '$w_chunks'"
 }
-run_test 1020 "ะกhecking compression counters"
+run_test 1020 "Checking compression counters"
 
 test_1080() {
        (( MDS1_VERSION >= $(version_code 2.14.0-ddn128) )) ||
index 0f75f73..12e5326 100644 (file)
@@ -4273,11 +4273,6 @@ static int lfs_setstripe_internal(int argc, char **argv,
                        break;
                case LFS_COMPRESS_TYPE_OPT:
                case 'Z':
-                       if (layout == NULL && mirror_list == NULL &&
-                           lsa.lsa_comp_end == 0)
-                               fprintf(stderr,
-                                       "WARNING: (-Z) option specified, however no layout defined (-E), compression feature will not be enabled.\n");
-
                        result = llapi_parse_compress_type(optarg,
                                                           &lsa.lsa_compr_type,
                                                           &lsa.lsa_compr_lvl,
@@ -4374,6 +4369,9 @@ static int lfs_setstripe_internal(int argc, char **argv,
                        lsa.lsa_comp_end = LUSTRE_EOF;
        }
 
+       if (lsa.lsa_compr_type && !lsa.lsa_comp_end)
+               lsa.lsa_comp_end = LUSTRE_EOF;
+
        if (lsa.lsa_comp_end != 0) {
                result = comp_args_to_layout(lpp, &lsa, true);
                if (result) {