@@ -676,8 +676,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);
@@ -1045,6 +1045,42 @@ 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;
+
+ /* 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] = {
@@ -1076,7 +1112,7 @@ static int mdc_io_read_ahead(const struct lu_env *env,
.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,
},
},
@@ -750,8 +750,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;
@@ -775,6 +775,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)
@@ -815,7 +816,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)