aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,