From d3874966e4938df1752117462faef7bfcffffc57 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Mon, 3 Apr 2023 05:38:03 -0400 Subject: [PATCH] LU-16700 pcc: reserve flags for PCC-RO This patch reserves flags for PCC-RO. It also adds wire check / test for these new flags. Test-Parameters: trivial Signed-off-by: Qian Yingjin Change-Id: I7086843770d16a6a7d2fd6b6ad3c77d43e04bf3b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50504 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Feng Lei Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustreapi.h | 18 +++++++++++ lustre/include/uapi/linux/lustre/lustre_idl.h | 2 ++ lustre/include/uapi/linux/lustre/lustre_user.h | 17 ++++++++++- lustre/ptlrpc/wiretest.c | 4 +++ lustre/utils/wirecheck.c | 26 ++++++++++++++++ lustre/utils/wiretest.c | 41 ++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 1 deletion(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index 93ccb4c..54481c5 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -841,6 +841,7 @@ int llapi_layout_merge(struct llapi_layout **dst_layout, #define LLAPI_LAYOUT_RAID0 0ULL #define LLAPI_LAYOUT_MDT 2ULL #define LLAPI_LAYOUT_OVERSTRIPING 4ULL +#define LLAPI_LAYOUT_FOREIGN 8ULL /** * The layout includes a specific set of OSTs on which to allocate. @@ -1123,6 +1124,23 @@ static const struct comp_flag_name { { LCME_FL_PARITY, "parity" }, }; +/* HSM component flags table */ +static const struct hsm_flag_name { + enum hsm_states hfn_flag; + const char *hfn_name; +} hsm_flags_table[] = { + { HS_NONE, "none" }, + { HS_EXISTS, "exists" }, + { HS_DIRTY, "dirty" }, + { HS_RELEASED, "released" }, + { HS_ARCHIVED, "archived" }, + { HS_NORELEASE, "norelease" }, + { HS_NOARCHIVE, "noarchive" }, + { HS_LOST, "lost" }, + { HS_PCCRW, "pccrw" }, + { HS_PCCRO, "pccro" }, +}; + /** * Gets the attribute flags of the current component. */ diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index e8974b9..6bffc36 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -3336,6 +3336,8 @@ enum layout_intent_opc { LAYOUT_INTENT_TRUNC = 4, /** truncate file, for comp layout */ LAYOUT_INTENT_RELEASE = 5, /** reserved for HSM release */ LAYOUT_INTENT_RESTORE = 6, /** reserved for HSM restore */ + LAYOUT_INTENT_PCCRO_SET = 7, /** set read-only layout for PCC */ + LAYOUT_INTENT_PCCRO_CLEAR = 8, /** clear read-only layout */ }; /* enqueue layout lock with intent */ diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 920c9de..c52b579 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -634,6 +634,7 @@ struct ll_ioc_lease_id { #define LL_IOC_LADVISE _IOR('f', 250, struct llapi_lu_ladvise) #define LL_IOC_HEAT_GET _IOWR('f', 251, struct lu_heat) #define LL_IOC_HEAT_SET _IOW('f', 251, __u64) +#define LL_IOC_PCC_ATTACH _IOW('f', 252, struct lu_pcc_attach) #define LL_IOC_PCC_DETACH _IOW('f', 252, struct lu_pcc_detach) #define LL_IOC_PCC_DETACH_BY_FID _IOW('f', 252, struct lu_pcc_detach_fid) #define LL_IOC_PCC_STATE _IOR('f', 252, struct lu_pcc_state) @@ -1134,9 +1135,18 @@ struct lustre_foreign_type { **/ enum lustre_foreign_types { LU_FOREIGN_TYPE_NONE = 0, + /* HSM copytool lhsm_posix */ + LU_FOREIGN_TYPE_POSIX = 1, + /* Used for PCC-RW. PCCRW components are local to a single archive. */ + LU_FOREIGN_TYPE_PCCRW = 2, + /* Used for PCC-RO. PCCRO components may be shared between archives. */ + LU_FOREIGN_TYPE_PCCRO = 3, + /* Used for S3 */ + LU_FOREIGN_TYPE_S3 = 4, + /* Used for DAOS */ LU_FOREIGN_TYPE_SYMLINK = 0xda05, /* must be the max/last one */ - LU_FOREIGN_TYPE_UNKNOWN = 0xffffffff, + LU_FOREIGN_TYPE_UNKNOWN = 0xffffffff, }; extern struct lustre_foreign_type lu_foreign_types[]; @@ -2255,6 +2265,8 @@ enum hsm_states { HS_NORELEASE = 0x00000010, HS_NOARCHIVE = 0x00000020, HS_LOST = 0x00000040, + HS_PCCRW = 0x00000080, + HS_PCCRO = 0x00000100, }; /* HSM user-setable flags. */ @@ -2704,6 +2716,7 @@ enum lu_pcc_type { LU_PCC_READWRITE = 0x01, LU_PCC_READONLY = 0x02, LU_PCC_TYPE_MASK = LU_PCC_READWRITE | LU_PCC_READONLY, + LU_PCC_FL_ASYNC = 0x10, LU_PCC_MAX }; @@ -2747,6 +2760,8 @@ enum lu_pcc_state_flags { PCC_STATE_FL_ATTR_VALID = 0x01, /* The file is being attached into PCC */ PCC_STATE_FL_ATTACHING = 0x02, + /* The PCC copy is unlinked */ + PCC_STATE_FL_UNLINKED = 0x04, }; struct lu_pcc_state { diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index f476931..cb2c0cc 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -4900,6 +4900,10 @@ void lustre_assert_wire_constants(void) (long long)LAYOUT_INTENT_RELEASE); LASSERTF(LAYOUT_INTENT_RESTORE == 6, "found %lld\n", (long long)LAYOUT_INTENT_RESTORE); + LASSERTF(LAYOUT_INTENT_PCCRO_SET == 7, "found %lld\n", + (long long)LAYOUT_INTENT_PCCRO_SET); + LASSERTF(LAYOUT_INTENT_PCCRO_CLEAR == 8, "found %lld\n", + (long long)LAYOUT_INTENT_PCCRO_CLEAR); /* Checks for struct hsm_action_item */ LASSERTF((int)sizeof(struct hsm_action_item) == 72, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index d29067d..0724538 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -858,6 +858,29 @@ check_lov_mds_md_v3(void) } static void +check_lov_foreign_md(void) +{ + BLANK_LINE(); + CHECK_STRUCT(lov_foreign_md); + CHECK_MEMBER(lov_foreign_md, lfm_magic); + CHECK_MEMBER(lov_foreign_md, lfm_length); + CHECK_MEMBER(lov_foreign_md, lfm_type); + CHECK_MEMBER(lov_foreign_md, lfm_flags); + CHECK_MEMBER(lov_foreign_md, lfm_value[0]); + + CHECK_VALUE_X(LU_FOREIGN_TYPE_NONE); + CHECK_VALUE_X(LU_FOREIGN_TYPE_POSIX); + CHECK_VALUE_X(LU_FOREIGN_TYPE_PCCRW); + CHECK_VALUE_X(LU_FOREIGN_TYPE_PCCRO); + CHECK_VALUE_X(LU_FOREIGN_TYPE_S3); + CHECK_VALUE_X(LU_FOREIGN_TYPE_DAOS); + CHECK_VALUE_X(LU_FOREIGN_TYPE_UNKNOWN); + + CHECK_CDEFINE(LOV_MAGIC_FOREIGN); + CHECK_VALUE_X(LOV_PATTERN_FOREIGN); +} + +static void check_lov_comp_md_entry_v1(void) { BLANK_LINE(); @@ -2415,6 +2438,8 @@ static void check_layout_intent(void) CHECK_VALUE(LAYOUT_INTENT_TRUNC); CHECK_VALUE(LAYOUT_INTENT_RELEASE); CHECK_VALUE(LAYOUT_INTENT_RESTORE); + CHECK_VALUE(LAYOUT_INTENT_PCCRO_SET); + CHECK_VALUE(LAYOUT_INTENT_PCCRO_CLEAR); } static void check_hsm_state_set(void) @@ -3255,6 +3280,7 @@ main(int argc, char **argv) check_lov_ost_data_v1(); check_lov_mds_md_v1(); check_lov_mds_md_v3(); + check_lov_foreign_md(); check_lov_comp_md_entry_v1(); check_lov_comp_md_v1(); check_lmv_mds_md_v1(); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 31bda08..11667e8 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -1827,6 +1827,43 @@ void lustre_assert_wire_constants(void) LASSERTF(LOV_PATTERN_OVERSTRIPING == 0x00000200UL, "found 0x%.8xUL\n", (unsigned)LOV_PATTERN_OVERSTRIPING); + /* Checks for struct lov_foreign_md */ + LASSERTF((int)sizeof(struct lov_foreign_md) == 16, "found %lld\n", + (long long)(int)sizeof(struct lov_foreign_md)); + LASSERTF((int)offsetof(struct lov_foreign_md, lfm_magic) == 0, "found %lld\n", + (long long)(int)offsetof(struct lov_foreign_md, lfm_magic)); + LASSERTF((int)sizeof(((struct lov_foreign_md *)0)->lfm_magic) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lov_foreign_md *)0)->lfm_magic)); + LASSERTF((int)offsetof(struct lov_foreign_md, lfm_length) == 4, "found %lld\n", + (long long)(int)offsetof(struct lov_foreign_md, lfm_length)); + LASSERTF((int)sizeof(((struct lov_foreign_md *)0)->lfm_length) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lov_foreign_md *)0)->lfm_length)); + LASSERTF((int)offsetof(struct lov_foreign_md, lfm_type) == 8, "found %lld\n", + (long long)(int)offsetof(struct lov_foreign_md, lfm_type)); + LASSERTF((int)sizeof(((struct lov_foreign_md *)0)->lfm_type) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lov_foreign_md *)0)->lfm_type)); + LASSERTF((int)offsetof(struct lov_foreign_md, lfm_flags) == 12, "found %lld\n", + (long long)(int)offsetof(struct lov_foreign_md, lfm_flags)); + LASSERTF((int)sizeof(((struct lov_foreign_md *)0)->lfm_flags) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lov_foreign_md *)0)->lfm_flags)); + LASSERTF((int)offsetof(struct lov_foreign_md, lfm_value) == 16, "found %lld\n", + (long long)(int)offsetof(struct lov_foreign_md, lfm_value)); + LASSERTF(LU_FOREIGN_TYPE_NONE == 0, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_NONE); + LASSERTF(LU_FOREIGN_TYPE_POSIX == 1, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_POSIX); + LASSERTF(LU_FOREIGN_TYPE_PCCRW == 2, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_PCCRW); + LASSERTF(LU_FOREIGN_TYPE_PCCRO == 3, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_PCCRO); + LASSERTF(LU_FOREIGN_TYPE_S3 == 4, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_S3); + LASSERTF(LU_FOREIGN_TYPE_SYMLINK == 0x0000da05, "found 0x%.8xUL\n", + (unsigned)LU_FOREIGN_TYPE_SYMLINK); + BUILD_BUG_ON(LOV_MAGIC_FOREIGN != (0x0BD70000 | 0x0BD0)); + LASSERTF(LOV_PATTERN_FOREIGN == 0x00000400, "found 0x%.8xUL\n", + (unsigned)LOV_PATTERN_FOREIGN); + /* Checks for struct lov_comp_md_entry_v1 */ LASSERTF((int)sizeof(struct lov_comp_md_entry_v1) == 48, "found %lld\n", (long long)(int)sizeof(struct lov_comp_md_entry_v1)); @@ -4926,6 +4963,10 @@ void lustre_assert_wire_constants(void) (long long)LAYOUT_INTENT_RELEASE); LASSERTF(LAYOUT_INTENT_RESTORE == 6, "found %lld\n", (long long)LAYOUT_INTENT_RESTORE); + LASSERTF(LAYOUT_INTENT_PCCRO_SET == 7, "found %lld\n", + (long long)LAYOUT_INTENT_PCCRO_SET); + LASSERTF(LAYOUT_INTENT_PCCRO_CLEAR == 8, "found %lld\n", + (long long)LAYOUT_INTENT_PCCRO_CLEAR); /* Checks for struct hsm_action_item */ LASSERTF((int)sizeof(struct hsm_action_item) == 72, "found %lld\n", -- 1.8.3.1