From b596047cae1d3381cafae9c4132e1a84e99ca9d0 Mon Sep 17 00:00:00 2001 From: Di Wang Date: Tue, 11 Oct 2016 15:30:53 -0400 Subject: [PATCH] LU-8250 mdd: move linkea prepare out of transaction. Move linkea prepare out of transaction to avoid reading linkea remotely inside the transaciton. Signed-off-by: Di Wang Change-Id: I10f0979c0c496fdcc5349f36ac5cca123d42c8a5 Reviewed-on: http://review.whamcloud.com/23096 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_dir.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 975c1cb..65fd18d 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1325,6 +1325,14 @@ static int mdd_link(const struct lu_env *env, struct md_object *tgt_obj, LASSERT(ma->ma_attr.la_valid & LA_CTIME); la->la_ctime = la->la_mtime = ma->ma_attr.la_ctime; + /* Note: even this function will change ldata, but it comes from + * thread_info, which is completely temporary and only seen in + * this function, so we do not need reset ldata once it fails.*/ + rc = mdd_linkea_prepare(env, mdd_sobj, NULL, NULL, mdo2fid(mdd_tobj), + lname, 0, 0, ldata); + if (rc != 0) + GOTO(stop, rc); + rc = mdd_declare_link(env, mdd, mdd_tobj, mdd_sobj, lname, handle, la, ldata); if (rc) @@ -1370,17 +1378,12 @@ static int mdd_link(const struct lu_env *env, struct md_object *tgt_obj, la->la_valid = LA_CTIME; rc = mdd_update_time(env, mdd_sobj, cattr, la, handle); - if (rc == 0) { - rc = mdd_linkea_prepare(env, mdd_sobj, NULL, NULL, - mdo2fid(mdd_tobj), lname, 0, 0, - ldata); - if (rc == 0) - mdd_links_add(env, mdd_sobj, mdo2fid(mdd_tobj), - lname, handle, ldata, 0); - /* The failure of links_add should not cause the link - * failure, reset rc here */ - rc = 0; - } + if (rc == 0) + /* Note: The failure of links_add should not cause the + * link failure, so do not check return value. */ + mdd_links_add(env, mdd_sobj, mdo2fid(mdd_tobj), + lname, handle, ldata, 0); + EXIT; out_unlock: mdd_write_unlock(env, mdd_sobj); -- 1.8.3.1