From: Jinshan Xiong Date: Mon, 29 Aug 2016 05:45:33 +0000 (-0700) Subject: LU-7655 tests: ost fake write for performance testing X-Git-Tag: 2.8.58~29 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f003d3eebbad43e7f8371af663e67c6e56bf5d9a;ds=sidebyside LU-7655 tests: ost fake write for performance testing Just drop the pages in ofd_commitrw_write(), but we need to maintain correct file size and always create a transaction so client can pin those pages in memory until transaction commits. Signed-off-by: Jinshan Xiong Change-Id: Ia9a2af0a159c8969479656d3a7016db3cda71a91 Reviewed-on: http://review.whamcloud.com/5164 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 6dfd472..ee9d9ad 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -327,6 +327,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_LDLM 0x300 #define OBD_FAIL_LDLM_NAMESPACE_NEW 0x301 diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 3f6ff63..777a332 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -1008,15 +1008,16 @@ ofd_commitrw_write(const struct lu_env *env, struct obd_export *exp, int niocount, struct niobuf_local *lnb, unsigned long granted, int old_rc) { - struct ofd_object *fo; - struct dt_object *o; - struct thandle *th; - int rc = 0; - int retries = 0; - int i; struct filter_export_data *fed = &exp->exp_filter_data; - bool soft_sync = false; - bool cb_registered = false; + struct ofd_object *fo; + struct dt_object *o; + struct thandle *th; + int rc = 0; + int retries = 0; + int i; + bool soft_sync = false; + bool cb_registered = false; + bool fake_write = false; ENTRY; @@ -1044,6 +1045,28 @@ 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)) { + struct niobuf_local *last = &lnb[niocount - 1]; + __u64 file_size = last->lnb_file_offset + last->lnb_len; + __u64 valid = la->la_valid; + + la->la_valid = LA_SIZE; + la->la_size = 0; + rc = dt_attr_get(env, o, la); + if (rc < 0 && rc != -ENOENT) + GOTO(out, rc); + + if (file_size < la->la_size) + file_size = la->la_size; + + /* dirty inode by setting file size */ + la->la_valid = valid | LA_SIZE; + la->la_size = file_size; + + fake_write = true; + } + retry: th = ofd_trans_create(env, ofd); if (IS_ERR(th)) @@ -1064,9 +1087,11 @@ retry: if (OBD_FAIL_CHECK(OBD_FAIL_OST_DQACQ_NET)) GOTO(out_stop, rc = -EINPROGRESS); - rc = dt_declare_write_commit(env, o, lnb, niocount, th); - if (rc) - GOTO(out_stop, rc); + if (likely(!fake_write)) { + rc = dt_declare_write_commit(env, o, lnb, niocount, th); + if (rc) + GOTO(out_stop, rc); + } if (la->la_valid) { /* update [mac]time if needed */ @@ -1079,9 +1104,11 @@ retry: if (rc) GOTO(out_stop, rc); - rc = dt_write_commit(env, o, lnb, niocount, th); - if (rc) - GOTO(out_stop, rc); + if (likely(!fake_write)) { + rc = dt_write_commit(env, o, lnb, niocount, th); + if (rc) + GOTO(out_stop, rc); + } if (la->la_valid) { rc = dt_attr_set(env, o, la, th); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 37ce91c..34a1df4 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -15169,6 +15169,48 @@ test_312() { # LU-4856 } run_test 312 "make sure ZFS adjusts its block size by write pattern" +test_399() { # LU-7655 for OST fake write + # turn off debug for performance testing + local saved_debug=$($LCTL get_param -n debug) + $LCTL set_param debug=0 + + $SETSTRIPE -c 1 -i 0 $DIR/$tfile + + # get ost1 size - lustre-OST0000 + local ost1_avail_size=$($LFS df | awk /${ost1_svc}/'{ print $4 }') + local blocks=$((ost1_avail_size/2/1024)) # half avail space by megabytes + [ $blocks -gt 1000 ] && blocks=1000 # 1G in maximum + + local start_time=$(date +%s.%N) + dd if=/dev/zero of=$DIR/$tfile bs=1M count=$blocks oflag=sync || + error "real dd writing error" + local duration=$(bc <<< "$(date +%s.%N) - $start_time") + rm -f $DIR/$tfile + + # define OBD_FAIL_OST_FAKE_WRITE 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" + 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" + + do_facet ost1 $LCTL set_param fail_loc=0 + + echo "fake write $duration_fake vs. normal write $duration in seconds" + [ $(bc <<< "$duration_fake < $duration") -eq 1 ] || + error "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_400a() { # LU-1606, was conf-sanity test_74 local extra_flags='' local out=$TMP/$tfile