From: Bhanu Prakash Gollapudi Date: Fri, 8 Mar 2013 21:28:52 +0000 (-0800) Subject: [SCSI] bnx2fc: Fix race condition between IO completion and abort X-Git-Tag: firefly_0821_release~3680^2~485^2~1^2~84 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5d78f175d0983de8dc0010fcc7c8afc777d4b8ee;p=firefly-linux-kernel-4.4.55.git [SCSI] bnx2fc: Fix race condition between IO completion and abort When IO is successfully completed while an abort is pending, eh_abort incorrectly assumes that abort failed and performes recovery by issuing cleanup. Howerver, cleanup timesout as the firmware has no clue about this IO. Fix this by checking if the IO has already completed. Signed-off-by: Bhanu Prakash Gollapudi Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 723a9a8ba5ee..e80ca01af8b4 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c @@ -1270,8 +1270,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd) spin_lock_bh(&tgt->tgt_lock); io_req->wait_for_comp = 0; - if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE, - &io_req->req_flags))) { + if (test_bit(BNX2FC_FLAG_IO_COMPL, &io_req->req_flags)) { + BNX2FC_IO_DBG(io_req, "IO completed in a different context\n"); + rc = SUCCESS; + } else if (!(test_and_set_bit(BNX2FC_FLAG_ABTS_DONE, + &io_req->req_flags))) { /* Let the scsi-ml try to recover this command */ printk(KERN_ERR PFX "abort failed, xid = 0x%x\n", io_req->xid);