Whamcloud - gitweb
LU-3285 mdc: implement own mdc_io_fsync_start() 13/29813/3
authorMikhal Pershin <mike.pershin@intel.com>
Thu, 26 Oct 2017 20:41:32 +0000 (23:41 +0300)
committerMike Pershin <mike.pershin@intel.com>
Mon, 30 Oct 2017 18:18:36 +0000 (18:18 +0000)
DoM lock cancelation may happen in llite and call
cl_sync_file_range() function to flush related data and
it uses DOM component end as limit for data to be flushed.
However related lock and extent are expanded to EOF and
this is asserted in osc_cache_writeback_range().
To avoid this a MDC uses own version of cio_start for FSYNC
and osc_cache_writeback_range() is called on whole DoM object
no matter what start/end are supplied by upper layers.

Test-Parameters: mdscount=1 mdtcount=1 mdssizegb=20 testlist=sanity-dom,dom-performance,racer
Signed-off-by: Mikhal Pershin <mike.pershin@intel.com>
Change-Id: I044faa95d3664a0448c21e9a2f1c2e5dd3a69cde
Reviewed-on: https://review.whamcloud.com/29813
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/lustre_osc.h
lustre/mdc/mdc_dev.c
lustre/osc/osc_io.c

index 0f23af7..aa7ab75 100644 (file)
@@ -684,8 +684,8 @@ int osc_io_read_start(const struct lu_env *env,
 int osc_io_write_start(const struct lu_env *env,
                       const struct cl_io_slice *slice);
 void osc_io_end(const struct lu_env *env, const struct cl_io_slice *slice);
-int osc_io_fsync_start(const struct lu_env *env,
-                      const struct cl_io_slice *slice);
+int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
+                 struct cl_fsync_io *fio);
 void osc_io_fsync_end(const struct lu_env *env,
                      const struct cl_io_slice *slice);
 void osc_read_ahead_release(const struct lu_env *env, void *cbdata);
index 3b37a40..d7e13ac 100644 (file)
@@ -1068,6 +1068,44 @@ static int mdc_io_read_ahead(const struct lu_env *env,
        RETURN(0);
 }
 
+int mdc_io_fsync_start(const struct lu_env *env,
+                      const struct cl_io_slice *slice)
+{
+       struct cl_io *io = slice->cis_io;
+       struct cl_fsync_io *fio = &io->u.ci_fsync;
+       struct cl_object *obj = slice->cis_obj;
+       struct osc_object *osc = cl2osc(obj);
+       int result = 0;
+
+       ENTRY;
+
+       /* a MDC lock always covers whole object, do sync for whole
+        * possible range despite of supplied start/end values.
+        */
+       result = osc_cache_writeback_range(env, osc, 0, CL_PAGE_EOF, 0,
+                                          fio->fi_mode == CL_FSYNC_DISCARD);
+       if (result > 0) {
+               fio->fi_nr_written += result;
+               result = 0;
+       }
+       if (fio->fi_mode == CL_FSYNC_ALL) {
+               int rc;
+
+               rc = osc_cache_wait_range(env, osc, 0, CL_PAGE_EOF);
+               if (result == 0)
+                       result = rc;
+               /* Use OSC sync code because it is asynchronous.
+                * It is to be added into MDC and avoid the using of
+                * OST_SYNC at both MDC and MDT.
+                */
+               rc = osc_fsync_ost(env, osc, fio);
+               if (result == 0)
+                       result = rc;
+       }
+
+       RETURN(result);
+}
+
 static struct cl_io_operations mdc_io_ops = {
        .op = {
                [CIT_READ] = {
@@ -1099,7 +1137,7 @@ static struct cl_io_operations mdc_io_ops = {
                        .cio_end       = osc_io_end,
                },
                [CIT_FSYNC] = {
-                       .cio_start = osc_io_fsync_start,
+                       .cio_start = mdc_io_fsync_start,
                        .cio_end   = osc_io_fsync_end,
                },
        },
index e959ae0..99733f3 100644 (file)
@@ -755,8 +755,8 @@ int osc_io_write_start(const struct lu_env *env,
 }
 EXPORT_SYMBOL(osc_io_write_start);
 
-static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
-                        struct cl_fsync_io *fio)
+int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
+                 struct cl_fsync_io *fio)
 {
        struct osc_io    *oio   = osc_env_io(env);
        struct obdo      *oa    = &oio->oi_oa;
@@ -781,6 +781,7 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
        rc = osc_sync_base(obj, oa, osc_async_upcall, cbargs, PTLRPCD_SET);
        RETURN(rc);
 }
+EXPORT_SYMBOL(osc_fsync_ost);
 
 int osc_io_fsync_start(const struct lu_env *env,
                       const struct cl_io_slice *slice)
@@ -821,7 +822,6 @@ int osc_io_fsync_start(const struct lu_env *env,
 
        RETURN(result);
 }
-EXPORT_SYMBOL(osc_io_fsync_start);
 
 void osc_io_fsync_end(const struct lu_env *env,
                      const struct cl_io_slice *slice)