Whamcloud - gitweb
LU-9771 osp: no delay commit callback for layout version 00/30000/10
authorJinshan Xiong <jinshan.xiong@intel.com>
Wed, 8 Nov 2017 23:30:44 +0000 (23:30 +0000)
committerJinshan Xiong <jinshan.xiong@intel.com>
Fri, 24 Nov 2017 03:11:05 +0000 (03:11 +0000)
OSP batches commit callback by one second interval. However, this
mechanism would cause problem to FLR because the clients has to
wait up to one second before they are able to write OST objects.

This patch registers immediate commit callback if the SETATTR is
for layout version. It also cleans up the code a little bit.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I5fa0fea9a8c8b23379118609bee9a36f412a191d
Reviewed-on: https://review.whamcloud.com/30000
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/osp/osp_internal.h
lustre/osp/osp_sync.c

index 74dc8f8..0b78530 100644 (file)
@@ -816,8 +816,6 @@ int osp_sync_init(const struct lu_env *env, struct osp_device *d);
 int osp_sync_fini(struct osp_device *d);
 void osp_sync_check_for_work(struct osp_device *osp);
 void osp_sync_force(const struct lu_env *env, struct osp_device *d);
-int osp_sync_add_commit_cb(const struct lu_env *env, struct osp_device *d,
-                          struct thandle *th);
 int osp_sync_add_commit_cb_1s(const struct lu_env *env, struct osp_device *d,
                              struct thandle *th);
 
index 47ec49c..f11d9bc 100644 (file)
@@ -95,6 +95,9 @@ struct osp_job_req_args {
        __u32                           jra_magic;
 };
 
+static int osp_sync_add_commit_cb(const struct lu_env *env,
+                                 struct osp_device *d, struct thandle *th);
+
 static inline int osp_sync_running(struct osp_device *d)
 {
        return !!(d->opd_sync_thread.t_flags & SVC_RUNNING);
@@ -349,28 +352,6 @@ int osp_sync_declare_add(const struct lu_env *env, struct osp_object *o,
        RETURN(rc);
 }
 
-/* add the commit callback every second */
-int osp_sync_add_commit_cb_1s(const struct lu_env *env, struct osp_device *d,
-                             struct thandle *th)
-{
-       int add = 0;
-
-       /* fast path */
-       if (cfs_time_before(cfs_time_current(), d->opd_sync_next_commit_cb))
-               return 0;
-
-       spin_lock(&d->opd_sync_lock);
-       if (cfs_time_aftereq(cfs_time_current(), d->opd_sync_next_commit_cb))
-               add = 1;
-       d->opd_sync_next_commit_cb = cfs_time_shift(1);
-       spin_unlock(&d->opd_sync_lock);
-
-       if (add == 0)
-               return 0;
-       return osp_sync_add_commit_cb(env, d, th);
-}
-
-
 /**
  * Generate a llog record for a given change.
  *
@@ -400,6 +381,7 @@ static int osp_sync_add_rec(const struct lu_env *env, struct osp_device *d,
        struct osp_thread_info  *osi = osp_env_info(env);
        struct llog_ctxt        *ctxt;
        struct thandle          *storage_th;
+       bool                     immediate_commit_cb = false;
        int                      rc;
 
        ENTRY;
@@ -433,8 +415,14 @@ static int osp_sync_add_rec(const struct lu_env *env, struct osp_device *d,
                        ((attr->la_valid & LA_UID) ? OBD_MD_FLUID : 0) |
                        ((attr->la_valid & LA_GID) ? OBD_MD_FLGID : 0) |
                        ((attr->la_valid & LA_PROJID) ? OBD_MD_FLPROJID : 0);
-               if (attr->la_valid & LA_LAYOUT_VERSION)
+               if (attr->la_valid & LA_LAYOUT_VERSION) {
                        osi->osi_setattr.lsr_valid |= OBD_MD_LAYOUT_VERSION;
+
+                       /* FLR: the layout version has to be transferred to
+                        * OST objects ASAP, otherwise clients will have to
+                        * experience delay to be able to write OST objects. */
+                       immediate_commit_cb = true;
+               }
                break;
        default:
                LBUG();
@@ -464,7 +452,10 @@ static int osp_sync_add_rec(const struct lu_env *env, struct osp_device *d,
                atomic_inc(&d->opd_sync_changes);
        }
 
-       rc = osp_sync_add_commit_cb_1s(env, d, th);
+       if (immediate_commit_cb)
+               rc = osp_sync_add_commit_cb(env, d, th);
+       else
+               rc = osp_sync_add_commit_cb_1s(env, d, th);
 
        /* return 0 always here, error case just cause no llog record */
        RETURN(0);
@@ -1567,8 +1558,8 @@ void osp_sync_local_commit_cb(struct lu_env *env, struct thandle *th,
        OBD_FREE_PTR(cb);
 }
 
-int osp_sync_add_commit_cb(const struct lu_env *env, struct osp_device *d,
-                          struct thandle *th)
+static int osp_sync_add_commit_cb(const struct lu_env *env,
+                                 struct osp_device *d, struct thandle *th)
 {
        struct osp_last_committed_cb    *cb;
        struct dt_txn_commit_cb         *dcb;
@@ -1598,6 +1589,29 @@ int osp_sync_add_commit_cb(const struct lu_env *env, struct osp_device *d,
        return rc;
 }
 
+/* add the commit callback every second */
+int osp_sync_add_commit_cb_1s(const struct lu_env *env, struct osp_device *d,
+                             struct thandle *th)
+{
+       bool add = false;
+
+       /* fast path */
+       if (cfs_time_before(cfs_time_current(), d->opd_sync_next_commit_cb))
+               return 0;
+
+       spin_lock(&d->opd_sync_lock);
+       if (cfs_time_aftereq(cfs_time_current(), d->opd_sync_next_commit_cb)) {
+               add = true;
+               d->opd_sync_next_commit_cb = cfs_time_shift(1);
+       }
+       spin_unlock(&d->opd_sync_lock);
+
+       if (!add)
+               return 0;
+
+       return osp_sync_add_commit_cb(env, d, th);
+}
+
 /*
  * generate an empty transaction and hook the commit callback in
  * then force transaction commit