Whamcloud - gitweb
LU-3448 llite: call simple_setattr() from ll_md_setattr()
[fs/lustre-release.git] / lustre / lov / lov_io.c
index 39c254f..8322798 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, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -968,4 +968,38 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
        RETURN(result != 0);
 }
 
+int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
+                       struct cl_io *io)
+{
+       struct lov_object *lov = cl2lov(obj);
+       struct lov_io *lio = lov_env_io(env);
+       int result;
+       ENTRY;
+
+       LASSERT(lov->lo_lsm != NULL);
+       lio->lis_object = lov;
+
+       switch (io->ci_type) {
+       default:
+               LASSERTF(0, "invalid type %d\n", io->ci_type);
+       case CIT_MISC:
+       case CIT_FSYNC:
+               result = +1;
+               break;
+       case CIT_SETATTR:
+       case CIT_READ:
+       case CIT_WRITE:
+       case CIT_FAULT:
+               /* TODO: need to restore the file. */
+               result = -EBADF;
+               break;
+       }
+       if (result == 0) {
+               cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops);
+               cfs_atomic_inc(&lov->lo_active_ios);
+       }
+
+       io->ci_result = result < 0 ? result : 0;
+       RETURN(result != 0);
+}
 /** @} lov */