From aaf755642e789765dd8eac1137c2f5557ff03c58 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Thu, 20 Nov 2014 13:21:40 +0800 Subject: [PATCH] LU-6231 osp: prepare OUT RPC after remote transaction start 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. Signed-off-by: Fan Yong Change-Id: Ib2ed4c290c9ae12b6f544575aa5313f0dc83a5af Reviewed-on: http://review.whamcloud.com/13710 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: wangdi Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/osp/osp_md_object.c | 366 +++++++++++++++++++++++++++++++++------------ lustre/osp/osp_object.c | 188 ++++++++++++----------- 2 files changed, 372 insertions(+), 182 deletions(-) diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index c32b92f..2f50b6a 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -60,29 +60,27 @@ static const char dot[] = "."; static const char dotdot[] = ".."; /** - * Implementation of dt_object_operations::do_declare_create + * Add OUT_CREATE sub-request into the OUT RPC. * - * Insert object create update into the RPC, which will be sent during - * transaction start. Note: if the object has already been created, - * we must add object destroy updates ahead of create updates, so it will - * destroy then recreate the object. + * Note: if the object has already been created, we must add object + * destroy sub-request ahead of the create, so it will destroy then + * re-create the object. * * \param[in] env execution environment - * \param[in] dt remote object to be created + * \param[in] dt object to be created * \param[in] attr attribute of the created object * \param[in] hint creation hint * \param[in] dof creation format information * \param[in] th the transaction handle * - * \retval 0 if the insertion succeeds. - * \retval negative errno if the insertion fails. + * \retval only return 0 for now */ -int osp_md_declare_object_create(const struct lu_env *env, - struct dt_object *dt, - struct lu_attr *attr, - struct dt_allocation_hint *hint, - struct dt_object_format *dof, - struct thandle *th) +static int __osp_md_declare_object_create(const struct lu_env *env, + struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *th) { struct dt_update_request *update; int rc; @@ -154,8 +152,47 @@ out: } /** + * Implementation of dt_object_operations::do_declare_create + * + * For non-remote transaction, it will add an OUT_CREATE sub-request + * into the OUT RPC that will be flushed when the transaction start. + * + * \param[in] env execution environment + * \param[in] dt remote object to be created + * \param[in] attr attribute of the created object + * \param[in] hint creation hint + * \param[in] dof creation format information + * \param[in] th the transaction handle + * + * \retval 0 if the insertion succeeds. + * \retval negative errno if the insertion fails. + */ +int osp_md_declare_object_create(const struct lu_env *env, + struct dt_object *dt, + struct lu_attr *attr, + struct dt_allocation_hint *hint, + struct dt_object_format *dof, + struct thandle *th) +{ + int rc = 0; + + if (!is_only_remote_trans(th)) { + rc = __osp_md_declare_object_create(env, dt, attr, hint, + dof, th); + + CDEBUG(D_INFO, "declare create md_object "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; +} + +/** * Implementation of dt_object_operations::do_create * + * For remote transaction, it will add an OUT_CREATE sub-request into + * the OUT RPC that will be flushed when the transaction stop. + * * It sets necessary flags for created object. In DNE phase I, * remote updates are actually executed during transaction start, * i.e. the object has already been created when calling this method. @@ -173,24 +210,27 @@ int osp_md_object_create(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr, struct dt_allocation_hint *hint, struct dt_object_format *dof, struct thandle *th) { - CDEBUG(D_INFO, "create object "DFID"\n", - PFID(&dt->do_lu.lo_header->loh_fid)); + int rc = 0; - /* Because the create update RPC will be sent during declare phase, - * if creation reaches here, it means the object has been created - * successfully */ - dt->do_lu.lo_header->loh_attr |= LOHA_EXISTS | (attr->la_mode & S_IFMT); - dt2osp_obj(dt)->opo_non_exist = 0; + if (is_only_remote_trans(th)) { + rc = __osp_md_declare_object_create(env, dt, attr, hint, + dof, th); - return 0; + CDEBUG(D_INFO, "create md_object "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + if (rc == 0) { + dt->do_lu.lo_header->loh_attr |= LOHA_EXISTS | + (attr->la_mode & S_IFMT); + dt2osp_obj(dt)->opo_non_exist = 0; + } + + return rc; } /** - * Implementation of dt_object_operations::do_declare_ref_del - * - * Declare decreasing the reference count of the remote object, i.e. insert - * decreasing object reference count update into the RPC, which will be sent - * during transaction start. + * Add OUT_REF_DEL sub-request into the OUT RPC. * * \param[in] env execution environment * \param[in] dt object to decrease the reference count. @@ -199,9 +239,8 @@ int osp_md_object_create(const struct lu_env *env, struct dt_object *dt, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -static int osp_md_declare_object_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int __osp_md_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct dt_update_request *update; int rc; @@ -221,11 +260,38 @@ static int osp_md_declare_object_ref_del(const struct lu_env *env, } /** + * Implementation of dt_object_operations::do_declare_ref_del + * + * For non-remote transaction, it will add an OUT_REF_DEL sub-request + * into the OUT RPC that will be flushed when the transaction start. + * + * \param[in] env execution environment + * \param[in] dt object to decrease the reference count. + * \param[in] th the transaction handle of refcount decrease. + * + * \retval 0 if the insertion succeeds. + * \retval negative errno if the insertion fails. + */ +static int osp_md_declare_ref_del(const struct lu_env *env, + struct dt_object *dt, struct thandle *th) +{ + int rc = 0; + + if (!is_only_remote_trans(th)) { + rc = __osp_md_ref_del(env, dt, th); + + CDEBUG(D_INFO, "declare ref del "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; +} + +/** * Implementation of dt_object_operations::do_ref_del * - * Do nothing in this method for now. In DNE phase I, remote updates are - * actually executed during transaction start, i.e. the object reference - * count has already been decreased when calling this method. + * For remote transaction, it will add an OUT_REF_DEL sub-request into + * the OUT RPC that will be flushed when the transaction stop. * * \param[in] env execution environment * \param[in] dt object to decrease the reference count @@ -233,21 +299,23 @@ static int osp_md_declare_object_ref_del(const struct lu_env *env, * * \retval only return 0 for now */ -static int osp_md_object_ref_del(const struct lu_env *env, - struct dt_object *dt, - struct thandle *th) +static int osp_md_ref_del(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { - CDEBUG(D_INFO, "ref del object "DFID"\n", - PFID(&dt->do_lu.lo_header->loh_fid)); + int rc = 0; - return 0; + if (is_only_remote_trans(th)) { + rc = __osp_md_ref_del(env, dt, th); + + CDEBUG(D_INFO, "ref del "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; } /** - * Implementation of dt_object_operations::do_declare_ref_del - * - * Declare increasing the reference count of the remote object, - * i.e. insert increasing object reference count update into RPC. + * Add OUT_REF_ADD sub-request into the OUT RPC. * * \param[in] env execution environment * \param[in] dt object on which to increase the reference count. @@ -256,8 +324,8 @@ static int osp_md_object_ref_del(const struct lu_env *env, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -static int osp_md_declare_ref_add(const struct lu_env *env, - struct dt_object *dt, struct thandle *th) +static int __osp_md_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { struct dt_update_request *update; int rc; @@ -278,11 +346,38 @@ static int osp_md_declare_ref_add(const struct lu_env *env, } /** + * Implementation of dt_object_operations::do_declare_ref_del + * + * For non-remote transaction, it will add an OUT_REF_ADD sub-request + * into the OUT RPC that will be flushed when the transaction start. + * + * \param[in] env execution environment + * \param[in] dt object on which to increase the reference count. + * \param[in] th the transaction handle. + * + * \retval 0 if the insertion succeeds. + * \retval negative errno if the insertion fails. + */ +static int osp_md_declare_ref_add(const struct lu_env *env, + struct dt_object *dt, struct thandle *th) +{ + int rc = 0; + + if (!is_only_remote_trans(th)) { + rc = __osp_md_ref_add(env, dt, th); + + CDEBUG(D_INFO, "declare ref add "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; +} + +/** * Implementation of dt_object_operations::do_ref_add * - * Do nothing in this method for now. In DNE phase I, remote updates are - * actually executed during transaction start, i.e. the object reference - * count has already been increased when calling this method. + * For remote transaction, it will add an OUT_REF_ADD sub-request into + * the OUT RPC that will be flushed when the transaction stop. * * \param[in] env execution environment * \param[in] dt object on which to increase the reference count @@ -290,13 +385,19 @@ static int osp_md_declare_ref_add(const struct lu_env *env, * * \retval only return 0 for now */ -static int osp_md_object_ref_add(const struct lu_env *env, struct dt_object *dt, - struct thandle *th) +static int osp_md_ref_add(const struct lu_env *env, struct dt_object *dt, + struct thandle *th) { - CDEBUG(D_INFO, "ref add object "DFID"\n", - PFID(&dt->do_lu.lo_header->loh_fid)); + int rc = 0; - return 0; + if (is_only_remote_trans(th)) { + rc = __osp_md_ref_add(env, dt, th); + + CDEBUG(D_INFO, "ref add "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; } /** @@ -326,7 +427,7 @@ static void osp_md_ah_init(const struct lu_env *env, } /** - * Add attr_set sub-request into the OUT RPC. + * Add OUT_ATTR_SET sub-request into the OUT RPC. * * \param[in] env execution environment * \param[in] dt object on which to set attributes @@ -362,9 +463,8 @@ int __osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, * * Declare setting attributes to the specified remote object. * - * If the transaction is a remote transaction, then add the modification - * sub-request into the OUT RPC here, and such OUT RPC will be triggered - * when transaction start. + * If the transaction is a non-remote transaction, then add the OUT_ATTR_SET + * sub-request into the OUT RPC that will be flushed when the transaction start. * * \param[in] env execution environment * \param[in] dt object on which to set attributes @@ -379,12 +479,13 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, { int rc = 0; - CDEBUG(D_INFO, "declare attr set object "DFID"\n", - PFID(&dt->do_lu.lo_header->loh_fid)); - - if (!is_only_remote_trans(th)) + if (!is_only_remote_trans(th)) { rc = __osp_md_attr_set(env, dt, attr, th); + CDEBUG(D_INFO, "declare attr set md_object "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + return rc; } @@ -393,11 +494,8 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, * * Set attributes to the specified remote 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, the modification - * sub-request will be added here, and related OUT RPC will be triggered - * when transaction stop. + * If the transaction is a remote transaction, then add the OUT_ATTR_SET + * sub-request into the OUT RPC that will be flushed when the transaction stop. * * \param[in] env execution environment * \param[in] dt object to set attributes @@ -413,13 +511,14 @@ int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, { int rc = 0; - CDEBUG(D_INFO, "attr set object "DFID"\n", - PFID(&dt->do_lu.lo_header->loh_fid)); - - if (is_only_remote_trans(th)) + if (is_only_remote_trans(th)) { rc = __osp_md_attr_set(env, dt, attr, th); - RETURN(rc); + CDEBUG(D_INFO, "attr set md_object "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + } + + return rc; } /** @@ -610,10 +709,7 @@ out: } /** - * Implementation of dt_index_operations::dio_declare_insert - * - * Declare the index insert of the remote object, i.e. pack index insert update - * into the RPC, which will be sent during transaction start. + * Add OUT_INDEX_INSERT sub-request into the OUT RPC. * * \param[in] env execution environment * \param[in] dt object for which to insert index @@ -624,7 +720,7 @@ out: * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -static int osp_md_declare_insert(const struct lu_env *env, +static int __osp_md_index_insert(const struct lu_env *env, struct dt_object *dt, const struct dt_rec *rec, const struct dt_key *key, @@ -648,11 +744,45 @@ static int osp_md_declare_insert(const struct lu_env *env, } /** + * Implementation of dt_index_operations::dio_declare_insert + * + * For non-remote transaction, it will add an OUT_INDEX_INSERT sub-request + * into the OUT RPC that will be flushed when the transaction start. + * + * \param[in] env execution environment + * \param[in] dt object for which to insert index + * \param[in] rec record of the index which will be inserted + * \param[in] key key of the index which will be inserted + * \param[in] th the transaction handle + * + * \retval 0 if the insertion succeeds. + * \retval negative errno if the insertion fails. + */ +static int osp_md_declare_index_insert(const struct lu_env *env, + struct dt_object *dt, + const struct dt_rec *rec, + const struct dt_key *key, + struct thandle *th) +{ + int rc = 0; + + if (!is_only_remote_trans(th)) { + rc = __osp_md_index_insert(env, dt, rec, key, th); + + CDEBUG(D_INFO, "declare index insert "DFID" key %s, rec "DFID + ": rc = %d\n", PFID(&dt->do_lu.lo_header->loh_fid), + (char *)key, + PFID(((struct dt_insert_rec *)rec)->rec_fid), rc); + } + + return rc; +} + +/** * Implementation of dt_index_operations::dio_insert * - * Do nothing in this method for now. In DNE phase I, remote updates - * are actually executed during transaction start, i.e. the index has - * already been inserted when calling this method. + * For remote transaction, it will add an OUT_INDEX_INSERT sub-request + * into the OUT RPC that will be flushed when the transaction stop. * * \param[in] env execution environment * \param[in] dt object for which to insert index @@ -672,14 +802,22 @@ static int osp_md_index_insert(const struct lu_env *env, struct lustre_capa *capa, int ignore_quota) { - return 0; + int rc = 0; + + if (is_only_remote_trans(th)) { + rc = __osp_md_index_insert(env, dt, rec, key, th); + + CDEBUG(D_INFO, "index insert "DFID" key %s, rec "DFID + ": rc = %d\n", PFID(&dt->do_lu.lo_header->loh_fid), + (char *)key, + PFID(((struct dt_insert_rec *)rec)->rec_fid), rc); + } + + return rc; } /** - * Implementation of dt_index_operations::dio_declare_delete - * - * Declare the index delete of the remote object, i.e. insert index delete - * update into the RPC, which will be sent during transaction start. + * Add OUT_INDEX_DELETE sub-request into the OUT RPC. * * \param[in] env execution environment * \param[in] dt object for which to delete index @@ -689,7 +827,7 @@ static int osp_md_index_insert(const struct lu_env *env, * \retval 0 if the insertion succeeds. * \retval negative errno if the insertion fails. */ -static int osp_md_declare_delete(const struct lu_env *env, +static int __osp_md_index_delete(const struct lu_env *env, struct dt_object *dt, const struct dt_key *key, struct thandle *th) @@ -712,11 +850,41 @@ static int osp_md_declare_delete(const struct lu_env *env, } /** + * Implementation of dt_index_operations::dio_declare_delete + * + * For non-remote transaction, it will add an OUT_INDEX_DELETE sub-request + * into the OUT RPC that will be flushed when the transaction start. + * + * \param[in] env execution environment + * \param[in] dt object for which to delete index + * \param[in] key key of the index + * \param[in] th the transaction handle + * + * \retval 0 if the insertion succeeds. + * \retval negative errno if the insertion fails. + */ +static int osp_md_declare_index_delete(const struct lu_env *env, + struct dt_object *dt, + const struct dt_key *key, + struct thandle *th) +{ + int rc = 0; + + if (!is_only_remote_trans(th)) { + rc = __osp_md_index_delete(env, dt, key, th); + + CDEBUG(D_INFO, "declare index delete "DFID" %s: rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), (char *)key, rc); + } + + return rc; +} + +/** * Implementation of dt_index_operations::dio_delete * - * Do nothing in this method for now. Because in DNE phase I, remote updates - * are actually executed during transaction start, i.e. the index has already - * been deleted when calling this method. + * For remote transaction, it will add an OUT_INDEX_DELETE sub-request + * into the OUT RPC that will be flushed when the transaction stop. * * \param[in] env execution environment * \param[in] dt object for which to delete index @@ -732,10 +900,16 @@ static int osp_md_index_delete(const struct lu_env *env, struct thandle *th, struct lustre_capa *capa) { - CDEBUG(D_INFO, "index delete "DFID" %s\n", - PFID(&dt->do_lu.lo_header->loh_fid), (char *)key); + int rc = 0; - return 0; + if (is_only_remote_trans(th)) { + rc = __osp_md_index_delete(env, dt, key, th); + + CDEBUG(D_INFO, "index delete "DFID" %s: rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), (char *)key, rc); + } + + return rc; } /** @@ -891,9 +1065,9 @@ static int osp_it_load(const struct lu_env *env, const struct dt_it *di, const struct dt_index_operations osp_md_index_ops = { .dio_lookup = osp_md_index_lookup, - .dio_declare_insert = osp_md_declare_insert, + .dio_declare_insert = osp_md_declare_index_insert, .dio_insert = osp_md_index_insert, - .dio_declare_delete = osp_md_declare_delete, + .dio_declare_delete = osp_md_declare_index_delete, .dio_delete = osp_md_index_delete, .dio_it = { .init = osp_it_init, @@ -1018,9 +1192,9 @@ struct dt_object_operations osp_md_obj_ops = { .do_declare_create = osp_md_declare_object_create, .do_create = osp_md_object_create, .do_declare_ref_add = osp_md_declare_ref_add, - .do_ref_add = osp_md_object_ref_add, - .do_declare_ref_del = osp_md_declare_object_ref_del, - .do_ref_del = osp_md_object_ref_del, + .do_ref_add = osp_md_ref_add, + .do_declare_ref_del = osp_md_declare_ref_del, + .do_ref_del = osp_md_ref_del, .do_declare_destroy = osp_declare_object_destroy, .do_destroy = osp_object_destroy, .do_ah_init = osp_md_ah_init, diff --git a/lustre/osp/osp_object.c b/lustre/osp/osp_object.c index f8aa9af..be29d0c 100644 --- a/lustre/osp/osp_object.c +++ b/lustre/osp/osp_object.c @@ -85,6 +85,39 @@ * 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 * Author: Mikhail Pershin */ @@ -659,35 +692,9 @@ static int __osp_attr_set(const struct lu_env *env, struct dt_object *dt, /** * 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 @@ -702,9 +709,13 @@ static int osp_declare_attr_set(const struct lu_env *env, struct dt_object *dt, { 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; } @@ -713,11 +724,10 @@ static int osp_declare_attr_set(const struct lu_env *env, struct dt_object *dt, * * 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. @@ -741,6 +751,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); + + CDEBUG(D_INFO, "(1) set attr "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + RETURN(rc); } @@ -751,6 +765,9 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt, rc = osp_sync_add(env, o, MDS_SETATTR64_REC, th, attr); /* XXX: send new uid/gid to OST ASAP? */ + CDEBUG(D_INFO, "(2) set attr "DFID": rc = %d\n", + PFID(&dt->do_lu.lo_header->loh_fid), rc); + RETURN(rc); } @@ -1178,9 +1195,11 @@ static int __osp_xattr_set(const struct lu_env *env, struct dt_object *dt, * 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 @@ -1199,11 +1218,13 @@ int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, { 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; } @@ -1212,12 +1233,11 @@ int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, * * 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 @@ -1237,14 +1257,13 @@ int osp_xattr_set(const struct lu_env *env, struct dt_object *dt, { 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; } @@ -1283,9 +1302,10 @@ static int __osp_xattr_del(const struct lu_env *env, struct dt_object *dt, * 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 @@ -1300,11 +1320,13 @@ int osp_declare_xattr_del(const struct lu_env *env, struct dt_object *dt, { 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; } @@ -1313,11 +1335,10 @@ int osp_declare_xattr_del(const struct lu_env *env, struct dt_object *dt, * * 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 @@ -1334,14 +1355,13 @@ int osp_xattr_del(const struct lu_env *env, struct dt_object *dt, { 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; } @@ -1350,15 +1370,13 @@ int osp_xattr_del(const struct lu_env *env, struct dt_object *dt, * * 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 @@ -1386,7 +1404,7 @@ static int osp_declare_object_create(const struct lu_env *env, 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); @@ -1455,12 +1473,9 @@ static int osp_declare_object_create(const struct lu_env *env, * * 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 @@ -1486,7 +1501,8 @@ static int osp_object_create(const struct lu_env *env, struct dt_object *dt, 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); -- 1.8.3.1