Whamcloud - gitweb
LU-4136 obdclass: use obd_get_info to report network status
[fs/lustre-release.git] / lustre / osp / osp_object.c
index e5ffe31..61fe85b 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -41,9 +41,6 @@
  * Author: Mikhail Pershin <mike.tappro@intel.com>
  */
 
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
 #define DEBUG_SUBSYSTEM S_MDS
 
 #include "osp_internal.h"
@@ -94,7 +91,8 @@ static int osp_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
        if (attr == NULL)
                RETURN(0);
 
-       if (attr->la_valid & LA_SIZE && attr->la_size > 0) {
+       if (attr->la_valid & LA_SIZE && attr->la_size > 0 &&
+           fid_is_zero(lu_object_fid(&o->opo_obj.do_lu))) {
                LASSERT(!dt_object_exists(dt));
                osp_object_assign_fid(env, d, o);
                rc = osp_object_truncate(env, dt, attr->la_size);
@@ -240,8 +238,8 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
 
        memcpy(fid, lu_object_fid(&dt->do_lu), sizeof(*fid));
 
-       LASSERTF(fid_is_sane(fid), "fid for osp_obj %p is insane"DFID"!\n",
-                osp_obj, PFID(fid));
+       LASSERTF(fid_is_sane(fid), "fid for osp_object %p is insane"DFID"!\n",
+                o, PFID(fid));
 
        if (!o->opo_reserved) {
                /* special case, id was assigned outside of transaction
@@ -251,7 +249,7 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
                spin_unlock(&d->opd_pre_lock);
        }
 
-       CDEBUG(D_INODE, "fid for osp_obj %p is "DFID"!\n", osp_obj, PFID(fid));
+       CDEBUG(D_INODE, "fid for osp_object %p is "DFID"\n", o, PFID(fid));
 
        /* If the precreate ends, it means it will be ready to rollover to
         * the new sequence soon, all the creation should be synchronized,
@@ -272,7 +270,9 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
                spin_lock(&d->opd_pre_lock);
                if (d->opd_gap_count > 0) {
                        int count = d->opd_gap_count;
-                       osi->osi_oi.oi_id = fid_oid(&d->opd_gap_start_fid);
+
+                       ostid_set_id(&osi->osi_oi,
+                                    fid_oid(&d->opd_gap_start_fid));
                        d->opd_gap_count = 0;
                        spin_unlock(&d->opd_pre_lock);
 
@@ -356,15 +356,27 @@ static int is_ost_obj(struct lu_object *lo)
 }
 
 static int osp_object_init(const struct lu_env *env, struct lu_object *o,
-                          const struct lu_object_conf *unused)
+                          const struct lu_object_conf *conf)
 {
        struct osp_object       *po = lu2osp_obj(o);
        int                     rc = 0;
        ENTRY;
 
-       if (is_ost_obj(o))
+       if (is_ost_obj(o)) {
                po->opo_obj.do_ops = &osp_obj_ops;
-
+       } else {
+               struct lu_attr          *la = &osp_env_info(env)->osi_attr;
+
+               po->opo_obj.do_ops = &osp_md_obj_ops;
+               o->lo_header->loh_attr |= LOHA_REMOTE;
+               rc = po->opo_obj.do_ops->do_attr_get(env, lu2dt_obj(o),
+                                                    la, NULL);
+               if (rc == 0)
+                       o->lo_header->loh_attr |=
+                               LOHA_EXISTS | (la->la_mode & S_IFMT);
+               if (rc == -ENOENT)
+                       rc = 0;
+       }
        RETURN(rc);
 }