4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * Implementation of cl_io for LOV layer.
34 * Author: Nikita Danilov <nikita.danilov@sun.com>
35 * Author: Jinshan Xiong <jinshan.xiong@whamcloud.com>
38 #define DEBUG_SUBSYSTEM S_LOV
40 #include "lov_cl_internal.h"
46 static inline void lov_sub_enter(struct lov_io_sub *sub)
51 static inline void lov_sub_exit(struct lov_io_sub *sub)
56 static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
57 struct lov_io_sub *sub)
60 if (sub->sub_io_initialized) {
62 cl_io_fini(sub->sub_env, sub->sub_io);
64 sub->sub_io_initialized = 0;
65 lio->lis_active_subios--;
67 if (sub->sub_stripe == lio->lis_single_subio_index)
68 lio->lis_single_subio_index = -1;
69 else if (!sub->sub_borrowed)
73 if (!IS_ERR_OR_NULL(sub->sub_env)) {
74 if (!sub->sub_borrowed)
75 cl_env_put(sub->sub_env, &sub->sub_refcheck);
80 static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio,
81 int stripe, loff_t start, loff_t end)
83 struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
84 struct cl_io *parent = lio->lis_cl.cis_io;
86 switch (io->ci_type) {
88 io->u.ci_setattr.sa_attr = parent->u.ci_setattr.sa_attr;
89 io->u.ci_setattr.sa_valid = parent->u.ci_setattr.sa_valid;
90 io->u.ci_setattr.sa_stripe_index = stripe;
91 io->u.ci_setattr.sa_parent_fid =
92 parent->u.ci_setattr.sa_parent_fid;
93 if (cl_io_is_trunc(io)) {
94 loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
96 new_size = lov_size_to_stripe(lsm, new_size, stripe);
97 io->u.ci_setattr.sa_attr.lvb_size = new_size;
102 struct cl_object *obj = parent->ci_obj;
103 loff_t off = cl_offset(obj, parent->u.ci_fault.ft_index);
105 io->u.ci_fault = parent->u.ci_fault;
106 off = lov_size_to_stripe(lsm, off, stripe);
107 io->u.ci_fault.ft_index = cl_index(obj, off);
111 io->u.ci_fsync.fi_start = start;
112 io->u.ci_fsync.fi_end = end;
113 io->u.ci_fsync.fi_fid = parent->u.ci_fsync.fi_fid;
114 io->u.ci_fsync.fi_mode = parent->u.ci_fsync.fi_mode;
119 io->u.ci_wr.wr_sync = cl_io_is_sync_write(parent);
120 if (cl_io_is_append(parent)) {
121 io->u.ci_wr.wr_append = 1;
123 io->u.ci_rw.crw_pos = start;
124 io->u.ci_rw.crw_count = end - start;
133 static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
134 struct lov_io_sub *sub)
136 struct lov_object *lov = lio->lis_object;
137 struct lov_device *ld = lu2lov_dev(lov2cl(lov)->co_lu.lo_dev);
138 struct cl_io *sub_io;
139 struct cl_object *sub_obj;
140 struct cl_io *io = lio->lis_cl.cis_io;
142 int stripe = sub->sub_stripe;
145 LASSERT(!sub->sub_io);
146 LASSERT(!sub->sub_env);
147 LASSERT(sub->sub_stripe < lio->lis_stripe_count);
149 if (unlikely(!lov_r0(lov)->lo_sub[stripe]))
153 sub->sub_io_initialized = 0;
154 sub->sub_borrowed = 0;
156 if (lio->lis_mem_frozen) {
157 LASSERT(mutex_is_locked(&ld->ld_mutex));
158 sub->sub_io = &ld->ld_emrg[stripe]->emrg_subio;
159 sub->sub_env = ld->ld_emrg[stripe]->emrg_env;
160 sub->sub_borrowed = 1;
164 /* obtain new environment */
165 cookie = cl_env_reenter();
166 sub->sub_env = cl_env_get(&sub->sub_refcheck);
167 cl_env_reexit(cookie);
168 if (IS_ERR(sub->sub_env))
169 result = PTR_ERR(sub->sub_env);
173 * First sub-io. Use ->lis_single_subio to
174 * avoid dynamic allocation.
176 if (lio->lis_active_subios == 0) {
177 sub->sub_io = &lio->lis_single_subio;
178 lio->lis_single_subio_index = stripe;
180 sub->sub_io = kzalloc(sizeof(*sub->sub_io),
189 sub_obj = lovsub2cl(lov_r0(lov)->lo_sub[stripe]);
190 sub_io = sub->sub_io;
192 sub_io->ci_obj = sub_obj;
193 sub_io->ci_result = 0;
195 sub_io->ci_parent = io;
196 sub_io->ci_lockreq = io->ci_lockreq;
197 sub_io->ci_type = io->ci_type;
198 sub_io->ci_no_srvlock = io->ci_no_srvlock;
199 sub_io->ci_noatime = io->ci_noatime;
202 result = cl_io_sub_init(sub->sub_env, sub_io,
203 io->ci_type, sub_obj);
206 lio->lis_active_subios++;
207 sub->sub_io_initialized = 1;
212 lov_io_sub_fini(env, lio, sub);
216 struct lov_io_sub *lov_sub_get(const struct lu_env *env,
217 struct lov_io *lio, int stripe)
220 struct lov_io_sub *sub = &lio->lis_subs[stripe];
222 LASSERT(stripe < lio->lis_stripe_count);
224 if (!sub->sub_io_initialized) {
225 sub->sub_stripe = stripe;
226 rc = lov_io_sub_init(env, lio, sub);
237 void lov_sub_put(struct lov_io_sub *sub)
242 /*****************************************************************************
248 int lov_page_stripe(const struct cl_page *page)
250 const struct cl_page_slice *slice;
252 slice = cl_page_at(page, &lov_device_type);
253 LASSERT(slice->cpl_obj);
255 return cl2lov_page(slice)->lps_stripe;
258 struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio,
259 const struct cl_page_slice *slice)
261 struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
262 struct cl_page *page = slice->cpl_page;
265 LASSERT(lio->lis_cl.cis_io);
266 LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object);
268 LASSERT(lio->lis_nr_subios > 0);
270 stripe = lov_page_stripe(page);
271 return lov_sub_get(env, lio, stripe);
274 static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
277 struct lov_stripe_md *lsm;
280 LASSERT(lio->lis_object);
281 lsm = lio->lis_object->lo_lsm;
284 * Need to be optimized, we can't afford to allocate a piece of memory
285 * when writing a page. -jay
288 libcfs_kvzalloc(lsm->lsm_stripe_count *
289 sizeof(lio->lis_subs[0]),
292 lio->lis_nr_subios = lio->lis_stripe_count;
293 lio->lis_single_subio_index = -1;
294 lio->lis_active_subios = 0;
302 static int lov_io_slice_init(struct lov_io *lio, struct lov_object *obj,
306 lio->lis_object = obj;
308 lio->lis_stripe_count = obj->lo_lsm->lsm_stripe_count;
310 switch (io->ci_type) {
313 lio->lis_pos = io->u.ci_rw.crw_pos;
314 lio->lis_endpos = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count;
315 lio->lis_io_endpos = lio->lis_endpos;
316 if (cl_io_is_append(io)) {
317 LASSERT(io->ci_type == CIT_WRITE);
320 * If there is LOV EA hole, then we may cannot locate
321 * the current file-tail exactly.
323 if (unlikely(obj->lo_lsm->lsm_pattern &
328 lio->lis_endpos = OBD_OBJECT_EOF;
333 if (cl_io_is_trunc(io))
334 lio->lis_pos = io->u.ci_setattr.sa_attr.lvb_size;
337 lio->lis_endpos = OBD_OBJECT_EOF;
341 pgoff_t index = io->u.ci_fault.ft_index;
343 lio->lis_pos = cl_offset(io->ci_obj, index);
344 lio->lis_endpos = cl_offset(io->ci_obj, index + 1);
349 lio->lis_pos = io->u.ci_fsync.fi_start;
350 lio->lis_endpos = io->u.ci_fsync.fi_end;
356 lio->lis_endpos = OBD_OBJECT_EOF;
365 static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
367 struct lov_io *lio = cl2lov_io(env, ios);
368 struct lov_object *lov = cl2lov(ios->cis_obj);
372 for (i = 0; i < lio->lis_nr_subios; i++)
373 lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
374 kvfree(lio->lis_subs);
375 lio->lis_nr_subios = 0;
378 LASSERT(atomic_read(&lov->lo_active_ios) > 0);
379 if (atomic_dec_and_test(&lov->lo_active_ios))
380 wake_up_all(&lov->lo_waitq);
383 static u64 lov_offset_mod(u64 val, int delta)
385 if (val != OBD_OBJECT_EOF)
390 static int lov_io_iter_init(const struct lu_env *env,
391 const struct cl_io_slice *ios)
393 struct lov_io *lio = cl2lov_io(env, ios);
394 struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
395 struct lov_io_sub *sub;
402 endpos = lov_offset_mod(lio->lis_endpos, -1);
403 for (stripe = 0; stripe < lio->lis_stripe_count; stripe++) {
404 if (!lov_stripe_intersects(lsm, stripe, lio->lis_pos,
405 endpos, &start, &end))
408 if (unlikely(!lov_r0(lio->lis_object)->lo_sub[stripe])) {
409 if (ios->cis_io->ci_type == CIT_READ ||
410 ios->cis_io->ci_type == CIT_WRITE ||
411 ios->cis_io->ci_type == CIT_FAULT)
417 end = lov_offset_mod(end, 1);
418 sub = lov_sub_get(env, lio, stripe);
420 lov_io_sub_inherit(sub->sub_io, lio, stripe,
422 rc = cl_io_iter_init(sub->sub_env, sub->sub_io);
424 CDEBUG(D_VFSTRACE, "shrink: %d [%llu, %llu)\n",
431 list_add_tail(&sub->sub_linkage, &lio->lis_active);
438 static int lov_io_rw_iter_init(const struct lu_env *env,
439 const struct cl_io_slice *ios)
441 struct lov_io *lio = cl2lov_io(env, ios);
442 struct cl_io *io = ios->cis_io;
443 struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
444 __u64 start = io->u.ci_rw.crw_pos;
446 unsigned long ssize = lsm->lsm_stripe_size;
448 LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE);
450 /* fast path for common case. */
451 if (lio->lis_nr_subios != 1 && !cl_io_is_append(io)) {
452 lov_do_div64(start, ssize);
453 next = (start + 1) * ssize;
454 if (next <= start * ssize)
457 io->ci_continue = next < lio->lis_io_endpos;
458 io->u.ci_rw.crw_count = min_t(loff_t, lio->lis_io_endpos,
459 next) - io->u.ci_rw.crw_pos;
460 lio->lis_pos = io->u.ci_rw.crw_pos;
461 lio->lis_endpos = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count;
462 CDEBUG(D_VFSTRACE, "stripe: %llu chunk: [%llu, %llu) %llu\n",
463 (__u64)start, lio->lis_pos, lio->lis_endpos,
464 (__u64)lio->lis_io_endpos);
467 * XXX The following call should be optimized: we know, that
468 * [lio->lis_pos, lio->lis_endpos) intersects with exactly one stripe.
470 return lov_io_iter_init(env, ios);
473 static int lov_io_call(const struct lu_env *env, struct lov_io *lio,
474 int (*iofunc)(const struct lu_env *, struct cl_io *))
476 struct cl_io *parent = lio->lis_cl.cis_io;
477 struct lov_io_sub *sub;
480 list_for_each_entry(sub, &lio->lis_active, sub_linkage) {
482 rc = iofunc(sub->sub_env, sub->sub_io);
487 if (parent->ci_result == 0)
488 parent->ci_result = sub->sub_io->ci_result;
493 static int lov_io_lock(const struct lu_env *env, const struct cl_io_slice *ios)
495 return lov_io_call(env, cl2lov_io(env, ios), cl_io_lock);
498 static int lov_io_start(const struct lu_env *env, const struct cl_io_slice *ios)
500 return lov_io_call(env, cl2lov_io(env, ios), cl_io_start);
503 static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io)
506 * It's possible that lov_io_start() wasn't called against this
507 * sub-io, either because previous sub-io failed, or upper layer
510 if (io->ci_state == CIS_IO_GOING)
513 io->ci_state = CIS_IO_FINISHED;
517 static int lov_io_iter_fini_wrapper(const struct lu_env *env, struct cl_io *io)
519 cl_io_iter_fini(env, io);
523 static int lov_io_unlock_wrapper(const struct lu_env *env, struct cl_io *io)
525 cl_io_unlock(env, io);
529 static void lov_io_end(const struct lu_env *env, const struct cl_io_slice *ios)
533 rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_end_wrapper);
537 static void lov_io_iter_fini(const struct lu_env *env,
538 const struct cl_io_slice *ios)
540 struct lov_io *lio = cl2lov_io(env, ios);
543 rc = lov_io_call(env, lio, lov_io_iter_fini_wrapper);
545 while (!list_empty(&lio->lis_active))
546 list_del_init(lio->lis_active.next);
549 static void lov_io_unlock(const struct lu_env *env,
550 const struct cl_io_slice *ios)
554 rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_unlock_wrapper);
559 * lov implementation of cl_operations::cio_submit() method. It takes a list
560 * of pages in \a queue, splits it into per-stripe sub-lists, invokes
561 * cl_io_submit() on underlying devices to submit sub-lists, and then splices
564 * Major complication of this function is a need to handle memory cleansing:
565 * cl_io_submit() is called to write out pages as a part of VM memory
566 * reclamation, and hence it may not fail due to memory shortages (system
567 * dead-locks otherwise). To deal with this, some resources (sub-lists,
568 * sub-environment, etc.) are allocated per-device on "startup" (i.e., in a
569 * not-memory cleansing context), and in case of memory shortage, these
570 * pre-allocated resources are used by lov_io_submit() under
571 * lov_device::ld_mutex mutex.
573 static int lov_io_submit(const struct lu_env *env,
574 const struct cl_io_slice *ios,
575 enum cl_req_type crt, struct cl_2queue *queue)
577 struct cl_page_list *qin = &queue->c2_qin;
578 struct lov_io *lio = cl2lov_io(env, ios);
579 struct lov_io_sub *sub;
580 struct cl_page_list *plist = &lov_env_info(env)->lti_plist;
581 struct cl_page *page;
586 if (lio->lis_active_subios == 1) {
587 int idx = lio->lis_single_subio_index;
589 LASSERT(idx < lio->lis_nr_subios);
590 sub = lov_sub_get(env, lio, idx);
591 LASSERT(!IS_ERR(sub));
592 LASSERT(sub->sub_io == &lio->lis_single_subio);
593 rc = cl_io_submit_rw(sub->sub_env, sub->sub_io,
599 LASSERT(lio->lis_subs);
601 cl_page_list_init(plist);
602 while (qin->pl_nr > 0) {
603 struct cl_2queue *cl2q = &lov_env_info(env)->lti_cl2q;
605 cl_2queue_init(cl2q);
607 page = cl_page_list_first(qin);
608 cl_page_list_move(&cl2q->c2_qin, qin, page);
610 stripe = lov_page_stripe(page);
611 while (qin->pl_nr > 0) {
612 page = cl_page_list_first(qin);
613 if (stripe != lov_page_stripe(page))
616 cl_page_list_move(&cl2q->c2_qin, qin, page);
619 sub = lov_sub_get(env, lio, stripe);
621 rc = cl_io_submit_rw(sub->sub_env, sub->sub_io,
628 cl_page_list_splice(&cl2q->c2_qin, plist);
629 cl_page_list_splice(&cl2q->c2_qout, &queue->c2_qout);
630 cl_2queue_fini(env, cl2q);
636 cl_page_list_splice(plist, qin);
637 cl_page_list_fini(env, plist);
642 static int lov_io_commit_async(const struct lu_env *env,
643 const struct cl_io_slice *ios,
644 struct cl_page_list *queue, int from, int to,
647 struct cl_page_list *plist = &lov_env_info(env)->lti_plist;
648 struct lov_io *lio = cl2lov_io(env, ios);
649 struct lov_io_sub *sub;
650 struct cl_page *page;
653 if (lio->lis_active_subios == 1) {
654 int idx = lio->lis_single_subio_index;
656 LASSERT(idx < lio->lis_nr_subios);
657 sub = lov_sub_get(env, lio, idx);
658 LASSERT(!IS_ERR(sub));
659 LASSERT(sub->sub_io == &lio->lis_single_subio);
660 rc = cl_io_commit_async(sub->sub_env, sub->sub_io, queue,
666 LASSERT(lio->lis_subs);
668 cl_page_list_init(plist);
669 while (queue->pl_nr > 0) {
673 LASSERT(plist->pl_nr == 0);
674 page = cl_page_list_first(queue);
675 cl_page_list_move(plist, queue, page);
677 stripe = lov_page_stripe(page);
678 while (queue->pl_nr > 0) {
679 page = cl_page_list_first(queue);
680 if (stripe != lov_page_stripe(page))
683 cl_page_list_move(plist, queue, page);
686 if (queue->pl_nr > 0) /* still has more pages */
687 stripe_to = PAGE_SIZE;
689 sub = lov_sub_get(env, lio, stripe);
691 rc = cl_io_commit_async(sub->sub_env, sub->sub_io,
692 plist, from, stripe_to, cb);
699 if (plist->pl_nr > 0) /* short write */
705 /* for error case, add the page back into the qin list */
706 LASSERT(ergo(rc == 0, plist->pl_nr == 0));
707 while (plist->pl_nr > 0) {
708 /* error occurred, add the uncommitted pages back into queue */
709 page = cl_page_list_last(plist);
710 cl_page_list_move_head(queue, plist, page);
716 static int lov_io_fault_start(const struct lu_env *env,
717 const struct cl_io_slice *ios)
719 struct cl_fault_io *fio;
721 struct lov_io_sub *sub;
723 fio = &ios->cis_io->u.ci_fault;
724 lio = cl2lov_io(env, ios);
725 sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page));
728 sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob;
730 return lov_io_start(env, ios);
733 static void lov_io_fsync_end(const struct lu_env *env,
734 const struct cl_io_slice *ios)
736 struct lov_io *lio = cl2lov_io(env, ios);
737 struct lov_io_sub *sub;
738 unsigned int *written = &ios->cis_io->u.ci_fsync.fi_nr_written;
741 list_for_each_entry(sub, &lio->lis_active, sub_linkage) {
742 struct cl_io *subio = sub->sub_io;
745 lov_io_end_wrapper(sub->sub_env, subio);
748 if (subio->ci_result == 0)
749 *written += subio->u.ci_fsync.fi_nr_written;
753 static const struct cl_io_operations lov_io_ops = {
756 .cio_fini = lov_io_fini,
757 .cio_iter_init = lov_io_rw_iter_init,
758 .cio_iter_fini = lov_io_iter_fini,
759 .cio_lock = lov_io_lock,
760 .cio_unlock = lov_io_unlock,
761 .cio_start = lov_io_start,
762 .cio_end = lov_io_end
765 .cio_fini = lov_io_fini,
766 .cio_iter_init = lov_io_rw_iter_init,
767 .cio_iter_fini = lov_io_iter_fini,
768 .cio_lock = lov_io_lock,
769 .cio_unlock = lov_io_unlock,
770 .cio_start = lov_io_start,
771 .cio_end = lov_io_end
774 .cio_fini = lov_io_fini,
775 .cio_iter_init = lov_io_iter_init,
776 .cio_iter_fini = lov_io_iter_fini,
777 .cio_lock = lov_io_lock,
778 .cio_unlock = lov_io_unlock,
779 .cio_start = lov_io_start,
780 .cio_end = lov_io_end
783 .cio_fini = lov_io_fini,
784 .cio_iter_init = lov_io_iter_init,
785 .cio_iter_fini = lov_io_iter_fini,
786 .cio_lock = lov_io_lock,
787 .cio_unlock = lov_io_unlock,
788 .cio_start = lov_io_fault_start,
789 .cio_end = lov_io_end
792 .cio_fini = lov_io_fini,
793 .cio_iter_init = lov_io_iter_init,
794 .cio_iter_fini = lov_io_iter_fini,
795 .cio_lock = lov_io_lock,
796 .cio_unlock = lov_io_unlock,
797 .cio_start = lov_io_start,
798 .cio_end = lov_io_fsync_end
801 .cio_fini = lov_io_fini
804 .cio_submit = lov_io_submit,
805 .cio_commit_async = lov_io_commit_async,
808 /*****************************************************************************
810 * Empty lov io operations.
814 static void lov_empty_io_fini(const struct lu_env *env,
815 const struct cl_io_slice *ios)
817 struct lov_object *lov = cl2lov(ios->cis_obj);
819 if (atomic_dec_and_test(&lov->lo_active_ios))
820 wake_up_all(&lov->lo_waitq);
823 static void lov_empty_impossible(const struct lu_env *env,
824 struct cl_io_slice *ios)
829 #define LOV_EMPTY_IMPOSSIBLE ((void *)lov_empty_impossible)
832 * An io operation vector for files without stripes.
834 static const struct cl_io_operations lov_empty_io_ops = {
837 .cio_fini = lov_empty_io_fini,
839 .cio_iter_init = LOV_EMPTY_IMPOSSIBLE,
840 .cio_lock = LOV_EMPTY_IMPOSSIBLE,
841 .cio_start = LOV_EMPTY_IMPOSSIBLE,
842 .cio_end = LOV_EMPTY_IMPOSSIBLE
846 .cio_fini = lov_empty_io_fini,
847 .cio_iter_init = LOV_EMPTY_IMPOSSIBLE,
848 .cio_lock = LOV_EMPTY_IMPOSSIBLE,
849 .cio_start = LOV_EMPTY_IMPOSSIBLE,
850 .cio_end = LOV_EMPTY_IMPOSSIBLE
853 .cio_fini = lov_empty_io_fini,
854 .cio_iter_init = LOV_EMPTY_IMPOSSIBLE,
855 .cio_lock = LOV_EMPTY_IMPOSSIBLE,
856 .cio_start = LOV_EMPTY_IMPOSSIBLE,
857 .cio_end = LOV_EMPTY_IMPOSSIBLE
860 .cio_fini = lov_empty_io_fini,
861 .cio_iter_init = LOV_EMPTY_IMPOSSIBLE,
862 .cio_lock = LOV_EMPTY_IMPOSSIBLE,
863 .cio_start = LOV_EMPTY_IMPOSSIBLE,
864 .cio_end = LOV_EMPTY_IMPOSSIBLE
867 .cio_fini = lov_empty_io_fini
870 .cio_fini = lov_empty_io_fini
873 .cio_submit = LOV_EMPTY_IMPOSSIBLE,
874 .cio_commit_async = LOV_EMPTY_IMPOSSIBLE
877 int lov_io_init_raid0(const struct lu_env *env, struct cl_object *obj,
880 struct lov_io *lio = lov_env_io(env);
881 struct lov_object *lov = cl2lov(obj);
883 INIT_LIST_HEAD(&lio->lis_active);
884 io->ci_result = lov_io_slice_init(lio, lov, io);
885 if (io->ci_result == 0) {
886 io->ci_result = lov_io_subio_init(env, lio, io);
887 if (io->ci_result == 0) {
888 cl_io_slice_add(io, &lio->lis_cl, obj, &lov_io_ops);
889 atomic_inc(&lov->lo_active_ios);
892 return io->ci_result;
895 int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
898 struct lov_object *lov = cl2lov(obj);
899 struct lov_io *lio = lov_env_io(env);
902 lio->lis_object = lov;
903 switch (io->ci_type) {
919 CERROR("Page fault on a file without stripes: "DFID"\n",
920 PFID(lu_object_fid(&obj->co_lu)));
924 cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops);
925 atomic_inc(&lov->lo_active_ios);
928 io->ci_result = result < 0 ? result : 0;
932 int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
935 struct lov_object *lov = cl2lov(obj);
936 struct lov_io *lio = lov_env_io(env);
939 LASSERT(lov->lo_lsm);
940 lio->lis_object = lov;
942 switch (io->ci_type) {
944 LASSERTF(0, "invalid type %d\n", io->ci_type);
950 /* the truncate to 0 is managed by MDT:
951 * - in open, for open O_TRUNC
952 * - in setattr, for truncate
954 /* the truncate is for size > 0 so triggers a restore */
955 if (cl_io_is_trunc(io))
956 io->ci_restore_needed = 1;
962 io->ci_restore_needed = 1;
967 cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops);
968 atomic_inc(&lov->lo_active_ios);
971 io->ci_result = result < 0 ? result : 0;