From: Fan Yong Date: Wed, 27 Jul 2016 14:55:00 +0000 (+0800) Subject: LU-7593 target: take ted_lcd_lock after transaction started X-Git-Tag: 2.8.60~27 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=cbca8055b75d084bc6554d1a06f3cd8ccf2f8c09 LU-7593 target: take ted_lcd_lock after transaction started Otherwise the thread1 may be blocked during the transaction start in tgt_client_data_update() with 'ted_lcd_lock' held because another thread2 may be blocked by such lock in tgt_txn_stop_cb() but with transaction handle started. That is deadlock. Signed-off-by: Fan Yong Change-Id: Id623d171e43beaa54ae4a9718fb4dc52c474df01 Reviewed-on: http://review.whamcloud.com/23129 Reviewed-by: Alex Zhuravlev Tested-by: Jenkins Reviewed-by: Mike Pershin Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index ac6841a..c3811cd 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -513,7 +513,6 @@ static int tgt_client_data_update(const struct lu_env *env, RETURN(PTR_ERR(th)); tti_buf_lcd(tti); - mutex_lock(&ted->ted_lcd_lock); rc = dt_declare_record_write(env, tgt->lut_last_rcvd, &tti->tti_buf, ted->ted_lr_off, th); @@ -523,6 +522,9 @@ static int tgt_client_data_update(const struct lu_env *env, rc = dt_trans_start_local(env, tgt->lut_bottom, th); if (rc) GOTO(out, rc); + + mutex_lock(&ted->ted_lcd_lock); + /* * Until this operations will be committed the sync is needed * for this export. This should be done _after_ starting the @@ -541,9 +543,11 @@ static int tgt_client_data_update(const struct lu_env *env, tti->tti_off = ted->ted_lr_off; rc = tgt_client_data_write(env, tgt, ted->ted_lcd, &tti->tti_off, th); + + mutex_unlock(&ted->ted_lcd_lock); + EXIT; out: - mutex_unlock(&ted->ted_lcd_lock); dt_trans_stop(env, tgt->lut_bottom, th); CDEBUG(D_INFO, "%s: update last_rcvd client data for UUID = %s, " "last_transno = %llu: rc = %d\n", tgt->lut_obd->obd_name,