From: Jian Yu Date: Wed, 27 Sep 2023 07:02:15 +0000 (-0700) Subject: LU-16218 utils: add component flags "prefrd" and "prefwr" X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=f82daa2336c9453a2cd347a4529bc7291357c018;p=fs%2Flustre-release.git 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. Lustre-change: https://review.whamcloud.com/52508 Lustre-commit: TBD (from a4cd76c790c46b4bf6d85e386b1054d4b925e095) Test-Parameters: trivial testlist=sanity-flr Change-Id: I3e413cb37fab7ab2834946536705ce61a3feeed4 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52525 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Colin Faber Reviewed-by: Andreas Dilger --- diff --git a/lustre/doc/lfs-find.1 b/lustre/doc/lfs-find.1 index 0563f35..b7dbe3c 100644 --- a/lustre/doc/lfs-find.1 +++ b/lustre/doc/lfs-find.1 @@ -118,6 +118,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 7c514e9..db674b3 100644 --- a/lustre/doc/lfs-getstripe.1 +++ b/lustre/doc/lfs-getstripe.1 @@ -122,6 +122,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 5b7ccd1..0240d40a 100644 --- a/lustre/doc/lfs-setstripe.1 +++ b/lustre/doc/lfs-setstripe.1 @@ -422,6 +422,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 b42ab98..13a6365 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -1157,6 +1157,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 55447cc..088c4ef 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -659,6 +659,7 @@ test_0h() { local td=$DIR/$tdir local tf=$td/$tfile + local flag local ids local i @@ -694,13 +695,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.3.1) ]] || return 0 diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 91069da..0836545 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -541,7 +541,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" " [[!] --compress|--compr|-Z [:[+-]]\n" " [[!] --compress-type=\n" " [[!] --compress-level=[+-]\n" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 1242c51..12c9ff1 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3180,11 +3180,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; }