Whamcloud - gitweb
LU-7655 tests: ost fake write for performance testing
[fs/lustre-release.git] / lustre / ofd / ofd_io.c
index 04445af..777a332 100644 (file)
@@ -631,10 +631,6 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                        lnb[j+k].lnb_flags = rnb[i].rnb_flags;
                        if (!(rnb[i].rnb_flags & OBD_BRW_GRANTED))
                                lnb[j+k].lnb_rc = -ENOSPC;
-
-                       /* remote client can't break through quota */
-                       if (exp_connect_rmtclient(exp))
-                               lnb[j+k].lnb_flags &= ~OBD_BRW_NOQUOTA;
                }
                j += rc;
                *nr_local += rc;
@@ -711,7 +707,7 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp,
 
        LASSERT(oa != NULL);
 
-       if (OBD_FAIL_CHECK(OBD_FAIL_OST_ENOENT)) {
+       if (OBD_FAIL_CHECK(OBD_FAIL_SRV_ENOENT)) {
                struct ofd_seq          *oseq;
 
                oseq = ofd_seq_load(env, ofd, ostid_seq(&oa->o_oi));
@@ -1012,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;
 
@@ -1048,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))
@@ -1068,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 */
@@ -1083,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);