From a4cd76c790c46b4bf6d85e386b1054d4b925e095 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Tue, 26 Sep 2023 12:45:07 -0700 Subject: [PATCH] LU-16218 utils: add component flags "prefrd" and "prefwr" 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 --- lustre/doc/lfs-find.1 | 6 ++++++ lustre/doc/lfs-getstripe.1 | 6 ++++++ lustre/doc/lfs-setstripe.1 | 6 ++++++ lustre/include/lustre/lustreapi.h | 2 ++ lustre/tests/sanity-flr.sh | 13 ++++++++----- lustre/utils/lfs.c | 2 +- lustre/utils/liblustreapi.c | 8 +++++--- 7 files changed, 34 insertions(+), 9 deletions(-) diff --git a/lustre/doc/lfs-find.1 b/lustre/doc/lfs-find.1 index f0be1d8..4f4a458 100644 --- a/lustre/doc/lfs-find.1 +++ b/lustre/doc/lfs-find.1 @@ -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 diff --git a/lustre/doc/lfs-getstripe.1 b/lustre/doc/lfs-getstripe.1 index b6b5a52..992f73b 100644 --- a/lustre/doc/lfs-getstripe.1 +++ b/lustre/doc/lfs-getstripe.1 @@ -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 diff --git a/lustre/doc/lfs-setstripe.1 b/lustre/doc/lfs-setstripe.1 index 2de086d..3b073a8 100644 --- a/lustre/doc/lfs-setstripe.1 +++ b/lustre/doc/lfs-setstripe.1 @@ -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 diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index a1a90f2..67fea05 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -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" }, diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index c19cb9a..e33fa55 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -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 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index f3f8101..daf4748 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -409,7 +409,7 @@ command_t cmdlist[] = { " [[!] --blocks|-b N] [[!] --component-count [+-]]\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[=]]\n" " [[!] --gid|-g|--group|-G |] [--help|-h]\n" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index b58289b..d09989c 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -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; } -- 1.8.3.1