From: Li Xi Date: Wed, 19 Oct 2016 00:36:04 +0000 (-0400) Subject: LU-8726 osd-ldiskfs: bypass read for benchmarking X-Git-Tag: 2.9.54~11 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5a6aa0e6d1583cc0d4c82ae8c95fb7b9856d6284;ds=sidebyside LU-8726 osd-ldiskfs: bypass read for benchmarking The read operation is bypassed, so that Lustre client could get more than 3GB/s on a single machine. This could be used when benchmarking client site performance, such as readahead. Signed-off-by: Li Xi Signed-off-by: Wang Shilong Change-Id: I518b287bf3c9b26347b43a4b82ef3114f966eb87 Reviewed-on: https://review.whamcloud.com/21648 Reviewed-by: Gu Zheng Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 4faba88..fdf2a3b 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -326,7 +326,7 @@ extern char obd_jobid_var[]; #define OBD_FAIL_OST_LADVISE_NET 0x235 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236 #define OBD_FAIL_OST_LADVISE_PAUSE 0x237 -#define OBD_FAIL_OST_FAKE_WRITE 0x238 +#define OBD_FAIL_OST_FAKE_RW 0x238 #define OBD_FAIL_LDLM 0x300 #define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index f1e9222..bd2da51 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -1047,7 +1047,7 @@ ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp, la->la_valid &= LA_ATIME | LA_MTIME | LA_CTIME; /* do fake write, to simulate the write case for performance testing */ - if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_WRITE)) { + if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_RW)) { struct niobuf_local *last = &lnb[niocount - 1]; __u64 file_size = last->lnb_file_offset + last->lnb_len; __u64 valid = la->la_valid; diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 7713af9..3434634 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1352,6 +1352,10 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, else lnb[i].lnb_rc = lnb[i].lnb_len; + /* Bypass disk read if fail_loc is set properly */ + if (OBD_FAIL_CHECK(OBD_FAIL_OST_FAKE_RW)) + SetPageUptodate(lnb[i].lnb_page); + if (PageUptodate(lnb[i].lnb_page)) { cache_hits++; } else { diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 41754a4..b389e68 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -15460,7 +15460,16 @@ test_313() { } run_test 313 "io should fail after last_rcvd update fail" -test_399() { # LU-7655 for OST fake write +test_fake_rw() { + local read_write=$1 + if [ "$read_write" = "write" ]; then + local dd_cmd="dd if=/dev/zero of=$DIR/$tfile" + elif [ "$read_write" = "read" ]; then + local dd_cmd="dd of=/dev/null if=$DIR/$tfile" + else + error "argument error" + fi + # turn off debug for performance testing local saved_debug=$($LCTL get_param -n debug) $LCTL set_param debug=0 @@ -15472,35 +15481,56 @@ test_399() { # LU-7655 for OST fake write local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum + if [ "$read_write" = "read" ]; then + truncate -s $(expr 1048576 \* $blocks) $DIR/$tfile + fi + local start_time=$(date +%s.%N) - dd if=/dev/zero of=$DIR/$tfile bs=1M count=$blocks oflag=sync || - error "real dd writing error" + $dd_cmd bs=1M count=$blocks oflag=sync || + error "real dd $read_write error" local duration=$(bc <<< "$(date +%s.%N) - $start_time") - rm -f $DIR/$tfile - # define OBD_FAIL_OST_FAKE_WRITE 0x238 + if [ "$read_write" = "write" ]; then + rm -f $DIR/$tfile + fi + + # define OBD_FAIL_OST_FAKE_RW 0x238 do_facet ost1 $LCTL set_param fail_loc=0x238 local start_time=$(date +%s.%N) - dd if=/dev/zero of=$DIR/$tfile bs=1M count=$blocks oflag=sync || - error "fake dd writing error" + $dd_cmd bs=1M count=$blocks oflag=sync || + error "fake dd $read_write error" local duration_fake=$(bc <<< "$(date +%s.%N) - $start_time") - # verify file size - cancel_lru_locks osc - $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile || - error "$tfile size not $blocks MB" - + if [ "$read_write" = "write" ]; then + # verify file size + cancel_lru_locks osc + $CHECKSTAT -t file -s $((blocks * 1024 * 1024)) $DIR/$tfile || + error "$tfile size not $blocks MB" + fi do_facet ost1 $LCTL set_param fail_loc=0 - echo "fake write $duration_fake vs. normal write $duration in seconds" + echo "fake $read_write $duration_fake vs. normal $read_write" \ + "$duration in seconds" [ $(bc <<< "$duration_fake < $duration") -eq 1 ] || error_not_in_vm "fake write is slower" $LCTL set_param -n debug="$saved_debug" rm -f $DIR/$tfile } -run_test 399 "fake write should not be slower than normal write" +test_399a() { # LU-7655 for OST fake write + test_fake_rw write +} +run_test 399a "fake write should not be slower than normal write" + + +test_399b() { # LU-8726 for OST fake read + if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then + skip "only for ldiskfs" && return 0 + fi + test_fake_rw read +} +run_test 399b "fake read should not be slower than normal read" test_400a() { # LU-1606, was conf-sanity test_74 local extra_flags=''