From: alex chen <alex.chen@huawei.com>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>, Milan Broz <asi@seznam.cz>,
Mike Anderson <andmike@linux.vnet.ibm.com>,
Joseph Qi <joseph.qi@huawei.com>,
christophe varoqui <christophe.varoqui@free.fr>,
dm-devel@redhat.com, Jun'ichi Nomura <j-nomura@ce.jp.nec.com>,
Alasdair Kergon <agk@redhat.com>
Subject: [PATCH] dm linear: disable WRITE SAME if it fails
Date: Sat, 31 May 2014 16:51:30 +0800 [thread overview]
Message-ID: <53899812.50403@huawei.com> (raw)
In-Reply-To: <53042F91.4050201@huawei.com>
The original commit f84cb8a46a771f36a04a02c61ea635c968ed5f6a("dm mpath:
disable WRITE SAME if it fails") disables WRITE SAME in the DM multipath
device if it fails, but when the DM linear device stacks ontop of the
multipath device it doesn't help.
this patch adds DM linear end_io method to catch WRITE SAME errors and
disables WRITE SAME in the DM linear device's queue_limits if an
underlying device disables it.
Before this patch:
dm linear device(dm-20): ocfs2-fs;
multipath device(dm-6);
scsi device(sdt,sdu);
After a WRITE SAME bio fails, the DM linear device does not disable the
WRITE SAME, although the underlying device(DM multipath device) has
disabled WRITE SAME.
cat /sys/block/dm-20/queue/write_same_max_bytes
33553920
cat /sys/block/dm-6/queue/write_same_max_bytes
0
cat /sys/block/sdt/queue/write_same_max_bytes
0
cat /sys/block/sdu/queue/write_same_max_bytes
0
After this patch:
dm linear device(dm-20): ocfs2-fs;
multipath device(dm-6);
scsi device(sdt,sdu);
After a WRITE SAME bio fails, the underlying device(DM multipath
device) disables WRITE SAME and then the DM linear device also disables
WRITE SAME.
cat /sys/block/dm-20/queue/write_same_max_bytes
0
cat /sys/block/dm-6/queue/write_same_max_bytes
0
cat /sys/block/sdt/queue/write_same_max_bytes
0
cat /sys/block/sdu/queue/write_same_max_bytes
0
Signed-off-by: alex.chen <alex.chen@huawei.com>
---
drivers/md/dm-linear.c | 26 +++++++++++++++++++++++++-
drivers/md/dm.c | 2 +-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 53e848c..eaf86a5 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -96,6 +96,29 @@ static int linear_map(struct dm_target *ti, struct
bio *bio)
return DM_MAPIO_REMAPPED;
}
+static int linear_end_io(struct dm_target *ti, struct bio *bio, int error)
+{
+ struct linear_c *lc = ti->private;
+ struct block_device *bdev;
+ struct queue_limits *limits;
+ struct queue_limits *bdev_limits;
+
+ if (!error)
+ return error;
+
+ if (unlikely(bio->bi_rw & REQ_WRITE_SAME)) {
+ bdev = lc->dev->bdev;
+ bdev_limits = &bdev->bd_disk->queue->limits;
+
+ limits = dm_get_queue_limits(dm_table_get_md(ti->table));
+
+ if ((!bdev_limits->max_write_same_sectors) &&
+ limits->max_write_same_sectors)
+ limits->max_write_same_sectors = 0;
+ }
+
+ return error;
+}
static void linear_status(struct dm_target *ti, status_type_t type,
unsigned status_flags, char *result, unsigned maxlen)
{
@@ -155,11 +178,12 @@ static int linear_iterate_devices(struct dm_target
*ti,
static struct target_type linear_target = {
.name = "linear",
- .version = {1, 2, 1},
+ .version = {1, 2, 2},
.module = THIS_MODULE,
.ctr = linear_ctr,
.dtr = linear_dtr,
.map = linear_map,
+ .end_io = linear_end_io,
.status = linear_status,
.ioctl = linear_ioctl,
.merge = linear_merge,
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8c53b09..4337025 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -770,7 +770,7 @@ static void clone_endio(struct bio *bio, int error)
if (endio) {
r = endio(tio->ti, bio, error);
- if (r < 0 || r == DM_ENDIO_REQUEUE)
+ if (r <= 0 || r == DM_ENDIO_REQUEUE)
/*
* error and requeue request are handled
* in dec_pending().
--
1.8.4.3
next prev parent reply other threads:[~2014-05-31 8:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-19 4:14 [PATCH] dm linear: disable WRITE SAME if it fails alex chen
2014-03-05 7:30 ` alex chen
2014-03-05 14:23 ` Mike Snitzer
2014-05-31 8:51 ` alex chen [this message]
2014-05-31 14:43 ` [PATCH] " Alasdair G Kergon
2014-05-31 15:05 ` Alasdair G Kergon
2014-06-02 18:36 ` dm: " Mike Snitzer
2014-06-03 16:58 ` Mike Snitzer
2014-06-03 22:59 ` Martin K. Petersen
2014-06-04 0:06 ` Mike Snitzer
2014-06-04 4:03 ` alex chen
2014-06-04 13:52 ` Mike Snitzer
2014-06-05 1:52 ` alex chen
2014-06-05 13:07 ` Mike Snitzer
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=53899812.50403@huawei.com \
--to=alex.chen@huawei.com \
--cc=agk@redhat.com \
--cc=andmike@linux.vnet.ibm.com \
--cc=asi@seznam.cz \
--cc=christophe.varoqui@free.fr \
--cc=dm-devel@redhat.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=joseph.qi@huawei.com \
--cc=k-ueda@ct.jp.nec.com \
--cc=snitzer@redhat.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.