aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2013-03-01 17:45:49 -0500
committerAlasdair G Kergon <agk@redhat.com>2013-03-01 17:45:49 -0500
commitb0d8ed4d96a26ef3ac54a4aa8911c9413070662e (patch)
treeb43cc88d671e85840a625cdb0de75754182043ac /drivers/md
parentdf5d2e9089c7d5b8c46f767e4278610ea3e815b9 (diff)
dm: add target num_write_bios fn
Add a num_write_bios function to struct target. If an instance of a target sets this, it will be queried before the target's mapping function is called on a write bio, and the response controls the number of copies of the write bio that the target will receive. This provides a convenient way for a target to send the same data to more than one device. The new cache target uses this in writethrough mode, to send the data both to the cache and the backing device. Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index e417cf0a69ef..7e469260fe5e 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1152,15 +1152,23 @@ static void __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti
1152{ 1152{
1153 struct bio *bio = ci->bio; 1153 struct bio *bio = ci->bio;
1154 struct dm_target_io *tio; 1154 struct dm_target_io *tio;
1155 unsigned target_bio_nr;
1156 unsigned num_target_bios = 1;
1155 1157
1156 tio = alloc_tio(ci, ti, nr_iovecs, 0); 1158 /*
1157 1159 * Does the target want to receive duplicate copies of the bio?
1158 if (split_bvec) 1160 */
1159 clone_split_bio(tio, bio, sector, idx, offset, len); 1161 if (bio_data_dir(bio) == WRITE && ti->num_write_bios)
1160 else 1162 num_target_bios = ti->num_write_bios(ti, bio);
1161 clone_bio(tio, bio, sector, idx, bv_count, len);
1162 1163
1163 __map_bio(tio); 1164 for (target_bio_nr = 0; target_bio_nr < num_target_bios; target_bio_nr++) {
1165 tio = alloc_tio(ci, ti, nr_iovecs, target_bio_nr);
1166 if (split_bvec)
1167 clone_split_bio(tio, bio, sector, idx, offset, len);
1168 else
1169 clone_bio(tio, bio, sector, idx, bv_count, len);
1170 __map_bio(tio);
1171 }
1164} 1172}
1165 1173
1166typedef unsigned (*get_num_bios_fn)(struct dm_target *ti); 1174typedef unsigned (*get_num_bios_fn)(struct dm_target *ti);