From 0dd85e9ace1e70e60c721eac94ece0cc8a1fccc2 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 27 Sep 2013 17:04:37 -0700 Subject: [PATCH] LU-4002 hsm: avoid layout lock on unlink and rename onto In mdt_reint_unlink() and mdt_reint_rename() do not take a FULL inode lock on the file to be unlinked or the rename target. This avoids a potential deadlock when unlinking a file under HSM restore. Signed-off-by: John L. Hammond Change-Id: Id6b11b9f5c1433221670d154d65d9cec30e260af Reviewed-on: http://review.whamcloud.com/7792 Reviewed-by: Jinshan Xiong Reviewed-by: jacques-Charles Lafoucriere Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_reint.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 909091c..80a7aa7 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -828,11 +828,14 @@ static int mdt_reint_unlink(struct mdt_thread_info *info, GOTO(put_child, rc); } - rc = mdt_object_lock(info, mc, child_lh, MDS_INODELOCK_FULL, - MDT_CROSS_LOCK); - if (rc != 0) { + /* We used to acquire MDS_INODELOCK_FULL here but we can't do + * this now because a running HSM restore on the child (unlink + * victim) will hold the layout lock. See LU-4002. */ + rc = mdt_object_lock(info, mc, child_lh, + MDS_INODELOCK_LOOKUP | MDS_INODELOCK_UPDATE, + MDT_CROSS_LOCK); + if (rc != 0) GOTO(put_child, rc); - } mdt_fail_write(info->mti_env, info->mti_mdt->mdt_bottom, OBD_FAIL_MDS_REINT_UNLINK_WRITE); @@ -1290,8 +1293,14 @@ static int mdt_reint_rename(struct mdt_thread_info *info, GOTO(out_unlock_old, rc = -EXDEV); } - rc = mdt_object_lock(info, mnew, lh_newp, - MDS_INODELOCK_FULL, MDT_CROSS_LOCK); + /* We used to acquire MDS_INODELOCK_FULL here but we + * can't do this now because a running HSM restore on + * the rename onto victim will hold the layout + * lock. See LU-4002. */ + rc = mdt_object_lock(info, mnew, lh_newp, + MDS_INODELOCK_LOOKUP | + MDS_INODELOCK_UPDATE, + MDT_CROSS_LOCK); if (rc != 0) { mdt_object_put(info->mti_env, mnew); GOTO(out_unlock_old, rc); -- 1.8.3.1