Whamcloud - gitweb
EX-3730 pcc: add test for concurrent read from 2 clients
authorQian Yingjin <qian@ddn.com>
Tue, 31 Aug 2021 03:45:25 +0000 (11:45 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 1 Sep 2021 15:30:24 +0000 (15:30 +0000)
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 <qian@ddn.com>
Change-Id: Ibb038bd3a74f43031b6fab4e65565620c416909e
Reviewed-on: https://review.whamcloud.com/44791
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/sanity-pcc.sh
lustre/utils/lfs.c

index 106b526..a9381df 100644 (file)
@@ -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"
index 103db65..bbb13c3 100644 (file)
@@ -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> <file> ...\n"
-               "\t-i: archive id for RW-PCC\n" },
+               "usage: lfs pcc attach [--readonly|-r] [--id|-i NUM] "
+               "<file> ...\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> "
-               "<fid> ...\n"
+               "usage: lfs pcc attach_id [--readonly|-r] [--id|-i NUM] "
+               "<--mnt|-m mnt> <fid> ...\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 <file> ...\n" },