Whamcloud - gitweb
LU-5443 lustre: replace direct HZ access with kernel APIs
[fs/lustre-release.git] / lustre / osp / osp_object.c
index 4a76f10..8d9f51a 100644 (file)
@@ -623,22 +623,23 @@ 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)) {
+               if (o->opo_new)
+                       /* no need in logging for new objects being created */
+                       RETURN(0);
+
                /*
                 * 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,8 +745,10 @@ 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);
+               if (rc == 0 && o->opo_new)
+                       o->opo_new = 0;
+
+               RETURN(rc);
        }
 
        /* we're interested in uid/gid changes only */
@@ -761,17 +764,8 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt,
                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 +953,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);
@@ -1724,6 +1724,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 +1820,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 +1892,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 +1918,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,6 +1991,7 @@ 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
  */