Whamcloud - gitweb
LU-10810 clio: SEEK_HOLE/SEEK_DATA on client side
[fs/lustre-release.git] / lustre / osc / osc_io.c
index 043a6de..3bddf18 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
 
 #define DEBUG_SUBSYSTEM S_OSC
 
-#include "osc_cl_internal.h"
+#include <lustre_obdo.h>
+#include <lustre_osc.h>
+#include <linux/pagevec.h>
+#include <linux/falloc.h>
 
-/** \addtogroup osc 
- *  @{ 
- */
+#include "osc_internal.h"
 
-/*****************************************************************************
- *
- * Type conversions.
- *
+/** \addtogroup osc
+ *  @{
  */
 
-static struct osc_req *cl2osc_req(const struct cl_req_slice *slice)
-{
-        LINVRNT(slice->crs_dev->cd_lu_dev.ld_type == &osc_device_type);
-        return container_of0(slice, struct osc_req, or_cl);
-}
-
-static struct osc_io *cl2osc_io(const struct lu_env *env,
-                                const struct cl_io_slice *slice)
-{
-        struct osc_io *oio = container_of0(slice, struct osc_io, oi_cl);
-        LINVRNT(oio == osc_env_io(env));
-        return oio;
-}
-
-static struct osc_page *osc_cl_page_osc(struct cl_page *page,
-                                       struct osc_object *osc)
-{
-       const struct cl_page_slice *slice;
-
-       if (osc != NULL)
-               slice = cl_object_page_slice(&osc->oo_cl, page);
-       else
-               slice = cl_page_at(page, &osc_device_type);
-       LASSERT(slice != NULL);
-
-       return cl2osc_page(slice);
-}
-
-
 /*****************************************************************************
  *
  * io operations.
@@ -92,8 +58,7 @@ static void osc_io_fini(const struct lu_env *env, const struct cl_io_slice *io)
 {
 }
 
-static void osc_read_ahead_release(const struct lu_env *env,
-                                  void *cbdata)
+void osc_read_ahead_release(const struct lu_env *env, void *cbdata)
 {
        struct ldlm_lock *dlmlock = cbdata;
        struct lustre_handle lockh;
@@ -102,6 +67,7 @@ static void osc_read_ahead_release(const struct lu_env *env,
        ldlm_lock_decref(&lockh, LCK_PR);
        LDLM_LOCK_PUT(dlmlock);
 }
+EXPORT_SYMBOL(osc_read_ahead_release);
 
 static int osc_io_read_ahead(const struct lu_env *env,
                             const struct cl_io_slice *ios,
@@ -114,6 +80,7 @@ static int osc_io_read_ahead(const struct lu_env *env,
 
        dlmlock = osc_dlmlock_at_pgoff(env, osc, start, 0);
        if (dlmlock != NULL) {
+               LASSERT(dlmlock->l_ast_data == osc);
                if (dlmlock->l_req_mode != LCK_PR) {
                        struct lustre_handle lockh;
                        ldlm_lock2handle(dlmlock, &lockh);
@@ -121,10 +88,13 @@ static int osc_io_read_ahead(const struct lu_env *env,
                        ldlm_lock_decref(&lockh, dlmlock->l_req_mode);
                }
 
-               ra->cra_end = cl_index(osc2cl(osc),
-                                      dlmlock->l_policy_data.l_extent.end);
+               ra->cra_rpc_pages = osc_cli(osc)->cl_max_pages_per_rpc;
+               ra->cra_end_idx = cl_index(osc2cl(osc),
+                                          dlmlock->l_policy_data.l_extent.end);
                ra->cra_release = osc_read_ahead_release;
                ra->cra_cbdata = dlmlock;
+               if (ra->cra_end_idx != CL_PAGE_EOF)
+                       ra->cra_contention = true;
                result = 0;
        }
 
@@ -138,9 +108,8 @@ static int osc_io_read_ahead(const struct lu_env *env,
  * or, if page is already submitted, changes osc flags through
  * osc_set_async_flags().
  */
-static int osc_io_submit(const struct lu_env *env,
-                         const struct cl_io_slice *ios,
-                        enum cl_req_type crt, struct cl_2queue *queue)
+int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios,
+                 enum cl_req_type crt, struct cl_2queue *queue)
 {
        struct cl_page    *page;
        struct cl_page    *tmp;
@@ -148,26 +117,36 @@ static int osc_io_submit(const struct lu_env *env,
        struct osc_object *osc  = NULL; /* to keep gcc happy */
        struct osc_page   *opg;
        struct cl_io      *io;
-       struct list_head  list = LIST_HEAD_INIT(list);
+       LIST_HEAD(list);
 
        struct cl_page_list *qin      = &queue->c2_qin;
        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);
 
-       CDEBUG(D_CACHE, "%d %d\n", qin->pl_nr, crt);
+       CDEBUG(D_CACHE|D_READA, "%d %d\n", qin->pl_nr, crt);
 
        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;
+
+       page = cl_page_list_first(qin);
+       if (page->cp_type == CPT_TRANSIENT)
+               brw_flags |= OBD_BRW_NOCACHE;
 
         /*
          * NOTE: here @page is a top-level page. This is done to avoid
@@ -219,53 +198,77 @@ static int osc_io_submit(const struct lu_env *env,
                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) {
+               struct cl_object *obj   = ios->cis_obj;
+               struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+
+               cl_object_attr_lock(obj);
+               attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
+               cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME);
+               cl_object_attr_unlock(obj);
+       }
 
        CDEBUG(D_INFO, "%d/%d %d\n", qin->pl_nr, qout->pl_nr, result);
        return qout->pl_nr > 0 ? 0 : result;
 }
+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;
+
+       ENTRY;
 
-        /* offset within stripe */
-        kms = cl_offset(obj, idx) + to;
+       /* offset within stripe */
+       kms = cl_offset(obj, idx) + to;
 
-        cl_object_attr_lock(obj);
-        /*
-         * XXX old code used
-         *
-         *         ll_inode_size_lock(inode, 0); lov_stripe_lock(lsm);
-         *
-         * here
-         */
-        CDEBUG(D_INODE, "stripe KMS %sincreasing "LPU64"->"LPU64" "LPU64"\n",
-               kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms,
-               loi->loi_lvb.lvb_size);
+       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);
 
-       attr->cat_mtime = attr->cat_ctime = LTIME_S(CFS_CURRENT_TIME);
+       attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
        valid = CAT_MTIME | CAT_CTIME;
        if (kms > loi->loi_kms) {
                attr->cat_kms = kms;
@@ -277,12 +280,14 @@ static void osc_page_touch_at(const struct lu_env *env,
        }
        cl_object_attr_update(env, obj, attr, valid);
        cl_object_attr_unlock(obj);
+
+       EXIT;
 }
 
-static int osc_io_commit_async(const struct lu_env *env,
-                               const struct cl_io_slice *ios,
-                               struct cl_page_list *qin, int from, int to,
-                               cl_commit_cbt cb)
+int osc_io_commit_async(const struct lu_env *env,
+                       const struct cl_io_slice *ios,
+                       struct cl_page_list *qin, int from, int to,
+                       cl_commit_cbt cb)
 {
        struct cl_io    *io = ios->cis_io;
        struct osc_io   *oio = cl2osc_io(env, ios);
@@ -290,6 +295,7 @@ static int osc_io_commit_async(const struct lu_env *env,
        struct cl_page  *page;
        struct cl_page  *last_page;
        struct osc_page *opg;
+       struct pagevec  *pvec = &osc_env_info(env)->oti_pagevec;
        int result = 0;
        ENTRY;
 
@@ -309,6 +315,8 @@ static int osc_io_commit_async(const struct lu_env *env,
                }
        }
 
+       ll_pagevec_init(pvec, 0);
+
        while (qin->pl_nr > 0) {
                struct osc_async_page *oap;
 
@@ -316,6 +324,9 @@ static 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);
@@ -325,7 +336,7 @@ static int osc_io_commit_async(const struct lu_env *env,
 
                /* The page may be already in dirty cache. */
                if (list_empty(&oap->oap_pending_item)) {
-                       result = osc_page_cache_add(env, &opg->ops_cl, io);
+                       result = osc_page_cache_add(env, opg, io, cb);
                        if (result != 0)
                                break;
                }
@@ -335,11 +346,20 @@ static int osc_io_commit_async(const struct lu_env *env,
 
                cl_page_list_del(env, qin, page);
 
-               (*cb)(env, io, page);
-               /* Can't access page any more. Page can be in transfer and
-                * complete at any time. */
+               /* if there are no more slots, do the callback & reinit */
+               if (pagevec_add(pvec, page->cp_vmpage) == 0) {
+                       (*cb)(env, io, pvec);
+                       pagevec_reinit(pvec);
+               }
        }
 
+       /* Clean up any partially full pagevecs */
+       if (pagevec_count(pvec) != 0)
+               (*cb)(env, io, pvec);
+
+       /* Can't access these pages any more. Page can be in transfer and
+        * complete at any time. */
+
        /* for sync write, kernel will wait for this page to be flushed before
         * osc_io_end() is called, so release it earlier.
         * for mkwrite(), it's known there is no further pages. */
@@ -351,60 +371,100 @@ static int osc_io_commit_async(const struct lu_env *env,
        CDEBUG(D_INFO, "%d %d\n", qin->pl_nr, result);
        RETURN(result);
 }
+EXPORT_SYMBOL(osc_io_commit_async);
 
-static int osc_io_rw_iter_init(const struct lu_env *env,
-                               const struct cl_io_slice *ios)
+static bool osc_import_not_healthy(struct obd_import *imp)
+{
+       return imp->imp_invalid || imp->imp_deactive ||
+              !(imp->imp_state == LUSTRE_IMP_FULL ||
+                imp->imp_state == LUSTRE_IMP_IDLE);
+}
+
+int osc_io_iter_init(const struct lu_env *env, const struct cl_io_slice *ios)
+{
+       struct osc_object *osc = cl2osc(ios->cis_obj);
+       struct obd_import *imp = osc_cli(osc)->cl_import;
+       struct osc_io *oio = osc_env_io(env);
+       int rc = -EIO;
+       ENTRY;
+
+       spin_lock(&imp->imp_lock);
+       /**
+        * check whether this OSC device is available for non-delay read,
+        * fast switching mirror if we haven't tried all mirrors.
+        */
+       if (ios->cis_io->ci_type == CIT_READ && ios->cis_io->ci_ndelay &&
+           !ios->cis_io->ci_tried_all_mirrors && osc_import_not_healthy(imp)) {
+               rc = -EWOULDBLOCK;
+       } else if (likely(!imp->imp_invalid)) {
+               atomic_inc(&osc->oo_nr_ios);
+               oio->oi_is_active = 1;
+               rc = 0;
+       }
+       spin_unlock(&imp->imp_lock);
+
+       if (cfs_capable(CFS_CAP_SYS_RESOURCE))
+               oio->oi_cap_sys_resource = 1;
+
+       RETURN(rc);
+}
+EXPORT_SYMBOL(osc_io_iter_init);
+
+int osc_io_rw_iter_init(const struct lu_env *env,
+                       const struct cl_io_slice *ios)
 {
        struct cl_io *io = ios->cis_io;
        struct osc_io *oio = osc_env_io(env);
        struct osc_object *osc = cl2osc(ios->cis_obj);
-       struct client_obd *cli = osc_cli(osc);
-       unsigned long c;
        unsigned long npages;
-       unsigned long max_pages;
        ENTRY;
 
        if (cl_io_is_append(io))
-               RETURN(0);
+               RETURN(osc_io_iter_init(env, ios));
 
-       npages = io->u.ci_rw.crw_count >> PAGE_CACHE_SHIFT;
+       npages = io->u.ci_rw.crw_count >> PAGE_SHIFT;
        if (io->u.ci_rw.crw_pos & ~PAGE_MASK)
                ++npages;
 
-       max_pages = cli->cl_max_pages_per_rpc * cli->cl_max_rpcs_in_flight;
-       if (npages > max_pages)
-               npages = max_pages;
+       oio->oi_lru_reserved = osc_lru_reserve(osc_cli(osc), npages);
 
-       c = atomic_long_read(cli->cl_lru_left);
-       if (c < npages && osc_lru_reclaim(cli) > 0)
-               c = atomic_long_read(cli->cl_lru_left);
-       while (c >= npages) {
-               if (c == atomic_long_cmpxchg(cli->cl_lru_left, c, c - npages)) {
-                       oio->oi_lru_reserved = npages;
-                       break;
-               }
-               c = atomic_long_read(cli->cl_lru_left);
-       }
+       RETURN(osc_io_iter_init(env, ios));
+}
+EXPORT_SYMBOL(osc_io_rw_iter_init);
 
-       RETURN(0);
+void osc_io_iter_fini(const struct lu_env *env,
+                     const struct cl_io_slice *ios)
+{
+       struct osc_io *oio = osc_env_io(env);
+
+       if (oio->oi_is_active) {
+               struct osc_object *osc = cl2osc(ios->cis_obj);
+
+               oio->oi_is_active = 0;
+               LASSERT(atomic_read(&osc->oo_nr_ios) > 0);
+               if (atomic_dec_and_test(&osc->oo_nr_ios))
+                       wake_up_all(&osc->oo_io_waitq);
+       }
 }
+EXPORT_SYMBOL(osc_io_iter_fini);
 
-static void osc_io_rw_iter_fini(const struct lu_env *env,
-                               const struct cl_io_slice *ios)
+void osc_io_rw_iter_fini(const struct lu_env *env,
+                        const struct cl_io_slice *ios)
 {
        struct osc_io *oio = osc_env_io(env);
        struct osc_object *osc = cl2osc(ios->cis_obj);
-       struct client_obd *cli = osc_cli(osc);
 
        if (oio->oi_lru_reserved > 0) {
-               atomic_long_add(oio->oi_lru_reserved, cli->cl_lru_left);
+               osc_lru_unreserve(osc_cli(osc), oio->oi_lru_reserved);
                oio->oi_lru_reserved = 0;
        }
        oio->oi_write_osclock = NULL;
+
+       osc_io_iter_fini(env, ios);
 }
+EXPORT_SYMBOL(osc_io_rw_iter_fini);
 
-static int osc_io_fault_start(const struct lu_env *env,
-                             const struct cl_io_slice *ios)
+int osc_io_fault_start(const struct lu_env *env, const struct cl_io_slice *ios)
 {
        struct cl_io       *io;
        struct cl_fault_io *fio;
@@ -424,6 +484,8 @@ static int osc_io_fault_start(const struct lu_env *env,
                                  fio->ft_index, fio->ft_nob);
        RETURN(0);
 }
+EXPORT_SYMBOL(osc_io_fault_start);
+
 
 static int osc_async_upcall(void *a, int rc)
 {
@@ -437,7 +499,7 @@ static int osc_async_upcall(void *a, int rc)
 /**
  * Checks that there are no pages being written in the extent being truncated.
  */
-static int trunc_check_cb(const struct lu_env *env, struct cl_io *io,
+static bool trunc_check_cb(const struct lu_env *env, struct cl_io *io,
                          struct osc_page *ops , void *cbdata)
 {
        struct cl_page *page = ops->ops_cl.cpl_page;
@@ -447,14 +509,14 @@ static int trunc_check_cb(const struct lu_env *env, struct cl_io *io,
        oap = &ops->ops_oap;
        if (oap->oap_cmd & OBD_BRW_WRITE &&
            !list_empty(&oap->oap_pending_item))
-               CL_PAGE_DEBUG(D_ERROR, env, page, "exists " LPU64 "/%s.\n",
+               CL_PAGE_DEBUG(D_ERROR, env, page, "exists %llu/%s.\n",
                                start, current->comm);
 
        if (PageLocked(page->cp_vmpage))
                CDEBUG(D_CACHE, "page %p index %lu locked for %d.\n",
                       ops, osc_index(ops), oap->oap_cmd & OBD_BRW_RWMASK);
 
-       return CLP_GANG_OKAY;
+       return true;
 }
 
 static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
@@ -479,20 +541,30 @@ static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
 static int osc_io_setattr_start(const struct lu_env *env,
                                 const struct cl_io_slice *slice)
 {
-        struct cl_io            *io     = slice->cis_io;
-        struct osc_io           *oio    = cl2osc_io(env, slice);
-        struct cl_object        *obj    = slice->cis_obj;
-        struct lov_oinfo        *loi    = cl2osc(obj)->oo_oinfo;
-        struct cl_attr          *attr   = &osc_env_info(env)->oti_attr;
-        struct obdo             *oa     = &oio->oi_oa;
+       struct cl_io *io = slice->cis_io;
+       struct osc_io *oio = cl2osc_io(env, slice);
+       struct cl_object *obj = slice->cis_obj;
+       struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
+       struct cl_attr *attr = &osc_env_info(env)->oti_attr;
+       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;
+       unsigned int ia_avalid = io->u.ci_setattr.sa_avalid;
+       enum op_xvalid ia_xvalid = io->u.ci_setattr.sa_xvalid;
+       int result = 0;
+       __u64 size = io->u.ci_setattr.sa_attr.lvb_size;
+       __u64 end = OBD_OBJECT_EOF;
+       bool io_is_falloc = false;
 
+       ENTRY;
        /* truncate cache dirty pages first */
-       if (cl_io_is_trunc(io))
-               result = osc_cache_truncate_start(env, oio, cl2osc(obj), size);
+       if (cl_io_is_trunc(io)) {
+               result = osc_cache_truncate_start(env, cl2osc(obj), size,
+                                                 &oio->oi_trunc);
+       } else if (cl_io_is_fallocate(io)) {
+               io_is_falloc = true;
+               size = io->u.ci_setattr.sa_falloc_offset;
+               end = io->u.ci_setattr.sa_falloc_end;
+       }
 
        if (result == 0 && oio->oi_lockless == 0) {
                cl_object_attr_lock(obj);
@@ -501,19 +573,20 @@ static int osc_io_setattr_start(const struct lu_env *env,
                        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;
                        }
@@ -527,87 +600,140 @@ static int osc_io_setattr_start(const struct lu_env *env,
                oa->o_oi = loi->loi_oi;
                obdo_set_parent_fid(oa, io->u.ci_setattr.sa_parent_fid);
                oa->o_stripe_idx = io->u.ci_setattr.sa_stripe_index;
-               oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
-               if (ia_valid & ATTR_CTIME) {
+               oa->o_layout = io->u.ci_setattr.sa_layout;
+               oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP |
+                       OBD_MD_FLOSTLAYOUT;
+               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) {
+                       if (io_is_falloc) {
+                               oa->o_size = size;
+                               oa->o_blocks = end;
+                               oa->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+                       } else {
+                               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)
-                       result = osc_punch_base(osc_export(cl2osc(obj)),
-                                               oa, osc_async_upcall,
-                                               cbargs, PTLRPCD_SET);
-               else
+               if (io_is_falloc) {
+                       int falloc_mode = io->u.ci_setattr.sa_falloc_mode;
+
+                       result = osc_fallocate_base(osc_export(cl2osc(obj)),
+                                                   oa, osc_async_upcall,
+                                                   cbargs, falloc_mode);
+               } else if (ia_avalid & ATTR_SIZE) {
+                       result = osc_punch_send(osc_export(cl2osc(obj)),
+                                               oa, osc_async_upcall, cbargs);
+               } else {
                        result = osc_setattr_async(osc_export(cl2osc(obj)),
                                                   oa, osc_async_upcall,
                                                   cbargs, PTLRPCD_SET);
-
+               }
                cbargs->opc_rpc_sent = result == 0;
        }
 
-       return result;
+       RETURN(result);
 }
 
-static void osc_io_setattr_end(const struct lu_env *env,
-                               const struct cl_io_slice *slice)
+void osc_io_setattr_end(const struct lu_env *env,
+                       const struct cl_io_slice *slice)
 {
        struct cl_io     *io  = slice->cis_io;
        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));
+                       LASSERT(cl_io_is_trunc(io) || cl_io_is_fallocate(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;
+
+               if (result == 0) {
+                       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);
-               if (oio->oi_trunc != NULL) {
-                       osc_cache_truncate_end(env, oio, cl2osc(obj));
-                       oio->oi_trunc = NULL;
+               osc_cache_truncate_end(env, oio->oi_trunc);
+               oio->oi_trunc = NULL;
+       }
+
+       if (cl_io_is_fallocate(io)) {
+               cl_object_attr_lock(obj);
+
+               /* update blocks */
+               if (oa->o_valid & OBD_MD_FLBLOCKS) {
+                       attr->cat_blocks = oa->o_blocks;
+                       cl_valid |= CAT_BLOCKS;
                }
+
+               /* update size */
+               if (oa->o_valid & OBD_MD_FLSIZE) {
+                       attr->cat_size = oa->o_size;
+                       cl_valid |= CAT_SIZE;
+               }
+
+               cl_object_attr_update(env, obj, attr, cl_valid);
+               cl_object_attr_unlock(obj);
        }
 }
+EXPORT_SYMBOL(osc_io_setattr_end);
 
 struct osc_data_version_args {
        struct osc_io *dva_oio;
@@ -615,9 +741,9 @@ struct osc_data_version_args {
 
 static int
 osc_data_version_interpret(const struct lu_env *env, struct ptlrpc_request *req,
-                          void *arg, int rc)
+                          void *args, int rc)
 {
-       struct osc_data_version_args *dva = arg;
+       struct osc_data_version_args *dva = args;
        struct osc_io *oio = dva->dva_oio;
        const struct ost_body *body;
 
@@ -683,8 +809,7 @@ static int osc_io_data_version_start(const struct lu_env *env,
 
        ptlrpc_request_set_replen(req);
        req->rq_interpret_reply = osc_data_version_interpret;
-       CLASSERT(sizeof(*dva) <= sizeof(req->rq_async_args));
-       dva = ptlrpc_req_async_args(req);
+       dva = ptlrpc_req_async_args(dva, req);
        dva->dva_oio = oio;
 
        ptlrpcd_add_req(req);
@@ -704,18 +829,23 @@ static void osc_io_data_version_end(const struct lu_env *env,
 
        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;
 }
 
-static int osc_io_read_start(const struct lu_env *env,
-                             const struct cl_io_slice *slice)
+int osc_io_read_start(const struct lu_env *env,
+                     const struct cl_io_slice *slice)
 {
        struct cl_object *obj  = slice->cis_obj;
        struct cl_attr   *attr = &osc_env_info(env)->oti_attr;
@@ -724,16 +854,17 @@ static int osc_io_read_start(const struct lu_env *env,
 
        if (!slice->cis_io->ci_noatime) {
                cl_object_attr_lock(obj);
-               attr->cat_atime = LTIME_S(CFS_CURRENT_TIME);
+               attr->cat_atime = ktime_get_real_seconds();
                rc = cl_object_attr_update(env, obj, attr, CAT_ATIME);
                cl_object_attr_unlock(obj);
        }
 
        RETURN(rc);
 }
+EXPORT_SYMBOL(osc_io_read_start);
 
-static int osc_io_write_start(const struct lu_env *env,
-                              const struct cl_io_slice *slice)
+int osc_io_write_start(const struct lu_env *env,
+                      const struct cl_io_slice *slice)
 {
        struct cl_object *obj   = slice->cis_obj;
        struct cl_attr   *attr  = &osc_env_info(env)->oti_attr;
@@ -742,15 +873,16 @@ static int osc_io_write_start(const struct lu_env *env,
 
        OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1);
        cl_object_attr_lock(obj);
-       attr->cat_mtime = attr->cat_ctime = LTIME_S(CFS_CURRENT_TIME);
+       attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds();
        rc = cl_object_attr_update(env, obj, attr, CAT_MTIME | CAT_CTIME);
        cl_object_attr_unlock(obj);
 
        RETURN(rc);
 }
+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,9 +907,10 @@ 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);
 
-static int osc_io_fsync_start(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)
 {
        struct cl_io       *io  = slice->cis_io;
        struct cl_fsync_io *fio = &io->u.ci_fsync;
@@ -816,8 +949,8 @@ static int osc_io_fsync_start(const struct lu_env *env,
        RETURN(result);
 }
 
-static void osc_io_fsync_end(const struct lu_env *env,
-                            const struct cl_io_slice *slice)
+void osc_io_fsync_end(const struct lu_env *env,
+                     const struct cl_io_slice *slice)
 {
        struct cl_fsync_io *fio = &slice->cis_io->u.ci_fsync;
        struct cl_object   *obj = slice->cis_obj;
@@ -837,9 +970,79 @@ static void osc_io_fsync_end(const struct lu_env *env,
        }
        slice->cis_io->ci_result = result;
 }
+EXPORT_SYMBOL(osc_io_fsync_end);
 
-static void osc_io_end(const struct lu_env *env,
-                      const struct cl_io_slice *slice)
+static int osc_io_ladvise_start(const struct lu_env *env,
+                               const struct cl_io_slice *slice)
+{
+       int                      result = 0;
+       struct cl_io            *io = slice->cis_io;
+       struct osc_io           *oio = cl2osc_io(env, slice);
+       struct cl_object        *obj = slice->cis_obj;
+       struct lov_oinfo        *loi = cl2osc(obj)->oo_oinfo;
+       struct cl_ladvise_io    *lio = &io->u.ci_ladvise;
+       struct obdo             *oa = &oio->oi_oa;
+       struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
+       struct lu_ladvise       *ladvise;
+       struct ladvise_hdr      *ladvise_hdr;
+       int                      buf_size;
+       int                      num_advise = 1;
+       ENTRY;
+
+       /* TODO: add multiple ladvise support in CLIO */
+       buf_size = offsetof(typeof(*ladvise_hdr), lah_advise[num_advise]);
+       if (osc_env_info(env)->oti_ladvise_buf.lb_len < buf_size)
+               lu_buf_realloc(&osc_env_info(env)->oti_ladvise_buf, buf_size);
+
+       ladvise_hdr = osc_env_info(env)->oti_ladvise_buf.lb_buf;
+       if (ladvise_hdr == NULL)
+               RETURN(-ENOMEM);
+
+       memset(ladvise_hdr, 0, buf_size);
+       ladvise_hdr->lah_magic = LADVISE_MAGIC;
+       ladvise_hdr->lah_count = num_advise;
+       ladvise_hdr->lah_flags = lio->li_flags;
+
+       memset(oa, 0, sizeof(*oa));
+       oa->o_oi = loi->loi_oi;
+       oa->o_valid = OBD_MD_FLID;
+       obdo_set_parent_fid(oa, lio->li_fid);
+
+       ladvise = ladvise_hdr->lah_advise;
+       ladvise->lla_start = lio->li_start;
+       ladvise->lla_end = lio->li_end;
+       ladvise->lla_advice = lio->li_advice;
+
+       if (lio->li_flags & LF_ASYNC) {
+               result = osc_ladvise_base(osc_export(cl2osc(obj)), oa,
+                                         ladvise_hdr, NULL, NULL, NULL);
+       } else {
+               init_completion(&cbargs->opc_sync);
+               result = osc_ladvise_base(osc_export(cl2osc(obj)), oa,
+                                         ladvise_hdr, osc_async_upcall,
+                                         cbargs, PTLRPCD_SET);
+               cbargs->opc_rpc_sent = result == 0;
+       }
+       RETURN(result);
+}
+
+static void osc_io_ladvise_end(const struct lu_env *env,
+                              const struct cl_io_slice *slice)
+{
+       struct cl_io            *io = slice->cis_io;
+       struct osc_io           *oio = cl2osc_io(env, slice);
+       struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
+       int                      result = 0;
+       struct cl_ladvise_io    *lio = &io->u.ci_ladvise;
+
+       if ((!(lio->li_flags & LF_ASYNC)) && cbargs->opc_rpc_sent) {
+               wait_for_completion(&cbargs->opc_sync);
+               result = cbargs->opc_rc;
+       }
+       slice->cis_io->ci_result = result;
+}
+
+void osc_io_end(const struct lu_env *env, const struct cl_io_slice *slice)
 {
        struct osc_io *oio = cl2osc_io(env, slice);
 
@@ -848,10 +1051,137 @@ static void osc_io_end(const struct lu_env *env,
                oio->oi_active = NULL;
        }
 }
+EXPORT_SYMBOL(osc_io_end);
+
+struct osc_lseek_args {
+       struct osc_io *lsa_oio;
+};
+
+static int osc_lseek_interpret(const struct lu_env *env,
+                              struct ptlrpc_request *req,
+                              void *arg, int rc)
+{
+       struct ost_body *reply;
+       struct osc_lseek_args *lsa = arg;
+       struct osc_io *oio = lsa->lsa_oio;
+       struct cl_io *io = oio->oi_cl.cis_io;
+       struct cl_lseek_io *lsio = &io->u.ci_lseek;
+
+       ENTRY;
+
+       if (rc != 0)
+               GOTO(out, rc);
+
+       reply = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
+       if (reply == NULL)
+               GOTO(out, rc = -EPROTO);
+
+       lsio->ls_result = reply->oa.o_size;
+out:
+       osc_async_upcall(&oio->oi_cbarg, rc);
+       RETURN(rc);
+}
+
+int osc_io_lseek_start(const struct lu_env *env,
+                      const struct cl_io_slice *slice)
+{
+       struct cl_io *io = slice->cis_io;
+       struct osc_io *oio = cl2osc_io(env, slice);
+       struct cl_object *obj = slice->cis_obj;
+       struct lov_oinfo *loi = cl2osc(obj)->oo_oinfo;
+       struct cl_lseek_io *lsio = &io->u.ci_lseek;
+       struct obdo *oa = &oio->oi_oa;
+       struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
+       struct obd_export *exp = osc_export(cl2osc(obj));
+       struct ptlrpc_request *req;
+       struct ost_body *body;
+       struct osc_lseek_args *lsa;
+       int rc = 0;
+
+       ENTRY;
+
+       /* No negative values at this point */
+       LASSERT(lsio->ls_start >= 0);
+       LASSERT(lsio->ls_whence == SEEK_HOLE || lsio->ls_whence == SEEK_DATA);
+
+       /* with IO lock taken we have object size in LVB and can check
+        * boundaries prior sending LSEEK RPC
+        */
+       if (lsio->ls_start >= loi->loi_lvb.lvb_size) {
+               /* consider area beyond end of object as hole */
+               if (lsio->ls_whence == SEEK_HOLE)
+                       lsio->ls_result = lsio->ls_start;
+               else
+                       lsio->ls_result = -ENXIO;
+               RETURN(0);
+       }
+
+       /* if LSEEK RPC is not supported by server, consider whole stripe
+        * object is data with hole after end of object
+        */
+       if (!exp_connect_lseek(exp)) {
+               if (lsio->ls_whence == SEEK_HOLE)
+                       lsio->ls_result = loi->loi_lvb.lvb_size;
+               else
+                       lsio->ls_result = lsio->ls_start;
+               RETURN(0);
+       }
+
+       memset(oa, 0, sizeof(*oa));
+       oa->o_oi = loi->loi_oi;
+       oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+       oa->o_size = lsio->ls_start;
+       oa->o_mode = lsio->ls_whence;
+       if (oio->oi_lockless) {
+               oa->o_flags = OBD_FL_SRVLOCK;
+               oa->o_valid |= OBD_MD_FLFLAGS;
+       }
+
+       init_completion(&cbargs->opc_sync);
+       req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SEEK);
+       if (req == NULL)
+               RETURN(-ENOMEM);
+
+       rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SEEK);
+       if (rc < 0) {
+               ptlrpc_request_free(req);
+               RETURN(rc);
+       }
+
+       body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
+       lustre_set_wire_obdo(&req->rq_import->imp_connect_data, &body->oa, oa);
+       ptlrpc_request_set_replen(req);
+       req->rq_interpret_reply = osc_lseek_interpret;
+       lsa = ptlrpc_req_async_args(lsa, req);
+       lsa->lsa_oio = oio;
+
+       ptlrpcd_add_req(req);
+       cbargs->opc_rpc_sent = 1;
+
+       RETURN(0);
+}
+EXPORT_SYMBOL(osc_io_lseek_start);
+
+void osc_io_lseek_end(const struct lu_env *env,
+                     const struct cl_io_slice *slice)
+{
+       struct osc_io *oio = cl2osc_io(env, slice);
+       struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
+       int rc = 0;
+
+       if (cbargs->opc_rpc_sent) {
+               wait_for_completion(&cbargs->opc_sync);
+               rc = cbargs->opc_rc;
+       }
+       slice->cis_io->ci_result = rc;
+}
+EXPORT_SYMBOL(osc_io_lseek_end);
 
 static const struct cl_io_operations osc_io_ops = {
        .op = {
                [CIT_READ] = {
+                       .cio_iter_init = osc_io_rw_iter_init,
+                       .cio_iter_fini = osc_io_rw_iter_fini,
                        .cio_start  = osc_io_read_start,
                        .cio_fini   = osc_io_fini
                },
@@ -863,6 +1193,8 @@ static const struct cl_io_operations osc_io_ops = {
                        .cio_fini   = osc_io_fini
                },
                [CIT_SETATTR] = {
+                       .cio_iter_init = osc_io_iter_init,
+                       .cio_iter_fini = osc_io_iter_fini,
                        .cio_start  = osc_io_setattr_start,
                        .cio_end    = osc_io_setattr_end
                },
@@ -871,6 +1203,8 @@ static const struct cl_io_operations osc_io_ops = {
                        .cio_end    = osc_io_data_version_end,
                },
                [CIT_FAULT] = {
+                       .cio_iter_init = osc_io_iter_init,
+                       .cio_iter_fini = osc_io_iter_fini,
                        .cio_start  = osc_io_fault_start,
                        .cio_end    = osc_io_end,
                        .cio_fini   = osc_io_fini
@@ -880,6 +1214,16 @@ static const struct cl_io_operations osc_io_ops = {
                        .cio_end    = osc_io_fsync_end,
                        .cio_fini   = osc_io_fini
                },
+               [CIT_LADVISE] = {
+                       .cio_start  = osc_io_ladvise_start,
+                       .cio_end    = osc_io_ladvise_end,
+                       .cio_fini   = osc_io_fini
+               },
+               [CIT_LSEEK] = {
+                       .cio_start  = osc_io_lseek_start,
+                       .cio_end    = osc_io_lseek_end,
+                       .cio_fini   = osc_io_fini
+               },
                [CIT_MISC] = {
                        .cio_fini   = osc_io_fini
                }
@@ -895,104 +1239,6 @@ static const struct cl_io_operations osc_io_ops = {
  *
  */
 
-static int osc_req_prep(const struct lu_env *env,
-                        const struct cl_req_slice *slice)
-{
-        return 0;
-}
-
-static void osc_req_completion(const struct lu_env *env,
-                               const struct cl_req_slice *slice, int ioret)
-{
-        struct osc_req *or;
-
-        or = cl2osc_req(slice);
-        OBD_SLAB_FREE_PTR(or, osc_req_kmem);
-}
-
-/**
- * Implementation of struct cl_req_operations::cro_attr_set() for osc
- * layer. osc is responsible for struct obdo::o_id and struct obdo::o_seq
- * fields.
- */
-static void osc_req_attr_set(const struct lu_env *env,
-                            const struct cl_req_slice *slice,
-                            const struct cl_object *obj,
-                            struct cl_req_attr *attr, u64 flags)
-{
-       struct lov_oinfo *oinfo;
-       struct cl_req    *clerq;
-       struct cl_page   *apage; /* _some_ page in @clerq */
-       struct ldlm_lock *lock;  /* _some_ lock protecting @apage */
-       struct osc_page  *opg;
-       struct obdo      *oa;
-       struct ost_lvb   *lvb;
-
-       oinfo   = cl2osc(obj)->oo_oinfo;
-       lvb     = &oinfo->loi_lvb;
-       oa      = attr->cra_oa;
-
-       if ((flags & OBD_MD_FLMTIME) != 0) {
-               oa->o_mtime = lvb->lvb_mtime;
-               oa->o_valid |= OBD_MD_FLMTIME;
-       }
-       if ((flags & OBD_MD_FLATIME) != 0) {
-               oa->o_atime = lvb->lvb_atime;
-               oa->o_valid |= OBD_MD_FLATIME;
-       }
-       if ((flags & OBD_MD_FLCTIME) != 0) {
-               oa->o_ctime = lvb->lvb_ctime;
-               oa->o_valid |= OBD_MD_FLCTIME;
-       }
-       if (flags & OBD_MD_FLGROUP) {
-               ostid_set_seq(&oa->o_oi, ostid_seq(&oinfo->loi_oi));
-               oa->o_valid |= OBD_MD_FLGROUP;
-       }
-       if (flags & OBD_MD_FLID) {
-               ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi));
-               oa->o_valid |= OBD_MD_FLID;
-       }
-       if (flags & OBD_MD_FLHANDLE) {
-               clerq = slice->crs_req;
-               LASSERT(!list_empty(&clerq->crq_pages));
-               apage = container_of(clerq->crq_pages.next,
-                                    struct cl_page, cp_flight);
-               opg = osc_cl_page_osc(apage, NULL);
-               lock = osc_dlmlock_at_pgoff(env, cl2osc(obj), osc_index(opg),
-                               OSC_DAP_FL_TEST_LOCK | OSC_DAP_FL_CANCELING);
-               if (lock == NULL && !opg->ops_srvlock) {
-                       struct ldlm_resource *res;
-                       struct ldlm_res_id *resname;
-
-                       CL_PAGE_DEBUG(D_ERROR, env, apage, "uncovered page!\n");
-
-                       resname = &osc_env_info(env)->oti_resname;
-                       ostid_build_res_name(&oinfo->loi_oi, resname);
-                       res = ldlm_resource_get(
-                               osc_export(cl2osc(obj))->exp_obd->obd_namespace,
-                               NULL, resname, LDLM_EXTENT, 0);
-                       ldlm_resource_dump(D_ERROR, res);
-
-                       libcfs_debug_dumpstack(NULL);
-                       LBUG();
-               }
-
-               /* check for lockless io. */
-               if (lock != NULL) {
-                       oa->o_handle = lock->l_remote_handle;
-                       oa->o_valid |= OBD_MD_FLHANDLE;
-                       LDLM_LOCK_PUT(lock);
-               }
-       }
-}
-
-static const struct cl_req_operations osc_req_ops = {
-        .cro_prep       = osc_req_prep,
-        .cro_attr_set   = osc_req_attr_set,
-        .cro_completion = osc_req_completion
-};
-
-
 int osc_io_init(const struct lu_env *env,
                 struct cl_object *obj, struct cl_io *io)
 {
@@ -1003,19 +1249,4 @@ int osc_io_init(const struct lu_env *env,
         return 0;
 }
 
-int osc_req_init(const struct lu_env *env, struct cl_device *dev,
-                struct cl_req *req)
-{
-       struct osc_req *or;
-       int result;
-
-       OBD_SLAB_ALLOC_PTR_GFP(or, osc_req_kmem, GFP_NOFS);
-       if (or != NULL) {
-               cl_req_slice_add(req, &or->or_cl, dev, &osc_req_ops);
-               result = 0;
-       } else
-               result = -ENOMEM;
-       return result;
-}
-
 /** @} osc */