* [PATCH v2 5/4] dm-raid: add merge method to target
@ 2015-05-15 14:04 heinzm
0 siblings, 0 replies; only message in thread
From: heinzm @ 2015-05-15 14:04 UTC (permalink / raw)
To: linux-raid; +Cc: Heinz Mauelshagen
From: Heinz Mauelshagen <heinzm@redhat.com>
Patch series
"[PATCH v2 0/4] dm-raid: Add support for the MD RAID0 personality"
is missing a merge function which can lead to data corruption
on read ahead.
This patch introduces it
It inquires the MD raid0 personalities mergeable_bvec
to make sure, that read ahead payload gets limited properly.
The problem did not occur with the other raid levels,
because it either did not apply without striping or got
avoided via stripe caching.
Signed-of-by: Heinz Mauelshagen <heinzm@redhat.com>
Tested-by: Heinz Mauelshagen <heinzm@redhat.com>
---
drivers/md/dm-raid.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 97e1651..06f9d63 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -1717,6 +1717,24 @@ static void raid_resume(struct dm_target *ti)
mddev_resume(&rs->md);
}
+static int raid_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
+ struct bio_vec *biovec, int max_size)
+{
+ struct raid_set *rs = ti->private;
+ struct md_personality *pers = rs->md.pers;
+
+ if (pers && pers->mergeable_bvec)
+ return min(max_size, pers->mergeable_bvec(&rs->md, bvm, biovec));
+
+ /*
+ * In case we can't request the personality because
+ * the raid set is not running yet
+ *
+ * -> return safe minimum
+ */
+ return rs->md.chunk_sectors;
+}
+
static struct target_type raid_target = {
.name = "raid",
.version = {1, 7, 0},
@@ -1731,6 +1749,7 @@ static struct target_type raid_target = {
.presuspend = raid_presuspend,
.postsuspend = raid_postsuspend,
.resume = raid_resume,
+ .merge = raid_merge
};
static int __init dm_raid_init(void)
--
2.1.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-15 14:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-15 14:04 [PATCH v2 5/4] dm-raid: add merge method to target heinzm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).