aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2012-12-21 15:23:40 -0500
committerAlasdair G Kergon <agk@redhat.com>2012-12-21 15:23:40 -0500
commit0045d61b5b7470f7228b35e1ab7139119e249503 (patch)
treed4e0f926484cf243141e83aeda5fd82703fc9151
parentc7cfdf5973f644a21ef4a0a0f1aa1f081efc42c1 (diff)
dm raid1: dont use map_context
Don't use map_info any more in dm-raid1. map_info was used for writes to hold the region number. For this purpose we add a new field dm_bio_details to dm_raid1_bio_record. map_info was used for reads to hold a pointer to dm_raid1_bio_record (if the pointer was non-NULL, bio details were saved; if the pointer was NULL, bio details were not saved). We use dm_raid1_bio_record.details->bi_bdev for this purpose. If bi_bdev is NULL, details were not saved, if bi_bdev is non-NULL, details were saved. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-raid1.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index a7d0d8a4bbdf..57685cf0afa8 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -140,7 +140,9 @@ static void dispatch_bios(void *context, struct bio_list *bio_list)
140 140
141struct dm_raid1_bio_record { 141struct dm_raid1_bio_record {
142 struct mirror *m; 142 struct mirror *m;
143 /* if details->bi_bdev == NULL, details were not saved */
143 struct dm_bio_details details; 144 struct dm_bio_details details;
145 region_t write_region;
144}; 146};
145 147
146/* 148/*
@@ -1146,12 +1148,15 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
1146 int r, rw = bio_rw(bio); 1148 int r, rw = bio_rw(bio);
1147 struct mirror *m; 1149 struct mirror *m;
1148 struct mirror_set *ms = ti->private; 1150 struct mirror_set *ms = ti->private;
1149 struct dm_raid1_bio_record *bio_record;
1150 struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh); 1151 struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
1152 struct dm_raid1_bio_record *bio_record =
1153 dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
1154
1155 bio_record->details.bi_bdev = NULL;
1151 1156
1152 if (rw == WRITE) { 1157 if (rw == WRITE) {
1153 /* Save region for mirror_end_io() handler */ 1158 /* Save region for mirror_end_io() handler */
1154 map_context->ll = dm_rh_bio_to_region(ms->rh, bio); 1159 bio_record->write_region = dm_rh_bio_to_region(ms->rh, bio);
1155 queue_bio(ms, bio, rw); 1160 queue_bio(ms, bio, rw);
1156 return DM_MAPIO_SUBMITTED; 1161 return DM_MAPIO_SUBMITTED;
1157 } 1162 }
@@ -1179,9 +1184,7 @@ static int mirror_map(struct dm_target *ti, struct bio *bio,
1179 if (unlikely(!m)) 1184 if (unlikely(!m))
1180 return -EIO; 1185 return -EIO;
1181 1186
1182 bio_record = dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
1183 dm_bio_record(&bio_record->details, bio); 1187 dm_bio_record(&bio_record->details, bio);
1184 map_context->ptr = bio_record;
1185 bio_record->m = m; 1188 bio_record->m = m;
1186 1189
1187 map_bio(m, bio); 1190 map_bio(m, bio);
@@ -1196,14 +1199,15 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1196 struct mirror_set *ms = (struct mirror_set *) ti->private; 1199 struct mirror_set *ms = (struct mirror_set *) ti->private;
1197 struct mirror *m = NULL; 1200 struct mirror *m = NULL;
1198 struct dm_bio_details *bd = NULL; 1201 struct dm_bio_details *bd = NULL;
1199 struct dm_raid1_bio_record *bio_record = map_context->ptr; 1202 struct dm_raid1_bio_record *bio_record =
1203 dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
1200 1204
1201 /* 1205 /*
1202 * We need to dec pending if this was a write. 1206 * We need to dec pending if this was a write.
1203 */ 1207 */
1204 if (rw == WRITE) { 1208 if (rw == WRITE) {
1205 if (!(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD))) 1209 if (!(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD)))
1206 dm_rh_dec(ms->rh, map_context->ll); 1210 dm_rh_dec(ms->rh, bio_record->write_region);
1207 return error; 1211 return error;
1208 } 1212 }
1209 1213
@@ -1214,7 +1218,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1214 goto out; 1218 goto out;
1215 1219
1216 if (unlikely(error)) { 1220 if (unlikely(error)) {
1217 if (!bio_record) { 1221 if (!bio_record->details.bi_bdev) {
1218 /* 1222 /*
1219 * There wasn't enough memory to record necessary 1223 * There wasn't enough memory to record necessary
1220 * information for a retry or there was no other 1224 * information for a retry or there was no other
@@ -1239,7 +1243,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1239 bd = &bio_record->details; 1243 bd = &bio_record->details;
1240 1244
1241 dm_bio_restore(bd, bio); 1245 dm_bio_restore(bd, bio);
1242 map_context->ptr = NULL; 1246 bio_record->details.bi_bdev = NULL;
1243 queue_bio(ms, bio, rw); 1247 queue_bio(ms, bio, rw);
1244 return DM_ENDIO_INCOMPLETE; 1248 return DM_ENDIO_INCOMPLETE;
1245 } 1249 }
@@ -1247,7 +1251,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1247 } 1251 }
1248 1252
1249out: 1253out:
1250 map_context->ptr = NULL; 1254 bio_record->details.bi_bdev = NULL;
1251 1255
1252 return error; 1256 return error;
1253} 1257}