Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / osc / osc_io.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * Implementation of cl_io for OSC layer.
37  *
38  *   Author: Nikita Danilov <nikita.danilov@sun.com>
39  */
40
41 /** \addtogroup osc osc @{ */
42
43 #define DEBUG_SUBSYSTEM S_OSC
44
45 #include "osc_cl_internal.h"
46
47 /*****************************************************************************
48  *
49  * Type conversions.
50  *
51  */
52
53 static struct osc_req *cl2osc_req(const struct cl_req_slice *slice)
54 {
55         LINVRNT(slice->crs_dev->cd_lu_dev.ld_type == &osc_device_type);
56         return container_of0(slice, struct osc_req, or_cl);
57 }
58
59 static struct osc_io *cl2osc_io(const struct lu_env *env,
60                                 const struct cl_io_slice *slice)
61 {
62         struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
63         LINVRNT(oio == osc_env_io(env));
64         return oio;
65 }
66
67 static struct osc_page *osc_cl_page_osc(struct cl_page *page)
68 {
69         const struct cl_page_slice *slice;
70
71         slice = cl_page_at(page, &osc_device_type);
72         LASSERT(slice != NULL);
73
74         return cl2osc_page(slice);
75 }
76
77
78 /*****************************************************************************
79  *
80  * io operations.
81  *
82  */
83
84 static void osc_io_fini(const struct lu_env *env, const struct cl_io_slice *io)
85 {
86 }
87
88 struct cl_page *osc_oap2cl_page(struct osc_async_page *oap)
89 {
90         return container_of(oap, struct osc_page, ops_oap)->ops_cl.cpl_page;
91 }
92
93 static void osc_io_unplug(const struct lu_env *env, struct osc_object *osc,
94                           struct client_obd *cli)
95 {
96         loi_list_maint(cli, osc->oo_oinfo);
97         osc_check_rpcs(env, cli);
98         client_obd_list_unlock(&cli->cl_loi_list_lock);
99 }
100
101 /**
102  * How many pages osc_io_submit() queues before checking whether an RPC is
103  * ready.
104  */
105 #define OSC_QUEUE_GRAIN (32)
106
107 /**
108  * An implementation of cl_io_operations::cio_io_submit() method for osc
109  * layer. Iterates over pages in the in-queue, prepares each for io by calling
110  * cl_page_prep() and then either submits them through osc_io_submit_page()
111  * or, if page is already submitted, changes osc flags through
112  * osc_set_async_flags_base().
113  */
114 static int osc_io_submit(const struct lu_env *env,
115                          const struct cl_io_slice *ios,
116                          enum cl_req_type crt, struct cl_2queue *queue,
117                          enum cl_req_priority priority)
118 {
119         struct cl_page    *page;
120         struct cl_page    *tmp;
121         struct osc_object *osc0 = NULL;
122         struct client_obd *cli  = NULL;
123         struct osc_object *osc  = NULL; /* to keep gcc happy */
124         struct osc_page   *opg;
125         struct cl_io      *io;
126
127         struct cl_page_list *qin      = &queue->c2_qin;
128         struct cl_page_list *qout     = &queue->c2_qout;
129         int queued = 0;
130         int result = 0;
131
132         LASSERT(qin->pl_nr > 0);
133
134         CDEBUG(D_INFO, "%i %i\n", qin->pl_nr, crt);
135         /*
136          * NOTE: here @page is a top-level page. This is done to avoid
137          *       creation of sub-page-list.
138          */
139         cl_page_list_for_each_safe(page, tmp, qin) {
140                 struct osc_async_page *oap;
141                 struct obd_export     *exp;
142
143                 /* Top level IO. */
144                 io = page->cp_owner;
145                 LASSERT(io != NULL);
146
147                 opg = osc_cl_page_osc(page);
148                 oap = &opg->ops_oap;
149                 osc = cl2osc(opg->ops_cl.cpl_obj);
150                 exp = osc_export(osc);
151
152                 if (priority > CRP_NORMAL)
153                         oap->oap_async_flags |= ASYNC_HP;
154                 /*
155                  * This can be checked without cli->cl_loi_list_lock, because
156                  * ->oap_*_item are always manipulated when the page is owned.
157                  */
158                 if (!list_empty(&oap->oap_urgent_item) ||
159                     !list_empty(&oap->oap_rpc_item)) {
160                         result = -EBUSY;
161                         break;
162                 }
163
164                 if (osc0 == NULL) { /* first iteration */
165                         cli = &exp->exp_obd->u.cli;
166                         osc0 = osc;
167                 } else /* check that all pages are against the same object
168                         * (for now) */
169                         LASSERT(osc == osc0);
170                 if (queued++ == 0)
171                         client_obd_list_lock(&cli->cl_loi_list_lock);
172                 result = cl_page_prep(env, io, page, crt);
173                 if (result == 0) {
174                         cl_page_list_move(qout, qin, page);
175                         if (list_empty(&oap->oap_pending_item)) {
176                                 osc_io_submit_page(env, cl2osc_io(env, ios),
177                                                    opg, crt);
178                         } else {
179                                 result = osc_set_async_flags_base(cli,
180                                                                   osc->oo_oinfo,
181                                                                   oap,
182                                                                   OSC_FLAGS);
183                                 /*
184                                  * bug 18881: we can't just break out here when
185                                  * error occurrs after cl_page_prep has been
186                                  * called against the page. The correct
187                                  * way is to call page's completion routine,
188                                  * as in osc_oap_interrupted.  For simplicity,
189                                  * we just force osc_set_async_flags_base() to
190                                  * not return error.
191                                  */
192                                 LASSERT(result == 0);
193                         }
194                 } else {
195                         LASSERT(result < 0);
196                         if (result != -EALREADY)
197                                 break;
198                         /*
199                          * Handle -EALREADY error: for read case, the page is
200                          * already in UPTODATE state; for write, the page
201                          * is not dirty.
202                          */
203                         result = 0;
204                 }
205                 /*
206                  * Don't keep client_obd_list_lock() for too long.
207                  *
208                  * XXX client_obd_list lock has to be unlocked periodically to
209                  * avoid soft-lockups that tend to happen otherwise (see bug
210                  * 16651). On the other hand, osc_io_submit_page() queues a
211                  * page with ASYNC_URGENT flag and so all pages queued up
212                  * until this point are sent out immediately by
213                  * osc_io_unplug() resulting in sub-optimal RPCs (sub-optimal
214                  * RPCs only happen during `warm up' phase when less than
215                  * cl_max_rpcs_in_flight RPCs are in flight). To balance these
216                  * conflicting requirements, one might unplug once enough
217                  * pages to form a large RPC were queued (i.e., use
218                  * cli->cl_max_pages_per_rpc as OSC_QUEUE_GRAIN, see
219                  * lop_makes_rpc()), or ignore soft-lockup issue altogether.
220                  *
221                  * XXX lock_need_resched() should be used here, but it is not
222                  * available in the older of supported kernels.
223                  */
224                 if (queued > OSC_QUEUE_GRAIN || cfs_need_resched()) {
225                         queued = 0;
226                         osc_io_unplug(env, osc, cli);
227                         cfs_cond_resched();
228                 }
229         }
230
231         LASSERT(ergo(result == 0, cli != NULL));
232         LASSERT(ergo(result == 0, osc == osc0));
233
234         if (queued > 0)
235                 osc_io_unplug(env, osc, cli);
236         CDEBUG(D_INFO, "%i/%i %i\n", qin->pl_nr, qout->pl_nr, result);
237         return qout->pl_nr > 0 ? 0 : result;
238 }
239
240 static void osc_page_touch_at(const struct lu_env *env,
241                               struct cl_object *obj, pgoff_t idx, unsigned to)
242 {
243         struct lov_oinfo  *loi  = cl2osc(obj)->oo_oinfo;
244         struct cl_attr    *attr = &osc_env_info(env)->oti_attr;
245         int valid;
246         __u64 kms;
247
248         /* offset within stripe */
249         kms = cl_offset(obj, idx) + to;
250
251         cl_object_attr_lock(obj);
252         /*
253          * XXX old code used
254          *
255          *         ll_inode_size_lock(inode, 0); lov_stripe_lock(lsm);
256          *
257          * here
258          */
259         CDEBUG(D_INODE, "stripe KMS %sincreasing "LPU64"->"LPU64" "LPU64"\n",
260                kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
261                loi->loi_lvb.lvb_size);
262
263         valid = 0;
264         if (kms > loi->loi_kms) {
265                 attr->cat_kms = kms;
266                 valid |= CAT_KMS;
267         }
268         if (kms > loi->loi_lvb.lvb_size) {
269                 attr->cat_size = kms;
270                 valid |= CAT_SIZE;
271         }
272         cl_object_attr_set(env, obj, attr, valid);
273         cl_object_attr_unlock(obj);
274 }
275
276 /**
277  * This is called when a page is accessed within file in a way that creates
278  * new page, if one were missing (i.e., if there were a hole at that place in
279  * the file, or accessed page is beyond the current file size). Examples:
280  * ->commit_write() and ->nopage() methods.
281  *
282  * Expand stripe KMS if necessary.
283  */
284 static void osc_page_touch(const struct lu_env *env,
285                            struct osc_page *opage, unsigned to)
286 {
287         struct cl_page    *page = opage->ops_cl.cpl_page;
288         struct cl_object  *obj  = opage->ops_cl.cpl_obj;
289
290         osc_page_touch_at(env, obj, page->cp_index, to);
291 }
292
293 /**
294  * Implements cl_io_operations::cio_prepare_write() method for osc layer.
295  *
296  * \retval -EIO transfer initiated against this osc will most likely fail
297  * \retval 0    transfer initiated against this osc will most likely succeed.
298  *
299  * The reason for this check is to immediately return an error to the caller
300  * in the case of a deactivated import. Note, that import can be deactivated
301  * later, while pages, dirtied by this IO, are still in the cache, but this is
302  * irrelevant, because that would still return an error to the application (if
303  * it does fsync), but many applications don't do fsync because of performance
304  * issues, and we wanted to return an -EIO at write time to notify the
305  * application.
306  */
307 static int osc_io_prepare_write(const struct lu_env *env,
308                                 const struct cl_io_slice *ios,
309                                 const struct cl_page_slice *slice,
310                                 unsigned from, unsigned to)
311 {
312         struct osc_device *dev = lu2osc_dev(slice->cpl_obj->co_lu.lo_dev);
313         struct obd_import *imp = class_exp2cliimp(dev->od_exp);
314
315         ENTRY;
316
317         /*
318          * This implements OBD_BRW_CHECK logic from old client.
319          */
320
321         RETURN(imp == NULL || imp->imp_invalid ? -EIO : 0);
322 }
323
324 static int osc_io_commit_write(const struct lu_env *env,
325                                const struct cl_io_slice *ios,
326                                const struct cl_page_slice *slice,
327                                unsigned from, unsigned to)
328 {
329         struct osc_page       *opg = cl2osc_page(slice);
330         struct osc_object     *obj = cl2osc(opg->ops_cl.cpl_obj);
331         struct osc_async_page *oap = &opg->ops_oap;
332         ENTRY;
333
334         LASSERT(to > 0);
335         /*
336          * XXX instead of calling osc_page_touch() here and in
337          * osc_io_fault_start() it might be more logical to introduce
338          * cl_page_touch() method, that generic cl_io_commit_write() and page
339          * fault code calls.
340          */
341         osc_page_touch(env, cl2osc_page(slice), to);
342         if (!client_is_remote(osc_export(obj)) &&
343             cfs_capable(CFS_CAP_SYS_RESOURCE))
344                 oap->oap_brw_flags |= OBD_BRW_NOQUOTA;
345
346         RETURN(0);
347 }
348
349 static int osc_io_fault_start(const struct lu_env *env,
350                               const struct cl_io_slice *ios)
351 {
352         struct cl_io       *io;
353         struct cl_fault_io *fio;
354
355         ENTRY;
356
357         io  = ios->cis_io;
358         fio = &io->u.ci_fault;
359         CDEBUG(D_INFO, "%lu %i %i\n",
360                fio->ft_index, fio->ft_writable, fio->ft_nob);
361         /*
362          * If mapping is writeable, adjust kms to cover this page,
363          * but do not extend kms beyond actual file size.
364          * See bug 10919.
365          */
366         if (fio->ft_writable)
367                 osc_page_touch_at(env, ios->cis_obj,
368                                   fio->ft_index, fio->ft_nob);
369         RETURN(0);
370 }
371
372 static int osc_punch_upcall(void *a, int rc)
373 {
374         struct osc_punch_cbargs *args = a;
375
376         args->opc_rc = rc;
377         complete(&args->opc_sync);
378         return 0;
379 }
380
381 #ifdef __KERNEL__
382 /**
383  * Checks that there are no pages being written in the extent being truncated.
384  */
385 static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
386                             struct osc_io *oio, size_t size)
387 {
388         struct osc_page     *cp;
389         struct osc_object   *obj;
390         struct cl_object    *clob;
391         struct cl_page      *page;
392         struct cl_page_list *list;
393         int                  partial;
394         pgoff_t              start;
395
396         clob    = oio->oi_cl.cis_obj;
397         obj     = cl2osc(clob);
398         start   = cl_index(clob, size);
399         partial = cl_offset(clob, start) < size;
400         list    = &osc_env_info(env)->oti_plist;
401
402         /*
403          * Complain if there are pages in the truncated region.
404          *
405          * XXX this is quite expensive check.
406          */
407         cl_page_list_init(list);
408         cl_page_gang_lookup(env, clob, io, start + partial, CL_PAGE_EOF, list);
409
410         cl_page_list_for_each(page, list)
411                 CL_PAGE_DEBUG(D_ERROR, env, page, "exists %lu\n", start);
412
413         cl_page_list_disown(env, io, list);
414         cl_page_list_fini(env, list);
415
416         spin_lock(&obj->oo_seatbelt);
417         list_for_each_entry(cp, &obj->oo_inflight[CRT_WRITE], ops_inflight) {
418                 page = cp->ops_cl.cpl_page;
419                 if (page->cp_index >= start + partial) {
420                         cfs_task_t *submitter;
421
422                         submitter = cp->ops_submitter;
423                         /*
424                          * XXX Linux specific debugging stuff.
425                          */
426                         CL_PAGE_DEBUG(D_ERROR, env, page, "%s/%i %lu\n",
427                                       submitter->comm, submitter->pid, start);
428                         libcfs_debug_dumpstack(submitter);
429                 }
430         }
431         spin_unlock(&obj->oo_seatbelt);
432 }
433 #else /* __KERNEL__ */
434 # define osc_trunc_check(env, io, oio, size) do {;} while (0)
435 #endif
436
437 static int osc_io_trunc_start(const struct lu_env *env,
438                               const struct cl_io_slice *slice)
439 {
440         struct cl_io            *io     = slice->cis_io;
441         struct osc_io           *oio    = cl2osc_io(env, slice);
442         struct cl_object        *obj    = slice->cis_obj;
443         struct lov_oinfo        *loi    = cl2osc(obj)->oo_oinfo;
444         struct cl_attr          *attr   = &osc_env_info(env)->oti_attr;
445         struct obdo             *oa     = &oio->oi_oa;
446         struct osc_punch_cbargs *cbargs = &oio->oi_punch_cbarg;
447         struct obd_capa         *capa;
448         loff_t                   size   = io->u.ci_truncate.tr_size;
449         int                      result = 0;
450
451
452         memset(oa, 0, sizeof(*oa));
453
454         osc_trunc_check(env, io, oio, size);
455
456         if (oio->oi_lockless == 0) {
457                 cl_object_attr_lock(obj);
458                 result = cl_object_attr_get(env, obj, attr);
459                 if (result == 0) {
460                         attr->cat_size = attr->cat_kms = size;
461                         result = cl_object_attr_set(env, obj, attr,
462                                                     CAT_SIZE|CAT_KMS);
463                 }
464                 cl_object_attr_unlock(obj);
465         }
466
467         if (result == 0) {
468                 oa->o_id = loi->loi_id;
469                 oa->o_gr = loi->loi_gr;
470                 oa->o_mtime = attr->cat_mtime;
471                 oa->o_atime = attr->cat_atime;
472                 oa->o_ctime = attr->cat_ctime;
473                 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLATIME |
474                         OBD_MD_FLCTIME | OBD_MD_FLMTIME;
475                 if (oio->oi_lockless) {
476                         oa->o_flags = OBD_FL_TRUNCLOCK;
477                         oa->o_valid |= OBD_MD_FLFLAGS;
478                 }
479                 oa->o_size = size;
480                 oa->o_blocks = OBD_OBJECT_EOF;
481                 oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
482
483                 capa = io->u.ci_truncate.tr_capa;
484                 init_completion(&cbargs->opc_sync);
485                 result = osc_punch_base(osc_export(cl2osc(obj)), oa, capa,
486                                         osc_punch_upcall, cbargs, PTLRPCD_SET);
487         }
488         return result;
489 }
490
491 static void osc_io_trunc_end(const struct lu_env *env,
492                              const struct cl_io_slice *slice)
493 {
494         struct cl_io            *io     = slice->cis_io;
495         struct osc_io           *oio    = cl2osc_io(env, slice);
496         struct osc_punch_cbargs *cbargs = &oio->oi_punch_cbarg;
497         struct obdo             *oa     = &oio->oi_oa;
498         int result;
499
500         wait_for_completion(&cbargs->opc_sync);
501
502         result = io->ci_result = cbargs->opc_rc;
503         if (result == 0) {
504                 struct cl_object *obj = slice->cis_obj;
505                 if (oio->oi_lockless == 0) {
506                         struct cl_attr *attr = &osc_env_info(env)->oti_attr;
507                         int valid = 0;
508
509                         /* Update kms & size */
510                         if (oa->o_valid & OBD_MD_FLSIZE) {
511                                 attr->cat_size = oa->o_size;
512                                 attr->cat_kms  = oa->o_size;
513                                 valid |= CAT_KMS|CAT_SIZE;
514                         }
515                         if (oa->o_valid & OBD_MD_FLBLOCKS) {
516                                 attr->cat_blocks = oa->o_blocks;
517                                 valid |= CAT_BLOCKS;
518                         }
519                         if (oa->o_valid & OBD_MD_FLMTIME) {
520                                 attr->cat_mtime = oa->o_mtime;
521                                 valid |= CAT_MTIME;
522                         }
523                         if (oa->o_valid & OBD_MD_FLCTIME) {
524                                 attr->cat_ctime = oa->o_ctime;
525                                 valid |= CAT_CTIME;
526                         }
527                         if (oa->o_valid & OBD_MD_FLATIME) {
528                                 attr->cat_atime = oa->o_atime;
529                                 valid |= CAT_ATIME;
530                         }
531                         cl_object_attr_lock(obj);
532                         result = cl_object_attr_set(env, obj, attr, valid);
533                         cl_object_attr_unlock(obj);
534                 } else {  /* lockless truncate */
535                         struct osc_device *osd = lu2osc_dev(obj->co_lu.lo_dev);
536                         /* XXX: Need a lock. */
537                         osd->od_stats.os_lockless_truncates++;
538                 }
539         }
540
541         /* return result; */
542 }
543
544 static const struct cl_io_operations osc_io_ops = {
545         .op = {
546                 [CIT_READ] = {
547                         .cio_fini   = osc_io_fini
548                 },
549                 [CIT_WRITE] = {
550                         .cio_fini   = osc_io_fini
551                 },
552                 [CIT_TRUNC] = {
553                         .cio_start  = osc_io_trunc_start,
554                         .cio_end    = osc_io_trunc_end
555                 },
556                 [CIT_FAULT] = {
557                         .cio_fini   = osc_io_fini,
558                         .cio_start  = osc_io_fault_start
559                 },
560                 [CIT_MISC] = {
561                         .cio_fini   = osc_io_fini
562                 }
563         },
564         .req_op = {
565                  [CRT_READ] = {
566                          .cio_submit    = osc_io_submit
567                  },
568                  [CRT_WRITE] = {
569                          .cio_submit    = osc_io_submit
570                  }
571          },
572         .cio_prepare_write = osc_io_prepare_write,
573         .cio_commit_write  = osc_io_commit_write
574 };
575
576 /*****************************************************************************
577  *
578  * Transfer operations.
579  *
580  */
581
582 static int osc_req_prep(const struct lu_env *env,
583                         const struct cl_req_slice *slice)
584 {
585         return 0;
586 }
587
588 static void osc_req_completion(const struct lu_env *env,
589                                const struct cl_req_slice *slice, int ioret)
590 {
591         struct osc_req *or;
592
593         or = cl2osc_req(slice);
594         OBD_SLAB_FREE_PTR(or, osc_req_kmem);
595 }
596
597 /**
598  * Implementation of struct cl_req_operations::cro_attr_set() for osc
599  * layer. osc is responsible for struct obdo::o_id and struct obdo::o_gr
600  * fields.
601  */
602 static void osc_req_attr_set(const struct lu_env *env,
603                              const struct cl_req_slice *slice,
604                              const struct cl_object *obj,
605                              struct cl_req_attr *attr, obd_valid flags)
606 {
607         struct lov_oinfo *oinfo;
608         struct cl_req    *clerq;
609         struct cl_page   *apage; /* _some_ page in @clerq */
610         struct cl_lock   *lock;  /* _some_ lock protecting @apage */
611         struct osc_lock  *olck;
612         struct osc_page  *opg;
613         struct obdo      *oa;
614
615         oa = attr->cra_oa;
616         oinfo = cl2osc(obj)->oo_oinfo;
617         if (flags & OBD_MD_FLID) {
618                 oa->o_id = oinfo->loi_id;
619                 oa->o_valid |= OBD_MD_FLID;
620         }
621         if (flags & OBD_MD_FLGROUP) {
622                 oa->o_gr = oinfo->loi_gr;
623                 oa->o_valid |= OBD_MD_FLGROUP;
624         }
625         if (flags & OBD_MD_FLHANDLE) {
626                 clerq = slice->crs_req;
627                 LASSERT(!list_empty(&clerq->crq_pages));
628                 apage = container_of(clerq->crq_pages.next,
629                                      struct cl_page, cp_flight);
630                 opg = osc_cl_page_osc(apage);
631                 apage = opg->ops_cl.cpl_page; /* now apage is a sub-page */
632                 lock = cl_lock_at_page(env, apage->cp_obj, apage, NULL, 1, 1);
633                 LASSERT(lock != NULL);
634                 olck = osc_lock_at(lock);
635                 LASSERT(olck != NULL);
636                 /* check for lockless io. */
637                 if (olck->ols_lock != NULL) {
638                         oa->o_handle = olck->ols_lock->l_remote_handle;
639                         oa->o_valid |= OBD_MD_FLHANDLE;
640                 }
641                 cl_lock_put(env, lock);
642         }
643 }
644
645 static const struct cl_req_operations osc_req_ops = {
646         .cro_prep       = osc_req_prep,
647         .cro_attr_set   = osc_req_attr_set,
648         .cro_completion = osc_req_completion
649 };
650
651
652 int osc_io_init(const struct lu_env *env,
653                 struct cl_object *obj, struct cl_io *io)
654 {
655         struct osc_io *oio = osc_env_io(env);
656
657         CL_IO_SLICE_CLEAN(oio, oi_cl);
658         cl_io_slice_add(io, &oio->oi_cl, obj, &osc_io_ops);
659         return 0;
660 }
661
662 int osc_req_init(const struct lu_env *env, struct cl_device *dev,
663                  struct cl_req *req)
664 {
665         struct osc_req *or;
666         int result;
667
668         OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, CFS_ALLOC_IO);
669         if (or != NULL) {
670                 cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
671                 result = 0;
672         } else
673                 result = -ENOMEM;
674         return result;
675 }
676
677 /** @} osc */