Whamcloud - gitweb
Mass conversion of all copyright messages to Oracle.
[fs/lustre-release.git] / lustre / cmm / cmm_object.c
index 3309687..191cf3e 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -66,12 +66,12 @@ int cmm_fld_lookup(struct cmm_device *cm, const struct lu_fid *fid,
         }
 
         if (*mds > cm->cmm_tgt_count) {
-                CERROR("Got invalid mdsno: "LPU64" (max: %u)\n",
+                CERROR("Got invalid mdsno: %x (max: %x)\n",
                        *mds, cm->cmm_tgt_count);
                 rc = -EINVAL;
         } else {
-                CDEBUG(D_INFO, "CMM: got MDS "LPU64" for sequence: "
-                       LPU64"\n", *mds, fid_seq(fid));
+                CDEBUG(D_INFO, "CMM: got MDS %x for sequence: "
+                       LPX64"\n", *mds, fid_seq(fid));
         }
 
         RETURN (rc);
@@ -160,7 +160,7 @@ static void cml_object_free(const struct lu_env *env,
 }
 
 static int cml_object_init(const struct lu_env *env, struct lu_object *lo,
-                           const struct lu_object_conf *_)
+                           const struct lu_object_conf *unused)
 {
         struct cmm_device *cd = lu2cmm_dev(lo->lo_dev);
         struct lu_device  *c_dev;
@@ -345,6 +345,15 @@ static int cml_capa_get(const struct lu_env *env, struct md_object *mo,
         RETURN(rc);
 }
 
+static int cml_path(const struct lu_env *env, struct md_object *mo,
+                    char *path, int pathlen, __u64 *recno, int *linkno)
+{
+        int rc;
+        ENTRY;
+        rc = mo_path(env, md_object_next(mo), path, pathlen, recno, linkno);
+        RETURN(rc);
+}
+
 static int cml_object_sync(const struct lu_env *env, struct md_object *mo)
 {
         int rc;
@@ -353,6 +362,18 @@ static int cml_object_sync(const struct lu_env *env, struct md_object *mo)
         RETURN(rc);
 }
 
+static dt_obj_version_t cml_version_get(const struct lu_env *env,
+                                        struct md_object *mo)
+{
+        return mo_version_get(env, md_object_next(mo));
+}
+
+static void cml_version_set(const struct lu_env *env, struct md_object *mo,
+                            dt_obj_version_t version)
+{
+        return mo_version_set(env, md_object_next(mo), version);
+}
+
 static const struct md_object_operations cml_mo_ops = {
         .moo_permission    = cml_permission,
         .moo_attr_get      = cml_attr_get,
@@ -370,6 +391,9 @@ static const struct md_object_operations cml_mo_ops = {
         .moo_readlink      = cml_readlink,
         .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,
 };
 
 /* md_dir operations */
@@ -777,14 +801,14 @@ static struct lu_device *cmr_child_dev(struct cmm_device *d, __u32 num)
         struct lu_device *next = NULL;
         struct mdc_device *mdc;
 
-        spin_lock(&d->cmm_tgt_guard);
-        list_for_each_entry(mdc, &d->cmm_targets, mc_linkage) {
+        cfs_spin_lock(&d->cmm_tgt_guard);
+        cfs_list_for_each_entry(mdc, &d->cmm_targets, mc_linkage) {
                 if (mdc->mc_num == num) {
                         next = mdc2lu_dev(mdc);
                         break;
                 }
         }
-        spin_unlock(&d->cmm_tgt_guard);
+        cfs_spin_unlock(&d->cmm_tgt_guard);
         return next;
 }
 
@@ -798,7 +822,7 @@ static void cmr_object_free(const struct lu_env *env,
 }
 
 static int cmr_object_init(const struct lu_env *env, struct lu_object *lo,
-                           const struct lu_object_conf *_)
+                           const struct lu_object_conf *unused)
 {
         struct cmm_device *cd = lu2cmm_dev(lo->lo_dev);
         struct lu_device  *c_dev;
@@ -827,7 +851,8 @@ static int cmr_object_init(const struct lu_env *env, struct lu_object *lo,
 static int cmr_object_print(const struct lu_env *env, void *cookie,
                             lu_printer_t p, const struct lu_object *lo)
 {
-        return (*p)(env, cookie, "[remote]");
+        const struct cmr_object *cro = lu2cmr_obj((struct lu_object *)lo);
+        return (*p)(env, cookie, "[remote](mds_num=%d)", cro->cmo_num);
 }
 
 static const struct lu_object_operations cmr_obj_ops = {
@@ -931,11 +956,31 @@ static int cmr_capa_get(const struct lu_env *env, struct md_object *mo,
         return -EFAULT;
 }
 
+static int cmr_path(const struct lu_env *env, struct md_object *obj,
+                    char *path, int pathlen, __u64 *recno, int *linkno)
+{
+        return -EREMOTE;
+}
+
 static int cmr_object_sync(const struct lu_env *env, struct md_object *mo)
 {
         return -EFAULT;
 }
 
+static dt_obj_version_t cmr_version_get(const struct lu_env *env,
+                                        struct md_object *mo)
+{
+        /* Don't check remote object version */
+        return 0;
+}
+
+static void cmr_version_set(const struct lu_env *env, struct md_object *mo,
+                            dt_obj_version_t version)
+{
+        /* No need to update remote object version here, it is done as a part
+         * of reintegration of partial operation on the remote server */
+}
+
 static const struct md_object_operations cmr_mo_ops = {
         .moo_permission    = cmr_permission,
         .moo_attr_get      = cmr_attr_get,
@@ -953,6 +998,9 @@ static const struct md_object_operations cmr_mo_ops = {
         .moo_readlink      = cmr_readlink,
         .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,
 };
 
 /* remote part of md_dir operations */
@@ -1274,5 +1322,5 @@ static const struct md_dir_operations cmr_dir_ops = {
         .mdo_link        = cmr_link,
         .mdo_unlink      = cmr_unlink,
         .mdo_rename      = cmr_rename,
-        .mdo_rename_tgt  = cmr_rename_tgt,
+        .mdo_rename_tgt  = cmr_rename_tgt
 };