From c8be6fafce0ed74ea3a8d6d41387bd6d1a8e215b Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Tue, 15 Nov 2022 01:57:08 -0500 Subject: [PATCH] LU-16313 pcc: use two bits to indicate pcc type for attach PCC currenty supports two types: readwrite and readonly. The attach data structure @lu_pcc_attach is using 32 bit value to indicate the PCC type: struct lu_pcc_attach { __u32 pcca_type; __u32 pcca_id; }; In this patch, it changes to use 2 bits to represent the PCC type. The left bits in @pcca_type can be used as flags for attach such as a flag to indicate using the asynchronous attach via the command "lfs pcc attach -A" for PCCRO. Lustre-change: https://review.whamcloud.com/49160 Lustre-commit: 6e90974b1f4ac24c5a5d45ecc9bdb4d47018dab4 Signed-off-by: Qian Yingjin Change-Id: Idee26018642a174b04d1d36a81952ea98a06514e Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49163 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/include/uapi/linux/lustre/lustre_user.h | 9 +++++---- lustre/utils/liblustreapi_pcc.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index b73c515..63460d7 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2720,15 +2720,16 @@ struct lu_heat { }; enum lu_pcc_type { - LU_PCC_NONE = 0, - LU_PCC_READWRITE = 1, - LU_PCC_READONLY = 2, + LU_PCC_NONE = 0x0, + LU_PCC_READWRITE = 0x01, + LU_PCC_READONLY = 0x02, + LU_PCC_TYPE_MASK = LU_PCC_READWRITE | LU_PCC_READONLY, LU_PCC_MAX }; static inline const char *pcc_type2string(enum lu_pcc_type type) { - switch (type) { + switch (type & LU_PCC_TYPE_MASK) { case LU_PCC_NONE: return "none"; case LU_PCC_READWRITE: diff --git a/lustre/utils/liblustreapi_pcc.c b/lustre/utils/liblustreapi_pcc.c index 13da70a..2a90ee3 100644 --- a/lustre/utils/liblustreapi_pcc.c +++ b/lustre/utils/liblustreapi_pcc.c @@ -154,7 +154,7 @@ int llapi_pcc_attach(const char *path, __u32 id, enum lu_pcc_type type) { int rc; - switch (type) { + switch (type & LU_PCC_TYPE_MASK) { case LU_PCC_READWRITE: rc = llapi_readwrite_pcc_attach(path, id); break; @@ -218,7 +218,7 @@ int llapi_pcc_attach_fid(const char *mntpath, const struct lu_fid *fid, { int rc; - switch (type) { + switch (type & LU_PCC_TYPE_MASK) { case LU_PCC_READWRITE: rc = llapi_readwrite_pcc_attach_fid(mntpath, fid, id); break; -- 1.8.3.1