Whamcloud - gitweb
LU-657 test: limit the write size in run_dd
[fs/lustre-release.git] / lustre / lov / lov_io.c
index e6578ed..440f357 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, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -156,7 +156,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
         sub->sub_borrowed = 0;
 
         if (lio->lis_mem_frozen) {
-                LASSERT(cfs_mutex_is_locked(&ld->ld_mutex));
+               LASSERT(mutex_is_locked(&ld->ld_mutex));
                 sub->sub_io  = &ld->ld_emrg[stripe]->emrg_subio;
                 sub->sub_env = ld->ld_emrg[stripe]->emrg_env;
                 sub->sub_borrowed = 1;
@@ -308,7 +308,8 @@ static void lov_io_slice_init(struct lov_io *lio,
        io->ci_result = 0;
        lio->lis_object = obj;
 
-       LASSERT(lio->lis_lsm != NULL);
+       LASSERT(obj->lo_lsm != NULL);
+       lio->lis_lsm = lsm_addref(obj->lo_lsm);
         lio->lis_stripe_count = lio->lis_lsm->lsm_stripe_count;
 
         switch (io->ci_type) {
@@ -627,7 +628,7 @@ static int lov_io_submit(const struct lu_env *env,
                  * In order to not make things worse, even don't try to
                  * allocate the memory with __GFP_NOWARN. -jay
                  */
-                cfs_mutex_lock(&ld->ld_mutex);
+               mutex_lock(&ld->ld_mutex);
                 lio->lis_mem_frozen = 1;
         }
 
@@ -680,7 +681,7 @@ static int lov_io_submit(const struct lu_env *env,
                                 lov_io_sub_fini(env, lio, &lio->lis_subs[i]);
                 }
                 lio->lis_mem_frozen = 0;
-                cfs_mutex_unlock(&ld->ld_mutex);
+               mutex_unlock(&ld->ld_mutex);
         }
 
         RETURN(rc);
@@ -932,13 +933,15 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
        switch (io->ci_type) {
        default:
                LBUG();
+       case CIT_MISC:
+       case CIT_READ:
+               result = 0;
+               break;
        case CIT_FSYNC:
-        case CIT_MISC:
-        case CIT_READ:
-                result = 0;
-                break;
+       case CIT_SETATTR:
+               result = +1;
+               break;
         case CIT_WRITE:
-        case CIT_SETATTR:
                 result = -EBADF;
                 break;
         case CIT_FAULT:
@@ -949,8 +952,8 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
         }
         if (result == 0)
                 cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops);
-        io->ci_result = result;
-        RETURN(result != 0);
+       io->ci_result = result < 0 ? result : 0;
+       RETURN(result != 0);
 }
 
 /** @} lov */