* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2016, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
struct cl_page_list *qout = &queue->c2_qout;
unsigned int queued = 0;
int result = 0;
- int cmd;
int brw_flags;
unsigned int max_pages;
+ unsigned int ppc_bits; /* pages per chunk bits */
+ unsigned int ppc;
+ bool sync_queue = false;
LASSERT(qin->pl_nr > 0);
osc = cl2osc(ios->cis_obj);
cli = osc_cli(osc);
max_pages = cli->cl_max_pages_per_rpc;
+ ppc_bits = cli->cl_chunkbits - PAGE_SHIFT;
+ ppc = 1 << ppc_bits;
- cmd = crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
brw_flags = osc_io_srvlock(cl2osc_io(env, ios)) ? OBD_BRW_SRVLOCK : 0;
+ brw_flags |= crt == CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
+ if (crt == CRT_READ && ios->cis_io->ci_ndelay)
+ brw_flags |= OBD_BRW_NDELAY;
/*
* NOTE: here @page is a top-level page. This is done to avoid
else /* async IO */
cl_page_list_del(env, qin, page);
- if (++queued == max_pages) {
- queued = 0;
- result = osc_queue_sync_pages(env, osc, &list, cmd,
+ queued++;
+ if (queued == max_pages) {
+ sync_queue = true;
+ } else if (crt == CRT_WRITE) {
+ unsigned int chunks;
+ unsigned int next_chunks;
+
+ chunks = (queued + ppc - 1) >> ppc_bits;
+ /* chunk number if add another page */
+ next_chunks = (queued + ppc) >> ppc_bits;
+
+ /* next page will excceed write chunk limit */
+ if (chunks == osc_max_write_chunks(cli) &&
+ next_chunks > chunks)
+ sync_queue = true;
+ }
+
+ if (sync_queue) {
+ result = osc_queue_sync_pages(env, io, osc, &list,
brw_flags);
if (result < 0)
break;
+ queued = 0;
+ sync_queue = false;
}
}
if (queued > 0)
- result = osc_queue_sync_pages(env, osc, &list, cmd, brw_flags);
+ result = osc_queue_sync_pages(env, io, osc, &list, brw_flags);
/* Update c/mtime for sync write. LU-7310 */
if (crt == CRT_WRITE && qout->pl_nr > 0 && result == 0) {
EXPORT_SYMBOL(osc_io_submit);
/**
- * This is called when a page is accessed within file in a way that creates
- * new page, if one were missing (i.e., if there were a hole at that place in
- * the file, or accessed page is beyond the current file size).
+ * This is called to update the attributes when modifying a specific page,
+ * both when making new pages and when doing updates to existing cached pages.
*
* Expand stripe KMS if necessary.
*/
-static void osc_page_touch_at(const struct lu_env *env,
- struct cl_object *obj, pgoff_t idx, size_t to)
+void osc_page_touch_at(const struct lu_env *env, struct cl_object *obj,
+ pgoff_t idx, size_t to)
{
- struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
- struct cl_attr *attr = &osc_env_info(env)->oti_attr;
- int valid;
- __u64 kms;
+ struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ int valid;
+ __u64 kms;
- /* offset within stripe */
- kms = cl_offset(obj, idx) + to;
+ ENTRY;
- cl_object_attr_lock(obj);
- /*
- * XXX old code used
- *
- * ll_inode_size_lock(inode, 0); lov_stripe_lock(lsm);
- *
- * here
- */
+ /* offset within stripe */
+ kms = cl_offset(obj, idx) + to;
+
+ cl_object_attr_lock(obj);
CDEBUG(D_INODE, "stripe KMS %sincreasing %llu->%llu %llu\n",
- kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
- loi->loi_lvb.lvb_size);
+ kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
+ loi->loi_lvb.lvb_size);
attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
valid = CAT_MTIME | CAT_CTIME;
}
cl_object_attr_update(env, obj, attr, valid);
cl_object_attr_unlock(obj);
+
+ EXIT;
}
int osc_io_commit_async(const struct lu_env *env,
opg = osc_cl_page_osc(page, osc);
oap = &opg->ops_oap;
+ LASSERTF(osc == oap->oap_obj,
+ "obj mismatch: %p / %p\n", osc, oap->oap_obj);
+
if (!list_empty(&oap->oap_rpc_item)) {
CDEBUG(D_CACHE, "Busy oap %p page %p for submit.\n",
oap, opg);
struct obdo *oa = &oio->oi_oa;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
__u64 size = io->u.ci_setattr.sa_attr.lvb_size;
- unsigned int ia_valid = io->u.ci_setattr.sa_valid;
- int result = 0;
- ENTRY;
+ unsigned int ia_avalid = io->u.ci_setattr.sa_avalid;
+ enum op_xvalid ia_xvalid = io->u.ci_setattr.sa_xvalid;
+ int result = 0;
+ ENTRY;
/* truncate cache dirty pages first */
if (cl_io_is_trunc(io))
result = osc_cache_truncate_start(env, cl2osc(obj), size,
struct ost_lvb *lvb = &io->u.ci_setattr.sa_attr;
unsigned int cl_valid = 0;
- if (ia_valid & ATTR_SIZE) {
- attr->cat_size = attr->cat_kms = size;
+ if (ia_avalid & ATTR_SIZE) {
+ attr->cat_size = size;
+ attr->cat_kms = size;
cl_valid = (CAT_SIZE | CAT_KMS);
}
- if (ia_valid & ATTR_MTIME_SET) {
+ if (ia_avalid & ATTR_MTIME_SET) {
attr->cat_mtime = lvb->lvb_mtime;
cl_valid |= CAT_MTIME;
}
- if (ia_valid & ATTR_ATIME_SET) {
+ if (ia_avalid & ATTR_ATIME_SET) {
attr->cat_atime = lvb->lvb_atime;
cl_valid |= CAT_ATIME;
}
- if (ia_valid & ATTR_CTIME_SET) {
+ if (ia_xvalid & OP_XVALID_CTIME_SET) {
attr->cat_ctime = lvb->lvb_ctime;
cl_valid |= CAT_CTIME;
}
oa->o_layout = io->u.ci_setattr.sa_layout;
oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
OBD_MD_FLOSTLAYOUT;
- if (ia_valid & ATTR_CTIME) {
+ if (ia_avalid & ATTR_CTIME) {
oa->o_valid |= OBD_MD_FLCTIME;
oa->o_ctime = attr->cat_ctime;
}
- if (ia_valid & ATTR_ATIME) {
+ if (ia_avalid & ATTR_ATIME) {
oa->o_valid |= OBD_MD_FLATIME;
oa->o_atime = attr->cat_atime;
}
- if (ia_valid & ATTR_MTIME) {
+ if (ia_avalid & ATTR_MTIME) {
oa->o_valid |= OBD_MD_FLMTIME;
oa->o_mtime = attr->cat_mtime;
}
- if (ia_valid & ATTR_SIZE) {
- oa->o_size = size;
- oa->o_blocks = OBD_OBJECT_EOF;
- oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
-
- if (oio->oi_lockless) {
- oa->o_flags = OBD_FL_SRVLOCK;
- oa->o_valid |= OBD_MD_FLFLAGS;
- }
- } else {
- LASSERT(oio->oi_lockless == 0);
- }
+ if (ia_avalid & ATTR_SIZE) {
+ oa->o_size = size;
+ oa->o_blocks = OBD_OBJECT_EOF;
+ oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+
+ if (oio->oi_lockless) {
+ oa->o_flags = OBD_FL_SRVLOCK;
+ oa->o_valid |= OBD_MD_FLFLAGS;
+ }
+
+ if (io->ci_layout_version > 0) {
+ /* verify layout version */
+ oa->o_valid |= OBD_MD_LAYOUT_VERSION;
+ oa->o_layout_version = io->ci_layout_version;
+ }
+ } else {
+ LASSERT(oio->oi_lockless == 0);
+ }
- if (ia_valid & ATTR_ATTR_FLAG) {
+ if (ia_xvalid & OP_XVALID_FLAGS) {
oa->o_flags = io->u.ci_setattr.sa_attr_flags;
oa->o_valid |= OBD_MD_FLFLAGS;
}
init_completion(&cbargs->opc_sync);
- if (ia_valid & ATTR_SIZE)
+ if (ia_avalid & ATTR_SIZE)
result = osc_punch_send(osc_export(cl2osc(obj)),
oa, osc_async_upcall, cbargs);
else
struct osc_io *oio = cl2osc_io(env, slice);
struct cl_object *obj = slice->cis_obj;
struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
- int result = 0;
+ struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+ struct obdo *oa = &oio->oi_oa;
+ unsigned int cl_valid = 0;
+ int result = 0;
if (cbargs->opc_rpc_sent) {
wait_for_completion(&cbargs->opc_sync);
result = io->ci_result = cbargs->opc_rc;
}
- if (result == 0) {
- if (oio->oi_lockless) {
- /* lockless truncate */
- struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
-
- LASSERT(cl_io_is_trunc(io));
- /* XXX: Need a lock. */
- osd->od_stats.os_lockless_truncates++;
- }
- }
+
+ if (result == 0) {
+ if (oio->oi_lockless) {
+ /* lockless truncate */
+ struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
+
+ LASSERT(cl_io_is_trunc(io));
+ /* XXX: Need a lock. */
+ osd->od_stats.os_lockless_truncates++;
+ }
+ }
if (cl_io_is_trunc(io)) {
__u64 size = io->u.ci_setattr.sa_attr.lvb_size;
+ cl_object_attr_lock(obj);
+ if (oa->o_valid & OBD_MD_FLBLOCKS) {
+ attr->cat_blocks = oa->o_blocks;
+ cl_valid |= CAT_BLOCKS;
+ }
+
+ cl_object_attr_update(env, obj, attr, cl_valid);
+ cl_object_attr_unlock(obj);
osc_trunc_check(env, io, oio, size);
osc_cache_truncate_end(env, oio->oi_trunc);
oio->oi_trunc = NULL;
if (cbargs->opc_rc != 0) {
slice->cis_io->ci_result = cbargs->opc_rc;
- } else if (!(oio->oi_oa.o_valid & OBD_MD_FLDATAVERSION)) {
- slice->cis_io->ci_result = -EOPNOTSUPP;
} else {
- dv->dv_data_version = oio->oi_oa.o_data_version;
slice->cis_io->ci_result = 0;
+ if (!(oio->oi_oa.o_valid &
+ (OBD_MD_LAYOUT_VERSION | OBD_MD_FLDATAVERSION)))
+ slice->cis_io->ci_result = -ENOTSUPP;
+
+ if (oio->oi_oa.o_valid & OBD_MD_LAYOUT_VERSION)
+ dv->dv_layout_version = oio->oi_oa.o_layout_version;
+ if (oio->oi_oa.o_valid & OBD_MD_FLDATAVERSION)
+ dv->dv_data_version = oio->oi_oa.o_data_version;
}
EXIT;
}
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;
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)
RETURN(result);
}
-EXPORT_SYMBOL(osc_io_fsync_start);
void osc_io_fsync_end(const struct lu_env *env,
const struct cl_io_slice *slice)