diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2012-12-21 15:23:39 -0500 |
|---|---|---|
| committer | Alasdair G Kergon <agk@redhat.com> | 2012-12-21 15:23:39 -0500 |
| commit | c7cfdf5973f644a21ef4a0a0f1aa1f081efc42c1 (patch) | |
| tree | fe9c287cca218170bd244ee688888cd775271f89 | |
| parent | 89c7cd8974035f1fbfac5c01e668b2de0733b443 (diff) | |
dm flakey: dont use map_context
Replace map_info with a per-bio structure "struct per_bio_data" in dm-flakey.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
| -rw-r--r-- | drivers/md/dm-flakey.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c index cc15543a6ad7..660f98167e7b 100644 --- a/drivers/md/dm-flakey.c +++ b/drivers/md/dm-flakey.c | |||
| @@ -39,6 +39,10 @@ enum feature_flag_bits { | |||
| 39 | DROP_WRITES | 39 | DROP_WRITES |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | struct per_bio_data { | ||
| 43 | bool bio_submitted; | ||
| 44 | }; | ||
| 45 | |||
| 42 | static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, | 46 | static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, |
| 43 | struct dm_target *ti) | 47 | struct dm_target *ti) |
| 44 | { | 48 | { |
| @@ -214,6 +218,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 214 | 218 | ||
| 215 | ti->num_flush_requests = 1; | 219 | ti->num_flush_requests = 1; |
| 216 | ti->num_discard_requests = 1; | 220 | ti->num_discard_requests = 1; |
| 221 | ti->per_bio_data_size = sizeof(struct per_bio_data); | ||
| 217 | ti->private = fc; | 222 | ti->private = fc; |
| 218 | return 0; | 223 | return 0; |
| 219 | 224 | ||
| @@ -270,6 +275,8 @@ static int flakey_map(struct dm_target *ti, struct bio *bio, | |||
| 270 | { | 275 | { |
| 271 | struct flakey_c *fc = ti->private; | 276 | struct flakey_c *fc = ti->private; |
| 272 | unsigned elapsed; | 277 | unsigned elapsed; |
| 278 | struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); | ||
| 279 | pb->bio_submitted = false; | ||
| 273 | 280 | ||
| 274 | /* Are we alive ? */ | 281 | /* Are we alive ? */ |
| 275 | elapsed = (jiffies - fc->start_time) / HZ; | 282 | elapsed = (jiffies - fc->start_time) / HZ; |
| @@ -277,7 +284,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio, | |||
| 277 | /* | 284 | /* |
| 278 | * Flag this bio as submitted while down. | 285 | * Flag this bio as submitted while down. |
| 279 | */ | 286 | */ |
| 280 | map_context->ll = 1; | 287 | pb->bio_submitted = true; |
| 281 | 288 | ||
| 282 | /* | 289 | /* |
| 283 | * Map reads as normal. | 290 | * Map reads as normal. |
| @@ -318,13 +325,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, | |||
| 318 | int error, union map_info *map_context) | 325 | int error, union map_info *map_context) |
| 319 | { | 326 | { |
| 320 | struct flakey_c *fc = ti->private; | 327 | struct flakey_c *fc = ti->private; |
| 321 | unsigned bio_submitted_while_down = map_context->ll; | 328 | struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); |
| 322 | 329 | ||
| 323 | /* | 330 | /* |
| 324 | * Corrupt successful READs while in down state. | 331 | * Corrupt successful READs while in down state. |
| 325 | * If flags were specified, only corrupt those that match. | 332 | * If flags were specified, only corrupt those that match. |
| 326 | */ | 333 | */ |
| 327 | if (fc->corrupt_bio_byte && !error && bio_submitted_while_down && | 334 | if (fc->corrupt_bio_byte && !error && pb->bio_submitted && |
| 328 | (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && | 335 | (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && |
| 329 | all_corrupt_bio_flags_match(bio, fc)) | 336 | all_corrupt_bio_flags_match(bio, fc)) |
| 330 | corrupt_bio_data(bio, fc); | 337 | corrupt_bio_data(bio, fc); |
| @@ -406,7 +413,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_ | |||
| 406 | 413 | ||
| 407 | static struct target_type flakey_target = { | 414 | static struct target_type flakey_target = { |
| 408 | .name = "flakey", | 415 | .name = "flakey", |
| 409 | .version = {1, 2, 0}, | 416 | .version = {1, 3, 0}, |
| 410 | .module = THIS_MODULE, | 417 | .module = THIS_MODULE, |
| 411 | .ctr = flakey_ctr, | 418 | .ctr = flakey_ctr, |
| 412 | .dtr = flakey_dtr, | 419 | .dtr = flakey_dtr, |
