diff options
| -rw-r--r-- | drivers/md/dm-raid1.c | 22 |
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 | ||
| 141 | struct dm_raid1_bio_record { | 141 | struct 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 | ||
| 1249 | out: | 1253 | out: |
| 1250 | map_context->ptr = NULL; | 1254 | bio_record->details.bi_bdev = NULL; |
| 1251 | 1255 | ||
| 1252 | return error; | 1256 | return error; |
| 1253 | } | 1257 | } |
