Whamcloud - gitweb
LU-3409 llite: silence lockdep warning in ll_md_blocking_ast
[fs/lustre-release.git] / lustre / osc / osc_io.c
index cc14b5a..c3d7f02 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, Whamcloud, Inc.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -337,7 +337,7 @@ static int osc_async_upcall(void *a, int rc)
        struct osc_async_cbargs *args = a;
 
         args->opc_rc = rc;
-        cfs_complete(&args->opc_sync);
+       complete(&args->opc_sync);
         return 0;
 }
 
@@ -449,13 +449,12 @@ static int osc_io_setattr_start(const struct lu_env *env,
         }
         memset(oa, 0, sizeof(*oa));
         if (result == 0) {
-                oa->o_id = loi->loi_id;
-                oa->o_seq = loi->loi_seq;
-                oa->o_mtime = attr->cat_mtime;
-                oa->o_atime = attr->cat_atime;
-                oa->o_ctime = attr->cat_ctime;
-                oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLATIME |
-                        OBD_MD_FLCTIME | OBD_MD_FLMTIME;
+               oa->o_oi = loi->loi_oi;
+               oa->o_mtime = attr->cat_mtime;
+               oa->o_atime = attr->cat_atime;
+               oa->o_ctime = attr->cat_ctime;
+               oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLATIME |
+                       OBD_MD_FLCTIME | OBD_MD_FLMTIME;
                 if (ia_valid & ATTR_SIZE) {
                         oa->o_size = size;
                         oa->o_blocks = OBD_OBJECT_EOF;
@@ -471,7 +470,7 @@ static int osc_io_setattr_start(const struct lu_env *env,
 
                 oinfo.oi_oa = oa;
                 oinfo.oi_capa = io->u.ci_setattr.sa_capa;
-                cfs_init_completion(&cbargs->opc_sync);
+               init_completion(&cbargs->opc_sync);
 
                 if (ia_valid & ATTR_SIZE)
                         result = osc_punch_base(osc_export(cl2osc(obj)),
@@ -482,6 +481,7 @@ static int osc_io_setattr_start(const struct lu_env *env,
                                                         &oinfo, NULL,
                                                        osc_async_upcall,
                                                         cbargs, PTLRPCD_SET);
+               cbargs->opc_rpc_sent = result == 0;
         }
         return result;
 }
@@ -493,11 +493,12 @@ static void osc_io_setattr_end(const struct lu_env *env,
        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;
-
-        cfs_wait_for_completion(&cbargs->opc_sync);
+        int result = 0;
 
-        result = io->ci_result = cbargs->opc_rc;
+       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 */
@@ -551,6 +552,7 @@ static int osc_io_write_start(const struct lu_env *env,
         ENTRY;
 
         if (oio->oi_lockless == 0) {
+               OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1);
                 cl_object_attr_lock(obj);
                 result = cl_object_attr_get(env, obj, attr);
                 if (result == 0) {
@@ -576,8 +578,7 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
        ENTRY;
 
        memset(oa, 0, sizeof(*oa));
-       oa->o_id = loi->loi_id;
-       oa->o_seq = loi->loi_seq;
+       oa->o_oi = loi->loi_oi;
        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
        /* reload size abd blocks for start and end of sync range */
@@ -590,7 +591,7 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj,
        memset(oinfo, 0, sizeof(*oinfo));
        oinfo->oi_oa = oa;
        oinfo->oi_capa = fio->fi_capa;
-       cfs_init_completion(&cbargs->opc_sync);
+       init_completion(&cbargs->opc_sync);
 
        rc = osc_sync_base(osc_export(obj), oinfo, osc_async_upcall, cbargs,
                           PTLRPCD_SET);
@@ -652,7 +653,7 @@ static void osc_io_fsync_end(const struct lu_env *env,
                struct osc_io           *oio    = cl2osc_io(env, slice);
                struct osc_async_cbargs *cbargs = &oio->oi_cbarg;
 
-               cfs_wait_for_completion(&cbargs->opc_sync);
+               wait_for_completion(&cbargs->opc_sync);
                if (result == 0)
                        result = cbargs->opc_rc;
        }
@@ -738,29 +739,44 @@ static void osc_req_completion(const struct lu_env *env,
  * 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, obd_valid flags)
+                            const struct cl_req_slice *slice,
+                            const struct cl_object *obj,
+                            struct cl_req_attr *attr, obd_valid flags)
 {
-        struct lov_oinfo *oinfo;
-        struct cl_req    *clerq;
-        struct cl_page   *apage; /* _some_ page in @clerq */
-        struct cl_lock   *lock;  /* _some_ lock protecting @apage */
-        struct osc_lock  *olck;
-        struct osc_page  *opg;
-        struct obdo      *oa;
-
-        oa = attr->cra_oa;
-        oinfo = cl2osc(obj)->oo_oinfo;
-        if (flags & OBD_MD_FLID) {
-                oa->o_id = oinfo->loi_id;
-                oa->o_valid |= OBD_MD_FLID;
-        }
-        if (flags & OBD_MD_FLGROUP) {
-                oa->o_seq = oinfo->loi_seq;
-                oa->o_valid |= OBD_MD_FLGROUP;
-        }
-        if (flags & OBD_MD_FLHANDLE) {
+       struct lov_oinfo *oinfo;
+       struct cl_req    *clerq;
+       struct cl_page   *apage; /* _some_ page in @clerq */
+       struct cl_lock   *lock;  /* _some_ lock protecting @apage */
+       struct osc_lock  *olck;
+       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(!cfs_list_empty(&clerq->crq_pages));
                 apage = container_of(clerq->crq_pages.next,