Whamcloud - gitweb
LU-1254 iokit: should not use single '[]'
[fs/lustre-release.git] / lustre / cmm / cmm_object.c
index 86741be..0320890 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -284,6 +286,15 @@ static int cml_readlink(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+static int cml_changelog(const struct lu_env *env, enum changelog_rec_type type,
+                         int flags, struct md_object *mo)
+{
+        int rc;
+        ENTRY;
+        rc = mo_changelog(env, type, flags, md_object_next(mo));
+        RETURN(rc);
+}
+
 static int cml_xattr_list(const struct lu_env *env, struct md_object *mo,
                           struct lu_buf *buf)
 {
@@ -340,11 +351,11 @@ static int cml_open(const struct lu_env *env, struct md_object *mo,
 }
 
 static int cml_close(const struct lu_env *env, struct md_object *mo,
-                     struct md_attr *ma)
+                     struct md_attr *ma, int mode)
 {
         int rc;
         ENTRY;
-        rc = mo_close(env, md_object_next(mo), ma);
+        rc = mo_close(env, md_object_next(mo), ma, mode);
         RETURN(rc);
 }
 
@@ -375,24 +386,31 @@ static int cml_path(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
-static int cml_object_sync(const struct lu_env *env, struct md_object *mo)
+static int cml_file_lock(const struct lu_env *env, struct md_object *mo,
+                         struct lov_mds_md *lmm, struct ldlm_extent *extent,
+                         struct lustre_handle *lockh)
 {
         int rc;
         ENTRY;
-        rc = mo_object_sync(env, md_object_next(mo));
+        rc = mo_file_lock(env, md_object_next(mo), lmm, extent, lockh);
         RETURN(rc);
 }
 
-static dt_obj_version_t cml_version_get(const struct lu_env *env,
-                                        struct md_object *mo)
+static int cml_file_unlock(const struct lu_env *env, struct md_object *mo,
+                           struct lov_mds_md *lmm, struct lustre_handle *lockh)
 {
-        return mo_version_get(env, md_object_next(mo));
+        int rc;
+        ENTRY;
+        rc = mo_file_unlock(env, md_object_next(mo), lmm, lockh);
+        RETURN(rc);
 }
 
-static void cml_version_set(const struct lu_env *env, struct md_object *mo,
-                            dt_obj_version_t version)
+static int cml_object_sync(const struct lu_env *env, struct md_object *mo)
 {
-        return mo_version_set(env, md_object_next(mo), version);
+        int rc;
+        ENTRY;
+        rc = mo_object_sync(env, md_object_next(mo));
+        RETURN(rc);
 }
 
 static const struct md_object_operations cml_mo_ops = {
@@ -410,11 +428,12 @@ static const struct md_object_operations cml_mo_ops = {
         .moo_close         = cml_close,
         .moo_readpage      = cml_readpage,
         .moo_readlink      = cml_readlink,
+        .moo_changelog     = cml_changelog,
         .moo_capa_get      = cml_capa_get,
         .moo_object_sync   = cml_object_sync,
-        .moo_version_get   = cml_version_get,
-        .moo_version_set   = cml_version_set,
         .moo_path          = cml_path,
+        .moo_file_lock     = cml_file_lock,
+        .moo_file_unlock   = cml_file_unlock,
 };
 /** @} */
 
@@ -577,6 +596,17 @@ static int cml_unlink(const struct lu_env *env, struct md_object *mo_p,
         RETURN(rc);
 }
 
+/** Call mdo_lum_lmm_cmp() on next layer */
+static int cml_lum_lmm_cmp(const struct lu_env *env, struct md_object *mo_c,
+                           const struct md_op_spec *spec, struct md_attr *ma)
+{
+        int rc;
+        ENTRY;
+
+        rc = mdo_lum_lmm_cmp(env, md_object_next(mo_c), spec, ma);
+        RETURN(rc);
+}
+
 /**
  * \ingroup cmm
  * Get mode of object.
@@ -863,10 +893,11 @@ static const struct md_dir_operations cml_dir_ops = {
         .mdo_create      = cml_create,
         .mdo_link        = cml_link,
         .mdo_unlink      = cml_unlink,
+        .mdo_lum_lmm_cmp = cml_lum_lmm_cmp,
         .mdo_name_insert = cml_name_insert,
         .mdo_rename      = cml_rename,
         .mdo_rename_tgt  = cml_rename_tgt,
-        .mdo_create_data = cml_create_data
+        .mdo_create_data = cml_create_data,
 };
 /** @} */
 /** @} */
@@ -1024,6 +1055,12 @@ static int cmr_readlink(const struct lu_env *env, struct md_object *mo,
         return -EFAULT;
 }
 
+static int cmr_changelog(const struct lu_env *env, enum changelog_rec_type type,
+                         int flags, struct md_object *mo)
+{
+        return -EFAULT;
+}
+
 static int cmr_xattr_list(const struct lu_env *env, struct md_object *mo,
                           struct lu_buf *buf)
 {
@@ -1062,7 +1099,7 @@ static int cmr_open(const struct lu_env *env, struct md_object *mo,
 }
 
 static int cmr_close(const struct lu_env *env, struct md_object *mo,
-                     struct md_attr *ma)
+                     struct md_attr *ma, int mode)
 {
         return -EFAULT;
 }
@@ -1090,26 +1127,23 @@ static int cmr_object_sync(const struct lu_env *env, struct md_object *mo)
         return -EFAULT;
 }
 
-/**
- * cmr moo_version_get().
- */
-static dt_obj_version_t cmr_version_get(const struct lu_env *env,
-                                        struct md_object *mo)
+static int cmr_file_lock(const struct lu_env *env, struct md_object *mo,
+                         struct lov_mds_md *lmm, struct ldlm_extent *extent,
+                         struct lustre_handle *lockh)
 {
-        /** Don't check remote object version */
-        return 0;
+        return -EREMOTE;
 }
 
+static int cmr_file_unlock(const struct lu_env *env, struct md_object *mo,
+                           struct lov_mds_md *lmm, struct lustre_handle *lockh)
+{
+        return -EREMOTE;
+}
 
-/**
- * cmr moo_version_set().
- * No need to update remote object version here, it is done as a part
- * of reintegration of partial operation on the remote server.
- */
-static void cmr_version_set(const struct lu_env *env, struct md_object *mo,
-                            dt_obj_version_t version)
+static int cmr_lum_lmm_cmp(const struct lu_env *env, struct md_object *mo_c,
+                           const struct md_op_spec *spec, struct md_attr *ma)
 {
-        return;
+        return -EREMOTE;
 }
 
 /** Set of md_object_operations for cmr. */
@@ -1128,11 +1162,12 @@ static const struct md_object_operations cmr_mo_ops = {
         .moo_close         = cmr_close,
         .moo_readpage      = cmr_readpage,
         .moo_readlink      = cmr_readlink,
+        .moo_changelog     = cmr_changelog,
         .moo_capa_get      = cmr_capa_get,
         .moo_object_sync   = cmr_object_sync,
-        .moo_version_get   = cmr_version_get,
-        .moo_version_set   = cmr_version_set,
         .moo_path          = cmr_path,
+        .moo_file_lock     = cmr_file_lock,
+        .moo_file_unlock   = cmr_file_unlock,
 };
 /** @} */
 
@@ -1512,6 +1547,7 @@ static const struct md_dir_operations cmr_dir_ops = {
         .mdo_create      = cmr_create,
         .mdo_link        = cmr_link,
         .mdo_unlink      = cmr_unlink,
+        .mdo_lum_lmm_cmp = cmr_lum_lmm_cmp,
         .mdo_rename      = cmr_rename,
         .mdo_rename_tgt  = cmr_rename_tgt
 };