Whamcloud - gitweb
LU-5396 mdc: (and lmv, mgc, osc) make some functions static
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 4a76f10..f8aa9af 100644 (file)
@@ -623,22 +623,19 @@ static int __osp_attr_set(const struct lu_env *env, struct dt_object *dt,
                        RETURN(rc);
        }
 
-       if (o->opo_new)
-               /* no need in logging for new objects being created */
-               RETURN(0);
-
        if (!(attr->la_valid & (LA_UID | LA_GID)))
                RETURN(0);
 
-       if (!is_only_remote_trans(th))
+       if (!is_only_remote_trans(th)) {
                /*
                 * track all UID/GID changes via llog
                 */
                rc = osp_sync_declare_add(env, o, MDS_SETATTR64_REC, th);
-       else
+       } else {
                /* It is for OST-object attr_set directly without updating
                 * local MDT-object attribute. It is usually used by LFSCK. */
-               rc = osp_md_declare_attr_set(env, dt, attr, th);
+               rc = __osp_md_attr_set(env, dt, attr, th);
+       }
 
        if (rc != 0 || o->opo_ooa == NULL)
                RETURN(rc);
@@ -744,34 +741,15 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt,
 
        if (is_only_remote_trans(th)) {
                rc = __osp_attr_set(env, dt, attr, th);
-               if (rc != 0)
-                       RETURN(rc);
+               RETURN(rc);
        }
 
        /* we're interested in uid/gid changes only */
        if (!(attr->la_valid & (LA_UID | LA_GID)))
                RETURN(0);
 
-       /* new object, the very first ->attr_set()
-        * initializing attributes needs no logging
-        * all subsequent one are subject to the
-        * logging and synchronization with OST */
-       if (o->opo_new) {
-               o->opo_new = 0;
-               RETURN(0);
-       }
-
-       if (!is_only_remote_trans(th))
-               /*
-                * once transaction is committed put proper command on
-                * the queue going to our OST
-                */
-               rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr);
-               /* XXX: send new uid/gid to OST ASAP? */
-       else
-               /* It is for OST-object attr_set directly without updating
-                * local MDT-object attribute. It is usually used by LFSCK. */
-               rc = osp_md_attr_set(env, dt, attr, th, capa);
+       rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr);
+       /* XXX: send new uid/gid to OST ASAP? */
 
        RETURN(rc);
 }
@@ -959,9 +937,15 @@ int osp_xattr_get(const struct lu_env *env, struct dt_object *dt,
        LASSERT(name != NULL);
 
        if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_BAD_NETWORK) &&
-           osp->opd_index == cfs_fail_val &&
-           osp_dev2node(osp) == cfs_fail_val)
-               RETURN(-ENOTCONN);
+           osp->opd_index == cfs_fail_val) {
+               if (is_ost_obj(&dt->do_lu)) {
+                       if (osp_dev2node(osp) == cfs_fail_val)
+                               RETURN(-ENOTCONN);
+               } else {
+                       if (strcmp(name, XATTR_NAME_LINK) == 0)
+                               RETURN(-ENOTCONN);
+               }
+       }
 
        if (unlikely(obj->opo_non_exist))
                RETURN(-ENOENT);
@@ -1148,7 +1132,7 @@ static int __osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
 
        oxe = osp_oac_xattr_find_or_add(o, name, buf->lb_len);
        if (oxe == NULL) {
-               CWARN("%s: Fail to add xattr (%s) to cache for "DFID,
+               CWARN("%s: cannot cache xattr '%s' of "DFID"\n",
                      dt->do_lu.lo_dev->ld_obd->obd_name,
                      name, PFID(lu_object_fid(&dt->do_lu)));
 
@@ -1163,7 +1147,7 @@ static int __osp_xattr_set(const struct lu_env *env, struct dt_object *dt,
                osp_oac_xattr_put(oxe);
                oxe = tmp;
                if (tmp == NULL) {
-                       CWARN("%s: Fail to update xattr (%s) to cache for "DFID,
+                       CWARN("%s: cannot update cached xattr '%s' of "DFID"\n",
                              dt->do_lu.lo_dev->ld_obd->obd_name,
                              name, PFID(lu_object_fid(&dt->do_lu)));
                        spin_lock(&o->opo_lock);
@@ -1569,10 +1553,6 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt,
                }
        }
 
-       /* new object, the very first ->attr_set()
-        * initializing attributes needs no logging */
-       o->opo_new = 1;
-
        /* Only need update last_used oid file, seq file will only be update
         * during seq rollover */
        osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off,
@@ -1724,6 +1704,7 @@ struct dt_it *osp_it_init(const struct lu_env *env, struct dt_object *dt,
 
        it->ooi_pos_ent = -1;
        it->ooi_obj = dt;
+       it->ooi_attr = attr;
 
        return (struct dt_it *)it;
 }
@@ -1819,15 +1800,16 @@ static int osp_it_fetch(const struct lu_env *env, struct osp_it *it)
                ii->ii_fid.f_oid = osp->opd_index;
                ii->ii_fid.f_ver = 0;
                ii->ii_flags = II_FL_NOHASH;
+               ii->ii_attrs = osp_dev2node(osp);
        } else {
                ii->ii_fid = *lu_object_fid(&it->ooi_obj->do_lu);
                ii->ii_flags = II_FL_NOHASH | II_FL_NOKEY | II_FL_VARKEY |
                               II_FL_VARREC;
+               ii->ii_attrs = it->ooi_attr;
        }
        ii->ii_magic = IDX_INFO_MAGIC;
        ii->ii_count = npages * LU_PAGE_COUNT;
        ii->ii_hash_start = it->ooi_next;
-       ii->ii_attrs = osp_dev2node(osp);
 
        ptlrpc_at_set_req_timeout(req);
 
@@ -1890,6 +1872,7 @@ out:
  * \param[in] env      pointer to the thread context
  * \param[in] di       pointer to the iteration structure
  *
+ * \retval             positive for end of the directory
  * \retval             0 for success
  * \retval             negative error number on failure
  */
@@ -1915,6 +1898,7 @@ again2:
                }
                it->ooi_cur_idxpage = NULL;
                it->ooi_pos_lu_page++;
+
 again1:
                if (it->ooi_pos_lu_page < LU_PAGE_COUNT) {
                        it->ooi_cur_idxpage = (void *)it->ooi_cur_page +
@@ -1987,10 +1971,11 @@ again0:
  * \param[in] env      pointer to the thread context
  * \param[in] di       pointer to the iteration structure
  *
+ * \retval             positive for end of the directory
  * \retval             0 for success
  * \retval             negative error number on failure
  */
-int osp_orphan_it_next(const struct lu_env *env, struct dt_it *di)
+static int osp_orphan_it_next(const struct lu_env *env, struct dt_it *di)
 {
        struct osp_it           *it = (struct osp_it *)di;
        struct lu_idxpage       *idxpage;
@@ -2031,8 +2016,8 @@ void osp_it_put(const struct lu_env *env, struct dt_it *di)
 {
 }
 
-struct dt_key *osp_orphan_it_key(const struct lu_env *env,
-                                const struct dt_it *di)
+static struct dt_key *osp_orphan_it_key(const struct lu_env *env,
+                                       const struct dt_it *di)
 {
        struct osp_it   *it  = (struct osp_it *)di;
        struct lu_orphan_ent    *ent = (struct lu_orphan_ent *)it->ooi_ent;
@@ -2043,13 +2028,14 @@ struct dt_key *osp_orphan_it_key(const struct lu_env *env,
        return NULL;
 }
 
-int osp_orphan_it_key_size(const struct lu_env *env, const struct dt_it *di)
+static int osp_orphan_it_key_size(const struct lu_env *env,
+                                 const struct dt_it *di)
 {
        return sizeof(struct lu_fid);
 }
 
-int osp_orphan_it_rec(const struct lu_env *env, const struct dt_it *di,
-                     struct dt_rec *rec, __u32 attr)
+static int osp_orphan_it_rec(const struct lu_env *env, const struct dt_it *di,
+                            struct dt_rec *rec, __u32 attr)
 {
        struct osp_it   *it  = (struct osp_it *)di;
        struct lu_orphan_ent    *ent = (struct lu_orphan_ent *)it->ooi_ent;
@@ -2153,7 +2139,7 @@ static int osp_index_try(const struct lu_env *env,
        return 0;
 }
 
-struct dt_object_operations osp_obj_ops = {
+static struct dt_object_operations osp_obj_ops = {
        .do_declare_attr_get    = osp_declare_attr_get,
        .do_attr_get            = osp_attr_get,
        .do_declare_attr_set    = osp_declare_attr_set,