Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking 48/21648/10
authorLi Xi <lixi@ddn.com>
Wed, 19 Oct 2016 00:36:04 +0000 (20:36 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 9 Mar 2017 06:12:33 +0000 (06:12 +0000)
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 <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I518b287bf3c9b26347b43a4b82ef3114f966eb87
Reviewed-on: https://review.whamcloud.com/21648
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd_support.h
lustre/ofd/ofd_io.c
lustre/osd-ldiskfs/osd_io.c
lustre/tests/sanity.sh

index 4faba88..fdf2a3b 100644 (file)
@@ -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_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
 
 #define OBD_FAIL_LDLM                    0x300
 #define OBD_FAIL_LDLM_NAMESPACE_NEW      0x301
index f1e9222..bd2da51 100644 (file)
@@ -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 */
        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;
                struct niobuf_local *last = &lnb[niocount - 1];
                __u64 file_size = last->lnb_file_offset + last->lnb_len;
                __u64 valid = la->la_valid;
index 7713af9..3434634 100644 (file)
@@ -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;
 
                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 {
                if (PageUptodate(lnb[i].lnb_page)) {
                        cache_hits++;
                } else {
index 41754a4..b389e68 100755 (executable)
@@ -15460,7 +15460,16 @@ test_313() {
 }
 run_test 313 "io should fail after last_rcvd update fail"
 
 }
 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
        # 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
 
        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)
        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")
        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)
        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")
 
        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
 
        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
 }
        [ $(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=''
 
 test_400a() { # LU-1606, was conf-sanity test_74
        local extra_flags=''