From: jiangyiwen <jiangyiwen@huawei.com>
To: snitzer@redhat.com
Cc: dm-devel@redhat.com, linux-scsi@vger.kernel.org,
Christoph Hellwig <hch@lst.de>,
James Bottomley <james.bottomley@hansenpartnership.com>,
xuejiufei@huawei.com, "Qijiang (Joseph,
Euler)" <joseph.qi@huawei.com>,
martin.petersen@oracle.com
Subject: [dm-devel] [PATCH] dm-mpath: fix a tiny case which can cause an infinite loop
Date: Thu, 4 Feb 2016 10:08:02 +0800 [thread overview]
Message-ID: <56B2B282.60400@huawei.com> (raw)
When two processes submit WRTIE SAME bio simultaneously and
first IO return failed because of INVALID FIELD IN CDB, and
then second IO can enter into an infinite loop.
The problem can be described as follows:
process 1 process 2
submit_bio(REQ_WRITE_SAME) and
wait io completion
begin submit_bio(REQ_WRITE_SAME)
-> blk_queue_bio()
-> dm_request_fn()
-> map_request()
-> scsi_request_fn()
-> blk_peek_request()
-> scsi_prep_fn()
In the moment, IO return and
sense_key with illegal_request,
sense_code with 0x24(INVALID FIELD IN CDB).
In this way it will set no_write_same = 1
in sd_done() and disable write same
In sd_setup_write_same_cmnd()
when find (no_write_same == 1)
will return BLKPREP_KILL,
and then in blk_peek_request()
set error to EIO.
However, in multipath_end_io()
when find error is EIO it will
fail path and retry even if
device doesn't support WRITE SAME.
In this situation, when process of multipathd reinstate
path by using test_unit_ready periodically, it will cause
second WRITE SAME IO enters into an infinite loop and
loop never terminates.
In do_end_io(), when finding device doesn't support WRITE SAME and
request is WRITE SAME, return EOPNOTSUPP to applications.
Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: xuejiufei <xuejiufei@huawei.com>
---
drivers/md/dm-mpath.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index cfa29f5..ad1602a 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1269,6 +1269,11 @@ static int do_end_io(struct multipath *m, struct request *clone,
if (noretry_error(error))
return error;
+ /* do not retry in case of WRITE SAME not supporting */
+ if ((clone->cmd_flags & REQ_WRITE_SAME) &&
+ !clone->q->limits.max_write_same_sectors)
+ return -EOPNOTSUPP;
+
if (mpio->pgpath)
fail_path(mpio->pgpath);
--
1.8.4.3
next reply other threads:[~2016-02-04 2:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 2:08 jiangyiwen [this message]
2016-02-04 3:24 ` dm-mpath: fix a tiny case which can cause an infinite loop Mike Snitzer
2016-02-04 3:49 ` jiangyiwen
2016-02-04 4:25 ` Mike Snitzer
2016-02-04 5:03 ` Martin K. Petersen
2016-02-04 6:48 ` [PATCH] block/sd: Return -EREMOTEIO when WRITE SAME and DISCARD are disabled Martin K. Petersen
2016-02-04 9:16 ` jiangyiwen
2016-02-05 3:13 ` Martin K. Petersen
2016-02-05 3:39 ` jiangyiwen
2016-02-16 12:14 ` jiangyiwen
2016-02-18 0:22 ` Martin K. Petersen
2016-02-04 14:14 ` Hannes Reinecke
2016-02-04 16:36 ` Ewan Milne
2016-02-05 3:16 ` Martin K. Petersen
2016-02-04 8:25 ` dm-mpath: fix a tiny case which can cause an infinite loop jiangyiwen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B2B282.60400@huawei.com \
--to=jiangyiwen@huawei.com \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=joseph.qi@huawei.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=snitzer@redhat.com \
--cc=xuejiufei@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.