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;
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))
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 */
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);
}
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