* [PATCH 1/2] dm-raid: add RAID discard support
@ 2014-09-24 14:12 heinzm
0 siblings, 0 replies; 3+ messages in thread
From: heinzm @ 2014-09-24 14:12 UTC (permalink / raw)
To: dm-devel; +Cc: Heinz Mauelshagen
From: Heinz Mauelshagen <heinzm@redhat.com>
Support discard in all RAID levels 1,10,4,5 and 6.
In case of RAID levels 4,5 and 6 we have to check for the capability
to zero data on discards to avoid stripe data corruption.
If that capabilizy is missing on any disk in a RAID set,
we have to disable discards.
Signed-off-by: Heinz Mauelshagen <heinzm|redhat.com>
---
drivers/md/dm-raid.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4880b69..4edb2c7 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010-2011 Neil Brown
- * Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2014 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
*/
@@ -1150,6 +1150,43 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
}
/*
+ * Enable/disable discard support on RAID set depending
+ * on RAID level and discard properties of underlying devices
+ * (i.e. the legs of the set).
+ */
+static void raid_check_discard(struct dm_target *ti, struct raid_set *rs)
+{
+ int i;
+ bool discard_supported = true;
+ /* RAID level 4,5,6 request discard_zeroes_data for data integrity! */
+ bool raid1_or_10 = rs->md.level == 1 || rs->md.level == 10;
+ bool zeroes_data_mandatory = !raid1_or_10;
+
+ for (i = 0; i < rs->md.raid_disks; i++) {
+ struct request_queue *q = bdev_get_queue(rs->dev[i].rdev.bdev);
+
+ if (!q ||
+ !blk_queue_discard(q) ||
+ (zeroes_data_mandatory && !q->limits.discard_zeroes_data)) {
+ discard_supported = false;
+ break;
+ }
+ }
+
+ if (discard_supported) {
+ ti->discards_supported = true;
+ /*
+ * raid1 and raid10 personalities require bio splitting,
+ * raid4/5/6 don't and process large discard bios properly.
+ */
+ ti->split_discard_bios = raid1_or_10;
+ ti->num_discard_bios = 1;
+
+ } else
+ ti->discards_supported = false;
+}
+
+/*
* Construct a RAID4/5/6 mapping:
* Args:
* <raid_type> <#raid_params> <raid_params> \
@@ -1231,6 +1268,11 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
ti->private = rs;
ti->num_flush_bios = 1;
+ /*
+ * Disable/enable discard support on RAID set.
+ */
+ raid_check_discard(ti, rs);
+
mutex_lock(&rs->md.reconfig_mutex);
ret = md_run(&rs->md);
rs->md.in_sync = 0; /* Assume already marked dirty */
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] dm-raid: add RAID discard support
2014-09-24 15:47 heinzm
@ 2014-09-25 18:02 ` Mike Snitzer
0 siblings, 0 replies; 3+ messages in thread
From: Mike Snitzer @ 2014-09-25 18:02 UTC (permalink / raw)
To: heinzm; +Cc: dm-devel
On Wed, Sep 24 2014 at 11:47am -0400,
heinzm@redhat.com <heinzm@redhat.com> wrote:
> From: Heinz Mauelshagen <heinzm@redhat.com>
>
> (Folding patches 2+3 of my previous series into one on Mike Snitzers request)
I've tweaked and then folded these 2 new patches too. I see no need to
"show your work" for such a simple change; especially given the rather
fundamental raid_check_discard() implementation differences that patch 2
introduced.
Anyway, end result is staged in linux-next for v3.18 inclusion, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=for-next&id=d679f9a5582b21eff85f759f5e6a9e2ffb4793e5
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] dm-raid: add RAID discard support
@ 2014-09-24 15:47 heinzm
2014-09-25 18:02 ` Mike Snitzer
0 siblings, 1 reply; 3+ messages in thread
From: heinzm @ 2014-09-24 15:47 UTC (permalink / raw)
To: dm-devel; +Cc: Heinz Mauelshagen
From: Heinz Mauelshagen <heinzm@redhat.com>
(Folding patches 2+3 of my previous series into one on Mike Snitzers request)
Support discard in all RAID levels 1,10,4,5 and 6.
In case of RAID levels 4,5 and 6 we have to check for the capability
to zero data on discards to avoid stripe data corruption.
If that capabilizy is missing on any disk in a RAID set,
we have to disable discards.
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
---
drivers/md/dm-raid.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4880b69..4edb2c7 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010-2011 Neil Brown
- * Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2014 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
*/
@@ -1150,6 +1150,43 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
}
/*
+ * Enable/disable discard support on RAID set depending
+ * on RAID level and discard properties of underlying devices
+ * (i.e. the legs of the set).
+ */
+static void raid_check_discard(struct dm_target *ti, struct raid_set *rs)
+{
+ int i;
+ bool discard_supported = true;
+ /* RAID level 4,5,6 request discard_zeroes_data for data integrity! */
+ bool raid1_or_10 = rs->md.level == 1 || rs->md.level == 10;
+ bool zeroes_data_mandatory = !raid1_or_10;
+
+ for (i = 0; i < rs->md.raid_disks; i++) {
+ struct request_queue *q = bdev_get_queue(rs->dev[i].rdev.bdev);
+
+ if (!q ||
+ !blk_queue_discard(q) ||
+ (zeroes_data_mandatory && !q->limits.discard_zeroes_data)) {
+ discard_supported = false;
+ break;
+ }
+ }
+
+ if (discard_supported) {
+ ti->discards_supported = true;
+ /*
+ * raid1 and raid10 personalities require bio splitting,
+ * raid4/5/6 don't and process large discard bios properly.
+ */
+ ti->split_discard_bios = raid1_or_10;
+ ti->num_discard_bios = 1;
+
+ } else
+ ti->discards_supported = false;
+}
+
+/*
* Construct a RAID4/5/6 mapping:
* Args:
* <raid_type> <#raid_params> <raid_params> \
@@ -1231,6 +1268,11 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
ti->private = rs;
ti->num_flush_bios = 1;
+ /*
+ * Disable/enable discard support on RAID set.
+ */
+ raid_check_discard(ti, rs);
+
mutex_lock(&rs->md.reconfig_mutex);
ret = md_run(&rs->md);
rs->md.in_sync = 0; /* Assume already marked dirty */
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-25 18:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 14:12 [PATCH 1/2] dm-raid: add RAID discard support heinzm
2014-09-24 15:47 heinzm
2014-09-25 18:02 ` Mike Snitzer
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.