aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-raid.c
diff options
context:
space:
mode:
authorHeinz Mauelshagen <heinzm@redhat.com>2014-09-24 11:47:18 -0400
committerMike Snitzer <snitzer@redhat.com>2014-10-05 20:03:36 -0400
commit75b8e04bbf01bdd5c42a1d8ac54abf757196ce49 (patch)
treeaa19a10d7e0bbea56455a81fc5e47bbe60f9b05d /drivers/md/dm-raid.c
parent86f1152b117a404229fd6f08ec3faca779f37b92 (diff)
dm raid: add discard support for RAID levels 1 and 10
Discard support is not enabled for RAID levels 4, 5, and 6 at this time due to concerns about unreliable discard_zeroes_data support on some hardware. Otherwise, discards could cause stripe data corruption (classic example of bad apples spoiling the bunch). Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r--drivers/md/dm-raid.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 4880b69e2e9e..030e2d6bc261 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2010-2011 Neil Brown 2 * Copyright (C) 2010-2011 Neil Brown
3 * Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved. 3 * Copyright (C) 2010-2014 Red Hat, Inc. All rights reserved.
4 * 4 *
5 * This file is released under the GPL. 5 * This file is released under the GPL.
6 */ 6 */
@@ -1150,6 +1150,27 @@ static int analyse_superblocks(struct dm_target *ti, struct raid_set *rs)
1150} 1150}
1151 1151
1152/* 1152/*
1153 * Enable/disable discard support on RAID set depending on RAID level.
1154 */
1155static void configure_discard_support(struct dm_target *ti, struct raid_set *rs)
1156{
1157 /* Assume discards not supported until after checks below. */
1158 ti->discards_supported = false;
1159
1160 /* RAID level 4,5,6 require discard_zeroes_data for data integrity! */
1161 if (rs->md.level == 4 || rs->md.level == 5 || rs->md.level == 6)
1162 return; /* discard_zeroes_data cannot be trusted as reliable */
1163
1164 ti->discards_supported = true;
1165
1166 /*
1167 * RAID1 and RAID10 personalities require bio splitting,
1168 */
1169 ti->split_discard_bios = true;
1170 ti->num_discard_bios = 1;
1171}
1172
1173/*
1153 * Construct a RAID4/5/6 mapping: 1174 * Construct a RAID4/5/6 mapping:
1154 * Args: 1175 * Args:
1155 * <raid_type> <#raid_params> <raid_params> \ 1176 * <raid_type> <#raid_params> <raid_params> \
@@ -1231,6 +1252,11 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
1231 ti->private = rs; 1252 ti->private = rs;
1232 ti->num_flush_bios = 1; 1253 ti->num_flush_bios = 1;
1233 1254
1255 /*
1256 * Disable/enable discard support on RAID set.
1257 */
1258 configure_discard_support(ti, rs);
1259
1234 mutex_lock(&rs->md.reconfig_mutex); 1260 mutex_lock(&rs->md.reconfig_mutex);
1235 ret = md_run(&rs->md); 1261 ret = md_run(&rs->md);
1236 rs->md.in_sync = 0; /* Assume already marked dirty */ 1262 rs->md.in_sync = 0; /* Assume already marked dirty */
@@ -1652,7 +1678,7 @@ static void raid_resume(struct dm_target *ti)
1652 1678
1653static struct target_type raid_target = { 1679static struct target_type raid_target = {
1654 .name = "raid", 1680 .name = "raid",
1655 .version = {1, 5, 2}, 1681 .version = {1, 6, 0},
1656 .module = THIS_MODULE, 1682 .module = THIS_MODULE,
1657 .ctr = raid_ctr, 1683 .ctr = raid_ctr,
1658 .dtr = raid_dtr, 1684 .dtr = raid_dtr,