Whamcloud - gitweb
LU-16218 utils: add component flags "prefrd" and "prefwr" 08/52508/3
authorJian Yu <yujian@whamcloud.com>
Tue, 26 Sep 2023 19:45:07 +0000 (12:45 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Oct 2023 05:49:33 +0000 (05:49 +0000)
The initial implementation of "lfs setstripe ... --comp-flags=prefer"
only allowed specifying a single "prefer" argument for a given
mirror component, which would set both the "LCME_FL_PREF_RD" and
"LCME_FL_PREF_WR" flags at the same time.

This patch adds the separated component flags "prefrd" and "prefwr"
to allow setting the individual flags on a component.

Test-Parameters: trivial testlist=sanity-flr

Change-Id: I3e413cb37fab7ab2834946536705ce61a3feeed4
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52508
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Zhenyu Xu <bobijam@hotmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs-find.1
lustre/doc/lfs-getstripe.1
lustre/doc/lfs-setstripe.1
lustre/include/lustre/lustreapi.h
lustre/tests/sanity-flr.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index f0be1d8..4f4a458 100644 (file)
@@ -114,6 +114,12 @@ before they can be accessed again.
 Replicated (mirrored) components that are preferred for read or write.
 For example, because they are located on SSD-based OSTs, or are more
 local on the network to clients.
+.TP
+.B prefrd
+Replicated (mirrored) components that are preferred for read.
+.TP
+.B prefwr
+Replicated (mirrored) components that are preferred for write.
 .RE
 .TP
 .BR --component-start | --comp-start
index b6b5a52..992f73b 100644 (file)
@@ -118,6 +118,12 @@ Replicated (mirrored) components that are preferred for read or write.
 For example, because they are located on SSD-based OSTs, or are more
 local on the network to clients.
 .TP
+.B prefrd
+Replicated (mirrored) components that are preferred for read.
+.TP
+.B prefwr
+Replicated (mirrored) components that are preferred for write.
+.TP
 .B nosync
 Replicated (mirrored) components that do not resync using \fB
 lfs mirror resync\fR.  Files with the \fBnosync\fR flag will also
index 2de086d..3b073a8 100644 (file)
@@ -394,6 +394,12 @@ to find uninitialized components.
 .B * prefer\fR - component preferred for read/write in a mirrored file
 .RE
 .RS
+.B * prefrd\fR - component preferred for read in a mirrored file
+.RE
+.RS
+.B * prefwr\fR - component preferred for write in a mirrored file
+.RE
+.RS
 .B * stale\fR - component has outdated data in a mirrored file. This flag is
 not allowed to be set on a component of the last non-stale mirror.
 Once a component is marked
index a1a90f2..67fea05 100644 (file)
@@ -1133,6 +1133,8 @@ static const struct comp_flag_name {
        { LCME_FL_INIT,         "init" },
        { LCME_FL_STALE,        "stale" },
        { LCME_FL_PREF_RW,      "prefer" },
+       { LCME_FL_PREF_RD,      "prefrd" },
+       { LCME_FL_PREF_WR,      "prefwr" },
        { LCME_FL_OFFLINE,      "offline" },
        { LCME_FL_NOSYNC,       "nosync" },
        { LCME_FL_EXTENSION,    "extension" },
index c19cb9a..e33fa55 100644 (file)
@@ -727,6 +727,7 @@ test_0h() {
 
        local td=$DIR/$tdir
        local tf=$td/$tfile
+       local flag
        local ids
        local i
 
@@ -762,13 +763,15 @@ test_0h() {
        cp /etc/hosts $tf || error "error writing file '$tf'"
        $LFS mirror resync $tf || error "error resync-ing file '$tf'"
 
-       $LFS setstripe --comp-set -I 0x20003 --comp-flags=prefer $tf ||
-               error "error setting flag prefer"
+       for flag in prefer prefrd prefwr; do
+               $LFS setstripe --comp-set -I 0x20003 --comp-flags=$flag $tf ||
+                       error "error setting flag $flag"
 
-       verify_comp_attr lcme_flags $tf 0x20003 prefer
+               verify_comp_attr lcme_flags $tf 0x20003 $flag
 
-       $LFS setstripe --comp-set -I 0x20003 --comp-flags=^prefer $tf ||
-               error "error clearing prefer flag from component 0x20003"
+               $LFS setstripe --comp-set -I 0x20003 --comp-flags=^$flag $tf ||
+                       error "error clearing $flag flag from component 0x20003"
+       done
 
        # MDS disallows setting stale flag on the last non-stale mirror
        [[ "$MDS1_VERSION" -ge $(version_code 2.12.57) ]] || return 0
index a6d965a..6db3263 100644 (file)
@@ -409,7 +409,7 @@ command_t cmdlist[] = {
         "     [[!] --blocks|-b N] [[!] --component-count [+-]<comp_cnt>]\n"
         "     [[!] --component-start [+-]N[kMGTPE]]\n"
         "     [[!] --component-end|-E [+-]N[kMGTPE]]\n"
-        "     [[!] --component-flags {init,stale,prefer,offline,nosync,extension}]\n"
+        "     [[!] --component-flags {init,stale,prefer,prefrd,prefwr,offline,nosync,extension}]\n"
         "     [[!] --extension-size|--ext-size|-z [+-]N[kMGT]]\n"
         "     [[!] --foreign[=<foreign_type>]]\n"
         "     [[!] --gid|-g|--group|-G <gid>|<gname>] [--help|-h]\n"
index b58289b..d09989c 100644 (file)
@@ -3163,11 +3163,13 @@ static void lcme_flags2str(__u32 comp_flags)
                return;
        }
        for (i = 0; i < ARRAY_SIZE(comp_flags_table); i++) {
-               if (comp_flags & comp_flags_table[i].cfn_flag) {
+               const char *cfn_name = comp_flags_table[i].cfn_name;
+               __u32 cfn_flag = comp_flags_table[i].cfn_flag;
+
+               if ((comp_flags & cfn_flag) == cfn_flag) {
                        if (found)
                                llapi_printf(LLAPI_MSG_NORMAL, ",");
-                       llapi_printf(LLAPI_MSG_NORMAL, "%s",
-                                    comp_flags_table[i].cfn_name);
+                       llapi_printf(LLAPI_MSG_NORMAL, "%s", cfn_name);
                        comp_flags &= ~comp_flags_table[i].cfn_flag;
                        found = true;
                }