}
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"
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" },