*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* Implementation of cl_io for LOV layer.
*
*ext = (typeof(*ext)) { lio->lis_pos, lio->lis_endpos };
io->ci_need_write_intent = 0;
- if (!(io->ci_type == CIT_WRITE || cl_io_is_trunc(io) ||
- cl_io_is_mkwrite(io)))
+ if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
+ cl_io_is_fallocate(io) || cl_io_is_trunc(io)))
RETURN(0);
/*
CDEBUG(D_LAYOUT, "designated I/O mirror state: %d\n",
lov_flr_state(obj));
- if ((cl_io_is_trunc(io) || io->ci_type == CIT_WRITE) &&
+ if ((cl_io_is_trunc(io) || io->ci_type == CIT_WRITE ||
+ cl_io_is_fallocate(io)) &&
(io->ci_layout_version != obj->lo_lsm->lsm_layout_gen)) {
/*
* For resync I/O, the ci_layout_version was the layout
io->ci_result = 0;
lio->lis_object = obj;
+ lio->lis_cached_entry = LIS_CACHE_ENTRY_NONE;
switch (io->ci_type) {
case CIT_READ:
{
struct lov_io *lio = cl2lov_io(env, ios);
struct lov_object *lov = cl2lov(ios->cis_obj);
+ struct lov_io_sub *sub;
ENTRY;
-
LASSERT(list_empty(&lio->lis_active));
- while (!list_empty(&lio->lis_subios)) {
- struct lov_io_sub *sub = list_entry(lio->lis_subios.next,
- struct lov_io_sub,
- sub_list);
-
+ while ((sub = list_first_entry_or_null(&lio->lis_subios,
+ struct lov_io_sub,
+ sub_list)) != NULL) {
list_del_init(&sub->sub_list);
lio->lis_nr_subios--;
LASSERT(atomic_read(&lov->lo_active_ios) > 0);
if (atomic_dec_and_test(&lov->lo_active_ios))
- wake_up_all(&lov->lo_waitq);
+ wake_up(&lov->lo_waitq);
EXIT;
}
if (cl_io_is_fallocate(io)) {
io->u.ci_setattr.sa_falloc_offset = start;
io->u.ci_setattr.sa_falloc_end = end;
+ io->u.ci_setattr.sa_falloc_uid =
+ parent->u.ci_setattr.sa_falloc_uid;
+ io->u.ci_setattr.sa_falloc_gid =
+ parent->u.ci_setattr.sa_falloc_gid;
}
- if (cl_io_is_trunc(io) || cl_io_is_fallocate(io)) {
+ if (cl_io_is_trunc(io)) {
loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
new_size = lov_size_to_stripe(lsm, index, new_size,
{
int rc;
+ /* Before ending each i/o, we must set lis_cached_entry to tell the
+ * next i/o not to use stale cached lis information.
+ */
+ cl2lov_io(env, ios)->lis_cached_entry = LIS_CACHE_ENTRY_NONE;
+
rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_end_wrapper);
LASSERT(rc == 0);
}
RETURN(0);
}
+int lov_io_lru_reserve(const struct lu_env *env,
+ const struct cl_io_slice *ios, loff_t pos, size_t bytes)
+{
+ struct lov_io *lio = cl2lov_io(env, ios);
+ struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+ struct lov_io_sub *sub;
+ struct lu_extent ext;
+ int index;
+ int rc = 0;
+
+ ENTRY;
+
+ ext.e_start = pos;
+ ext.e_end = pos + bytes;
+ lov_foreach_io_layout(index, lio, &ext) {
+ struct lov_layout_entry *le = lov_entry(lio->lis_object, index);
+ struct lov_layout_raid0 *r0 = &le->lle_raid0;
+ u64 start;
+ u64 end;
+ int stripe;
+
+ if (!lsm_entry_inited(lsm, index))
+ continue;
+
+ if (!le->lle_valid && !ios->cis_io->ci_designated_mirror) {
+ CERROR(DFID": I/O to invalid component: %d, mirror: %d\n",
+ PFID(lu_object_fid(lov2lu(lio->lis_object))),
+ index, lio->lis_mirror_index);
+ RETURN(-EIO);
+ }
+
+ for (stripe = 0; stripe < r0->lo_nr; stripe++) {
+ if (!lov_stripe_intersects(lsm, index, stripe,
+ &ext, &start, &end))
+ continue;
+
+ if (unlikely(!r0->lo_sub[stripe]))
+ RETURN(-EIO);
+
+ sub = lov_sub_get(env, lio,
+ lov_comp_index(index, stripe));
+ if (IS_ERR(sub))
+ return PTR_ERR(sub);
+
+ rc = cl_io_lru_reserve(sub->sub_env, &sub->sub_io, start,
+ end - start + 1);
+ if (rc != 0)
+ RETURN(rc);
+ }
+ }
+
+ RETURN(0);
+}
+
/**
* lov implementation of cl_operations::cio_submit() method. It takes a list
* of pages in \a queue, splits it into per-stripe sub-lists, invokes
struct lov_io *lio = cl2lov_io(env, ios);
struct lov_io_sub *sub;
struct cl_page_list *plist = &lov_env_info(env)->lti_plist;
- struct cl_page *page;
+ struct cl_page *page = cl_page_list_first(qin);
struct cl_page *tmp;
+ bool dio = false;
int index;
int rc = 0;
ENTRY;
+ if (page->cp_type == CPT_TRANSIENT)
+ dio = true;
+
cl_page_list_init(plist);
while (qin->pl_nr > 0) {
struct cl_2queue *cl2q = &lov_env_info(env)->lti_cl2q;
cl_page_list_move(&cl2q->c2_qin, qin, page);
index = page->cp_lov_index;
- cl_page_list_for_each_safe(page, tmp, qin) {
- /* this page is not on this stripe */
- if (index != page->cp_lov_index)
- continue;
-
- cl_page_list_move(&cl2q->c2_qin, qin, page);
+ /* DIO is already split by stripe */
+ if (!dio) {
+ cl_page_list_for_each_safe(page, tmp, qin) {
+ /* this page is not on this stripe */
+ if (index != page->cp_lov_index)
+ continue;
+
+ cl_page_list_move(&cl2q->c2_qin, qin, page);
+ }
+ } else {
+ cl_page_list_splice(qin, &cl2q->c2_qin);
}
sub = lov_sub_get(env, lio, index);
struct cl_fault_io *fio;
struct lov_io *lio;
struct lov_io_sub *sub;
+ loff_t offset;
+ int entry;
+ int stripe;
ENTRY;
fio = &ios->cis_io->u.ci_fault;
lio = cl2lov_io(env, ios);
+
+ /**
+ * LU-14502: ft_page could be an existing cl_page associated with
+ * the vmpage covering the fault index, and the page may still
+ * refer to another mirror of an old IO.
+ */
+ if (lov_is_flr(lio->lis_object)) {
+ offset = cl_offset(ios->cis_obj, fio->ft_index);
+ entry = lov_io_layout_at(lio, offset);
+ if (entry < 0) {
+ CERROR(DFID": page fault index %lu invalid component: "
+ "%d, mirror: %d\n",
+ PFID(lu_object_fid(&ios->cis_obj->co_lu)),
+ fio->ft_index, entry,
+ lio->lis_mirror_index);
+ RETURN(-EIO);
+ }
+ stripe = lov_stripe_number(lio->lis_object->lo_lsm,
+ entry, offset);
+
+ if (fio->ft_page->cp_lov_index !=
+ lov_comp_index(entry, stripe)) {
+ CDEBUG(D_INFO, DFID": page fault at index %lu, "
+ "at mirror %u comp entry %u stripe %u, "
+ "been used with comp entry %u stripe %u\n",
+ PFID(lu_object_fid(&ios->cis_obj->co_lu)),
+ fio->ft_index, lio->lis_mirror_index,
+ entry, stripe,
+ lov_comp_entry(fio->ft_page->cp_lov_index),
+ lov_comp_stripe(fio->ft_page->cp_lov_index));
+
+ fio->ft_page->cp_lov_index =
+ lov_comp_index(entry, stripe);
+ }
+ }
+
sub = lov_sub_get(env, lio, fio->ft_page->cp_lov_index);
sub->sub_io.u.ci_fault.ft_nob = fio->ft_nob;
RETURN(lov_io_start(env, ios));
}
+static int lov_io_setattr_start(const struct lu_env *env,
+ const struct cl_io_slice *ios)
+{
+ struct lov_io *lio = cl2lov_io(env, ios);
+ struct cl_io *parent = ios->cis_io;
+ struct lov_io_sub *sub;
+ struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+
+ ENTRY;
+
+ if (cl_io_is_fallocate(parent)) {
+ list_for_each_entry(sub, &lio->lis_active, sub_linkage) {
+ loff_t size = parent->u.ci_setattr.sa_attr.lvb_size;
+ int index = lov_comp_entry(sub->sub_subio_index);
+ int stripe = lov_comp_stripe(sub->sub_subio_index);
+
+ size = lov_size_to_stripe(lsm, index, size, stripe);
+ sub->sub_io.u.ci_setattr.sa_attr.lvb_size = size;
+ sub->sub_io.u.ci_setattr.sa_avalid =
+ parent->u.ci_setattr.sa_avalid;
+ }
+ }
+
+ RETURN(lov_io_start(env, ios));
+}
+
static void lov_io_fsync_end(const struct lu_env *env,
const struct cl_io_slice *ios)
{
.cio_iter_fini = lov_io_iter_fini,
.cio_lock = lov_io_lock,
.cio_unlock = lov_io_unlock,
- .cio_start = lov_io_start,
+ .cio_start = lov_io_setattr_start,
.cio_end = lov_io_end
},
[CIT_DATA_VERSION] = {
}
},
.cio_read_ahead = lov_io_read_ahead,
+ .cio_lru_reserve = lov_io_lru_reserve,
.cio_submit = lov_io_submit,
.cio_commit_async = lov_io_commit_async,
};
ENTRY;
if (atomic_dec_and_test(&lov->lo_active_ios))
- wake_up_all(&lov->lo_waitq);
+ wake_up(&lov->lo_waitq);
EXIT;
}