From: Qian Yingjin Date: Tue, 8 Jun 2021 09:54:49 +0000 (+0800) Subject: LU-10499 pcc: avoid to specify ID for every attach X-Git-Tag: 2.15.65~105 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F54414%2F6;p=fs%2Flustre-release.git LU-10499 pcc: avoid to specify ID for every attach In this patch, it avoids the need to specify "-i " for every attach as in the very common case there is only a single cache for that client. If attach ID is not specified, it will select the first dataset on the client as PCC backend. And the new format of PCC state is as follows: file: /mnt/lustre/f42.sanity-pcc, type: readonly, PCC_file: /d42.sanity-pcc/0402/0x200000401:0x3:0x0, open_count: 0, flags: 0 EX-3752 pcc: show attaching state for PCC state output When set llite.*.pcc_async_threshold=0, the client will do PCC attach in asynchronous way. When the file is large, attaching the file into PCC may take some time. In this patch, we improve that output of the PCC command "lfs pcc state" to show that the file is in PCC attaching state when the file is still in the phase of copying from Lustre OSTs to PCC. Was-Change-Id: I101d87638f5afac41fb4f55b4aaf95d938bc8ccd EX-bug-id: EX-3292 EX-3752 Signed-off-by: Qian Yingjin Change-Id: Icd23eda5dca4711f9bb7af940f6cef5ddb97ce69 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54414 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- diff --git a/lustre/llite/pcc.c b/lustre/llite/pcc.c index 0a0d062..a92080c 100644 --- a/lustre/llite/pcc.c +++ b/lustre/llite/pcc.c @@ -1073,20 +1073,20 @@ pcc_dataset_get(struct pcc_super *super, enum lu_pcc_type type, __u32 id) struct pcc_dataset *dataset; struct pcc_dataset *selected = NULL; - if (id == 0) - return NULL; - /* * archive ID (read-write ID) or read-only ID is unique in the list, * we just return last added one as first priority. + * @id == 0, it will select the first one as candidate dataset. */ down_read(&super->pccs_rw_sem); list_for_each_entry(dataset, &super->pccs_datasets, pccd_linkage) { - if (type == LU_PCC_READWRITE && (dataset->pccd_rwid != id || - !(dataset->pccd_flags & PCC_DATASET_PCCRW))) + if (type == LU_PCC_READWRITE && + (!(dataset->pccd_rwid == id || id == 0) || + !(dataset->pccd_flags & PCC_DATASET_PCCRW))) continue; - if (type == LU_PCC_READONLY && (dataset->pccd_roid != id || - !(dataset->pccd_flags & PCC_DATASET_PCCRO))) + if (type == LU_PCC_READONLY && + (!(dataset->pccd_roid == id || id == 0) || + !(dataset->pccd_flags & PCC_DATASET_PCCRO))) continue; atomic_inc(&dataset->pccd_refcount); selected = dataset; @@ -4135,6 +4135,7 @@ int pcc_ioctl_state(struct file *file, struct inode *inode, char *buf; char *path; int buf_len = sizeof(state->pccs_path); + struct ll_inode_info *lli = ll_i2info(inode); struct pcc_inode *pcci; ENTRY; @@ -4150,6 +4151,7 @@ int pcc_ioctl_state(struct file *file, struct inode *inode, pcci = ll_i2pcci(inode); if (pcci == NULL) { state->pccs_type = LU_PCC_NONE; + state->pccs_flags = lli->lli_pcc_state; GOTO(out_unlock, rc = 0); } @@ -4173,7 +4175,7 @@ int pcc_ioctl_state(struct file *file, struct inode *inode, state->pccs_type = pcci->pcci_type; state->pccs_open_count = count; - state->pccs_flags = ll_i2info(inode)->lli_pcc_state; + state->pccs_flags = lli->lli_pcc_state; path = dentry_path_raw(pcci->pcci_path.dentry, buf, buf_len); if (IS_ERR(path)) GOTO(out_unlock, rc = PTR_ERR(path)); diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index 01679a5..3bdc18f 100755 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -3334,6 +3334,27 @@ test_41() { } run_test 41 "Test mtime rule for PCC-RO open attach with O_RDONLY mode" +test_42() { + local loopfile="$TMP/$tfile" + local mntpt="/mnt/pcc.$tdir" + local hsm_root="$mntpt/$tdir" + local file=$DIR/$tfile + + setup_loopdev $SINGLEAGT $loopfile $mntpt 60 + do_facet $SINGLEAGT mkdir $hsm_root || error "mkdir $hsm_root failed" + setup_pcc_mapping $SINGLEAGT \ + "projid={100}\ roid=$HSM_ARCHIVE_NUMBER\ ropcc=1" + do_facet $SINGLEAGT $LCTL pcc list $MOUNT + + do_facet $SINGLEAGT echo -n attach_id_not_specified > $file || + error "Write $file failed" + do_facet $SINGLEAGT $LFS pcc attach -r $file || + error "PCC attach -r $file failed" + do_facet $SINGLEAGT $LFS pcc state $file + check_lpcc_state $file "readonly" +} +run_test 42 "PCC attach without attach ID specified" + test_96() { local loopfile="$TMP/$tfile" local mntpt="/mnt/pcc.$tdir" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index f779290..45faa08 100755 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -13662,11 +13662,6 @@ static int lfs_pcc_attach(int argc, char **argv) } } - if (attach_id == 0) { - fprintf(stderr, "%s: must specify attach ID\n", argv[0]); - return CMD_HELP; - } - if (argc <= optind) { fprintf(stderr, "%s: must specify one or more file names\n", argv[0]); @@ -13748,11 +13743,6 @@ static int lfs_pcc_attach_fid(int argc, char **argv) } } - if (attach_id == 0) { - fprintf(stderr, "%s: must specify an archive ID\n", argv[0]); - return CMD_HELP; - } - if (!mntpath) { fprintf(stderr, "%s: must specify Lustre mount point\n", argv[0]); @@ -13936,12 +13926,14 @@ static int lfs_pcc_state(int argc, char **argv) printf(", type: %s", pcc_type2string(state.pccs_type)); if (state.pccs_type == LU_PCC_NONE && state.pccs_open_count == 0) { + if (state.pccs_flags & PCC_STATE_FL_ATTACHING) + printf(", flags: attaching"); printf("\n"); continue; } - printf(", PCC file: %s", state.pccs_path); - printf(", user number: %u", state.pccs_open_count); + printf(", PCC_file: %s", state.pccs_path); + printf(", open_count: %u", state.pccs_open_count); printf(", flags: %x", state.pccs_flags); printf("\n"); }