Whamcloud - gitweb
LU-3906 tests: fix space estimation codes in run_compilebench()
[fs/lustre-release.git] / lustre / lov / lov_io.c
index 8322798..c163cfa 100644 (file)
@@ -197,6 +197,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
                 sub_io->ci_lockreq = io->ci_lockreq;
                 sub_io->ci_type    = io->ci_type;
                 sub_io->ci_no_srvlock = io->ci_no_srvlock;
+               sub_io->ci_noatime = io->ci_noatime;
 
                 lov_sub_enter(sub);
                 result = cl_io_sub_init(sub->sub_env, sub_io,
@@ -278,11 +279,12 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio,
 static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
                              struct cl_io *io)
 {
-       struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+       struct lov_stripe_md *lsm;
        int result;
+       ENTRY;
 
-        LASSERT(lio->lis_object != NULL);
-        ENTRY;
+       LASSERT(lio->lis_object != NULL);
+       lsm = lio->lis_object->lo_lsm;
 
         /*
          * Need to be optimized, we can't afford to allocate a piece of memory
@@ -374,7 +376,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
 
        LASSERT(cfs_atomic_read(&lov->lo_active_ios) > 0);
        if (cfs_atomic_dec_and_test(&lov->lo_active_ios))
-               cfs_waitq_broadcast(&lov->lo_waitq);
+               wake_up_all(&lov->lo_waitq);
        EXIT;
 }
 
@@ -846,7 +848,7 @@ static void lov_empty_io_fini(const struct lu_env *env,
         ENTRY;
 
        if (cfs_atomic_dec_and_test(&lov->lo_active_ios))
-               cfs_waitq_broadcast(&lov->lo_waitq);
+               wake_up_all(&lov->lo_waitq);
         EXIT;
 }
 
@@ -984,14 +986,23 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
                LASSERTF(0, "invalid type %d\n", io->ci_type);
        case CIT_MISC:
        case CIT_FSYNC:
-               result = +1;
+               result = 1;
                break;
        case CIT_SETATTR:
+               /* the truncate to 0 is managed by MDT:
+                * - in open, for open O_TRUNC
+                * - in setattr, for truncate
+                */
+               /* the truncate is for size > 0 so triggers a restore */
+               if (cl_io_is_trunc(io))
+                       io->ci_restore_needed = 1;
+               result = -ENODATA;
+               break;
        case CIT_READ:
        case CIT_WRITE:
        case CIT_FAULT:
-               /* TODO: need to restore the file. */
-               result = -EBADF;
+               io->ci_restore_needed = 1;
+               result = -ENODATA;
                break;
        }
        if (result == 0) {