From 58aa84e785353edbc24bcc5242dd68a43acfc9e0 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Tue, 31 Aug 2021 11:45:25 +0800 Subject: [PATCH] EX-3730 pcc: add test for concurrent read from 2 clients This patch add a test case with concurrent read access from 2 clients. The purpose is to verify that the client will not re-attach file into PCC backend once attached when the file is read access concurrently from 2 mount points on a client according to the PCC attach stats. This patch also fixes the help message for PCC-RO. Signed-off-by: Qian Yingjin Change-Id: Ibb038bd3a74f43031b6fab4e65565620c416909e Reviewed-on: https://review.whamcloud.com/44791 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger --- lustre/tests/sanity-pcc.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++ lustre/utils/lfs.c | 13 +++++--- 2 files changed, 86 insertions(+), 5 deletions(-) diff --git a/lustre/tests/sanity-pcc.sh b/lustre/tests/sanity-pcc.sh index 106b526..a9381df 100644 --- a/lustre/tests/sanity-pcc.sh +++ b/lustre/tests/sanity-pcc.sh @@ -3413,6 +3413,84 @@ test_44() { } run_test 44 "Verify valid auto attach without re-fetching the whole files" +test_45() { + local loopfile="$TMP/$tfile" + local loopfile2="$TMP/$tfile.2" + local mntpt="/mnt/pcc.$tdir" + local mntpt2="/mnt/pcc.$tdir.2" + local file1=$DIR/$tfile + local file2=$DIR2/$tfile + local count=50 + local bs="1M" + + setup_loopdev client $loopfile $mntpt 60 + setup_loopdev client $loopfile2 $mntpt2 60 + stack_trap "$LCTL pcc clear $MOUNT" EXIT + $LCTL pcc add $MOUNT $mntpt -p \ + "projid={0} roid=$HSM_ARCHIVE_NUMBER ropcc=1" || + error "failed to config PCC for $MOUNT $mntpt" + stack_trap "$LCTL pcc clear $MOUNT2" EXIT + $LCTL pcc add $MOUNT2 $mntpt2 -p \ + "projid={0} roid=$HSM_ARCHIVE_NUMBER ropcc=1" || + error "failed to config PCC for $MOUNT2 $mntpt2" + $LCTL pcc list $MOUNT + $LCTL pcc list $MOUNT2 + + do_facet $SINGLEAGT $LCTL set_param llite.*.pcc_async_threshold=0 + + dd if=/dev/zero of=$file1 bs=$bs count=$count || + error "Write $file failed" + + local n=16 + local lpid + local -a pids1 + local -a pids2 + + $LFS getstripe -v $file + clear_stats llite.*.stats + + for ((i = 0; i < $n; i++)); do + ( + while [ ! -e $DIR/$tfile.lck ]; do + dd if=$file1 of=/dev/null bs=$bs count=$count || + error "Read $file failed" + sleep 0.$((RANDON % 4 + 1)) + done + )& + pids1[$i]=$! + done + + for ((i = 0; i < $n; i++)); do + ( + while [ ! -e $DIR/$tfile.lck ]; do + dd if=$file2 of=/dev/null bs=$bs count=$count || + error "Read $file failed" + sleep 0.$((RANDON % 4 + 1)) + done + )& + pids2[$i]=$! + done + + sleep 60 + touch $DIR/$tfile.lck + for ((i = 0; i < $n; i++)); do + wait ${pids1[$i]} || error "$?: read failed" + wait ${pids2[$i]} || error "$?: read failed" + done + + $LFS getstripe -v $file1 + $LCTL get_param llite.*.stats + + local attach_num=$(calc_stats llite.*.stats pcc_attach) + local detach_num=$(calc_stats llite.*.stats pcc_detach) + local autoat_num=$(calc_stats llite.*.stats pcc_auto_attach) + + echo "attach $attach_num detach $detach_num auto_attach $autoat_num" + [ $attach_num -eq 2 ] || error "attach more than 2 time: $attach_num" + rm -f $DIR/$tfile.lck +} +run_test 45 "Concurrent read access from two mount points" + test_96() { local loopfile="$TMP/$tfile" local mntpt="/mnt/pcc.$tdir" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 103db65..bbb13c3 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -374,14 +374,17 @@ command_t mirror_cmdlist[] = { command_t pcc_cmdlist[] = { { .pc_name = "attach", .pc_func = lfs_pcc_attach, .pc_help = "Attach given files to the Persistent Client Cache.\n" - "usage: lfs pcc attach <--id|-i NUM> ...\n" - "\t-i: archive id for RW-PCC\n" }, + "usage: lfs pcc attach [--readonly|-r] [--id|-i NUM] " + " ...\n" + "\t-i: archive id for RW-PCC\n" + "\t-r: readonly attach\n" }, { .pc_name = "attach_fid", .pc_func = lfs_pcc_attach_fid, .pc_help = "Attach given files into PCC by FID(s).\n" - "usage: lfs pcc attach_id <--id|-i NUM> <--mnt|-m mnt> " - " ...\n" + "usage: lfs pcc attach_id [--readonly|-r] [--id|-i NUM] " + "<--mnt|-m mnt> ...\n" "\t-i: archive id for RW-PCC\n" - "\t-m: Lustre mount point\n" }, + "\t-m: Lustre mount point\n" + "\t-r: readonly attach\n" }, { .pc_name = "state", .pc_func = lfs_pcc_state, .pc_help = "Display the PCC state for given files.\n" "usage: lfs pcc state ...\n" }, -- 1.8.3.1