Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / ofd / ofd_io.c
index 0608cd9..bd2da51 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -542,7 +542,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
 
                oseq = ofd_seq_load(env, ofd, seq);
                if (IS_ERR(oseq)) {
-                       CERROR("%s: Can't find FID Sequence "LPX64": rc = %d\n",
+                       CERROR("%s: Can't find FID Sequence %#llx: rc = %d\n",
                               ofd_name(ofd), seq, (int)PTR_ERR(oseq));
                        GOTO(out, rc = -EINVAL);
                }
@@ -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;
@@ -1012,15 +1008,17 @@ 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 rc2 = 0;
+       int retries = 0;
+       int i;
+       bool soft_sync = false;
+       bool cb_registered = false;
+       bool fake_write = false;
 
        ENTRY;
 
@@ -1048,6 +1046,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_RW)) {
+               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 +1088,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 +1105,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);
@@ -1113,7 +1137,9 @@ out_stop:
                        granted = 0;
        }
 
-       ofd_trans_stop(env, ofd, th, rc);
+       rc2 = ofd_trans_stop(env, ofd, th, rc);
+       if (!rc)
+               rc = rc2;
        if (rc == -ENOSPC && retries++ < 3) {
                CDEBUG(D_INODE, "retry after force commit, retries:%d\n",
                       retries);