* or osp_declare_xattr_get(). That is usually for LFSCK purpose,
* but it also can be shared by others.
*
+ *
+ * XXX: NOT prepare out RPC for remote transaction. ((please refer to the
+ * comment of osp_trans_create() for remote transaction)
+ *
+ * According to our current transaction/dt_object_lock framework (to make
+ * the cross-MDTs modification for DNE1 to be workable), the transaction
+ * sponsor will start the transaction firstly, then try to acquire related
+ * dt_object_lock if needed. Under such rules, if we want to prepare the
+ * OUT RPC in the transaction declare phase, then related attr/xattr
+ * should be known without dt_object_lock. But such condition maybe not
+ * true for some remote transaction case. For example:
+ *
+ * For linkEA repairing (by LFSCK) case, before the LFSCK thread obtained
+ * the dt_object_lock on the target MDT-object, it cannot know whether
+ * the MDT-object has linkEA or not, neither invalid or not.
+ *
+ * Since the LFSCK thread cannot hold dt_object_lock before the remote
+ * transaction start (otherwise there will be some potential deadlock),
+ * it cannot prepare related OUT RPC for repairing during the declare
+ * phase as other normal transactions do.
+ *
+ * To resolve the trouble, we will make OSP to prepare related OUT RPC
+ * after remote transaction started, and trigger the remote updating
+ * (send RPC) when trans_stop. Then the up layer users, such as LFSCK,
+ * can follow the general rule to handle trans_start/dt_object_lock
+ * for repairing linkEA inconsistency without distinguishing remote
+ * MDT-object.
+ *
+ * In fact, above solution for remote transaction should be the normal
+ * model without considering DNE1. The trouble brought by DNE1 will be
+ * resolved in DNE2. At that time, this patch can be removed.
+ *
+ *
* Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
* Author: Mikhail Pershin <mike.tappro@intel.com>
*/
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);
/**
* Implement OSP layer dt_object_operations::do_declare_attr_set() interface.
- * XXX: NOT prepare set_{attr,xattr} RPC for remote transaction.
- *
- * According to our current transaction/dt_object_lock framework (to make
- * the cross-MDTs modification for DNE1 to be workable), the transaction
- * sponsor will start the transaction firstly, then try to acquire related
- * dt_object_lock if needed. Under such rules, if we want to prepare the
- * set_{attr,xattr} RPC in the RPC declare phase, then related attr/xattr
- * should be known without dt_object_lock. But such condition maybe not
- * true for some remote transaction case. For example:
- *
- * For linkEA repairing (by LFSCK) case, before the LFSCK thread obtained
- * the dt_object_lock on the target MDT-object, it cannot know whether
- * the MDT-object has linkEA or not, neither invalid or not.
- *
- * Since the LFSCK thread cannot hold dt_object_lock before the (remote)
- * transaction start (otherwise there will be some potential deadlock),
- * it cannot prepare related RPC for repairing during the declare phase
- * as other normal transactions do.
- *
- * To resolve the trouble, we will make OSP to prepare related RPC
- * (set_attr/set_xattr/del_xattr) after remote transaction started,
- * and trigger the remote updating (RPC sending) when trans_stop.
- * Then the up layer users, such as LFSCK, can follow the general
- * rule to handle trans_start/dt_object_lock for repairing linkEA
- * inconsistency without distinguishing remote MDT-object.
*
- * In fact, above solution for remote transaction should be the normal
- * model without considering DNE1. The trouble brought by DNE1 will be
- * resolved in DNE2. At that time, this patch can be removed.
+ * If the transaction is not remote one, then declare the credits that will
+ * be used for the subsequent llog record for the object's attributes.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
{
int rc = 0;
- if (!is_only_remote_trans(th))
+ if (!is_only_remote_trans(th)) {
rc = __osp_attr_set(env, dt, attr, th);
+ CDEBUG(D_INFO, "declare set attr "DFID": rc = %d\n",
+ PFID(&dt->do_lu.lo_header->loh_fid), rc);
+ }
+
return rc;
}
*
* Set attribute to the specified OST object.
*
- * If the transaction is a remote transaction, then related modification
- * sub-request has been added in the declare phase and related OUT RPC
- * has been triggered at transaction start. Otherwise it will generate
- * a MDS_SETATTR64_REC record in the llog. There is a dedicated thread
- * to handle the llog asynchronously.
+ * If the transaction is a remote one, then add OUT_ATTR_SET sub-request
+ * in the OUT RPC that will be flushed when the remote transaction stop.
+ * Otherwise, it will generate a MDS_SETATTR64_REC record in the llog that
+ * will be handled by a dedicated thread asynchronously.
*
* If the attribute entry exists in the OSP object attributes cache,
* then update the cached attribute according to given attribute.
if (is_only_remote_trans(th)) {
rc = __osp_attr_set(env, dt, attr, th);
- if (rc != 0)
- RETURN(rc);
+
+ CDEBUG(D_INFO, "(1) set attr "DFID": rc = %d\n",
+ PFID(&dt->do_lu.lo_header->loh_fid), 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);
- }
+ rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr);
+ /* XXX: send new uid/gid to OST ASAP? */
- 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);
+ CDEBUG(D_INFO, "(2) set attr "DFID": rc = %d\n",
+ PFID(&dt->do_lu.lo_header->loh_fid), rc);
RETURN(rc);
}
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)));
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);
* Declare that the caller will set extended attribute to the specified
* MDT/OST object.
*
- * This function will add an OUT_XATTR_SET sub-request to the per
- * OSP-transaction based request queue which will be flushed when
- * the transaction starts.
+ * If it is non-remote transaction, it will add an OUT_XATTR_SET sub-request
+ * to the OUT RPC that will be flushed when the transaction start. And if the
+ * OSP attributes cache is initialized, then check whether the name extended
+ * attribute entry exists in the cache or not. If yes, replace it; otherwise,
+ * add the extended attribute to the cache.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
{
int rc = 0;
- /* Please check the comment in osp_attr_set() for handling
- * remote transaction. */
- if (!is_only_remote_trans(th))
+ if (!is_only_remote_trans(th)) {
rc = __osp_xattr_set(env, dt, buf, name, flag, th);
+ CDEBUG(D_INFO, "declare xattr %s set object "DFID": rc = %d\n",
+ name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
+ }
+
return rc;
}
*
* Set extended attribute to the specified MDT/OST object.
*
- * The real modification sub-request has been added in the declare phase
- * and related (OUT) RPC has been triggered when transaction start.
- *
- * If the OSP attributes cache is initialized, then check whether the name
- * extended attribute entry exists in the cache or not. If yes, replace it;
- * otherwise, add the extended attribute to the cache.
+ * If it is remote transaction, it will add an OUT_XATTR_SET sub-request into
+ * the OUT RPC that will be flushed when the transaction stop. And if the OSP
+ * attributes cache is initialized, then check whether the name extended
+ * attribute entry exists in the cache or not. If yes, replace it; otherwise,
+ * add the extended attribute to the cache.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
{
int rc = 0;
- CDEBUG(D_INFO, "xattr %s set object "DFID"\n", name,
- PFID(&dt->do_lu.lo_header->loh_fid));
-
- /* Please check the comment in osp_attr_set() for handling
- * remote transaction. */
- if (is_only_remote_trans(th))
+ if (is_only_remote_trans(th)) {
rc = __osp_xattr_set(env, dt, buf, name, fl, th);
+ CDEBUG(D_INFO, "xattr %s set object "DFID": rc = %d\n",
+ name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
+ }
+
return rc;
}
* Declare that the caller will delete extended attribute on the specified
* MDT/OST object.
*
- * This function will add an OUT_XATTR_DEL sub-request to the per
- * OSP-transaction based request queue which will be flushed when
- * transaction start.
+ * If it is non-remote transaction, it will add an OUT_XATTR_DEL sub-request
+ * to the OUT RPC that will be flushed when the transaction start. And if the
+ * name extended attribute entry exists in the OSP attributes cache, then remove
+ * it from the cache.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
{
int rc = 0;
- /* Please check the comment in osp_attr_set() for handling
- * remote transaction. */
- if (!is_only_remote_trans(th))
+ if (!is_only_remote_trans(th)) {
rc = __osp_xattr_del(env, dt, name, th);
+ CDEBUG(D_INFO, "declare xattr %s del object "DFID": rc = %d\n",
+ name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
+ }
+
return rc;
}
*
* Delete extended attribute on the specified MDT/OST object.
*
- * The real modification sub-request has been added in the declare phase
- * and related (OUT) RPC has been triggered when transaction start.
- *
- * If the name extended attribute entry exists in the OSP attributes
- * cache, then remove it from the cache.
+ * If it is remote transaction, it will add an OUT_XATTR_DEL sub-request into
+ * the OUT RPC that will be flushed when the transaction stop. And if the name
+ * extended attribute entry exists in the OSP attributes cache, then remove it
+ * from the cache.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
{
int rc = 0;
- CDEBUG(D_INFO, "xattr %s del object "DFID"\n", name,
- PFID(&dt->do_lu.lo_header->loh_fid));
-
- /* Please check the comment in osp_attr_set() for handling
- * remote transaction. */
- if (is_only_remote_trans(th))
+ if (is_only_remote_trans(th)) {
rc = __osp_xattr_del(env, dt, name, th);
+ CDEBUG(D_INFO, "xattr %s del object "DFID": rc = %d\n",
+ name, PFID(&dt->do_lu.lo_header->loh_fid), rc);
+ }
+
return rc;
}
*
* Declare that the caller will create the OST object.
*
- * If the transaction is a remote transaction (please refer to the
- * comment of osp_trans_create() for remote transaction), then the FID
- * for the OST object has been assigned already, and will be handled
- * as create (remote) MDT object via osp_md_declare_object_create().
- * This function is usually used for LFSCK to re-create the lost OST
- * object. Otherwise, if it is not replay case, the OSP will reserve
- * pre-created object for the subsequent create operation; if the MDT
- * side cached pre-created objects are less than some threshold, then
- * it will wakeup the pre-create thread.
+ * If the transaction is a remote transaction and the FID for the OST-object
+ * has been assigned already, then handle it as creating (remote) MDT object
+ * via osp_md_declare_object_create(). This function is usually used for LFSCK
+ * to re-create the lost OST object. Otherwise, if it is not replay case, the
+ * OSP will reserve pre-created object for the subsequent create operation;
+ * if the MDT side cached pre-created objects are less than some threshold,
+ * then it will wakeup the pre-create thread.
*
* \param[in] env pointer to the thread context
* \param[in] dt pointer to the OSP layer dt_object
ENTRY;
- if (is_only_remote_trans(th)) {
+ if (is_only_remote_trans(th) && !fid_is_zero(fid)) {
LASSERT(fid_is_sane(fid));
rc = osp_md_declare_object_create(env, dt, attr, hint, dof, th);
*
* Create the OST object.
*
- * For remote transaction case, the real create sub-request has been
- * added in the declare phase and related (OUT) RPC has been triggered
- * at transaction start. Here, like creating (remote) MDT object, the
- * OSP will mark the object existence via osp_md_object_create().
- *
- * For non-remote transaction case, the OSP will assign FID to the
+ * If the transaction is a remote transaction and the FID for the OST-object
+ * has been assigned already, then handle it as handling MDT object via the
+ * osp_md_object_create(). For other cases, the OSP will assign FID to the
* object to be created, and update last_used Object ID (OID) file.
*
* \param[in] env pointer to the thread context
struct lu_fid *fid = &osi->osi_fid;
ENTRY;
- if (is_only_remote_trans(th)) {
+ if (is_only_remote_trans(th) &&
+ !fid_is_zero(lu_object_fid(&dt->do_lu))) {
LASSERT(fid_is_sane(lu_object_fid(&dt->do_lu)));
rc = osp_md_object_create(env, dt, attr, hint, dof, th);
}
}
- /* 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,
it->ooi_pos_ent = -1;
it->ooi_obj = dt;
+ it->ooi_attr = attr;
return (struct dt_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);
* \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
*/
}
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 +
* \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;
{
}
-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;
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;
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,