Skip to content

Commit c7cfdf5

Browse files
Mikulas Patockakergon
authored andcommitted
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>
1 parent 89c7cd8 commit c7cfdf5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/md/dm-flakey.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ enum feature_flag_bits {
3939
DROP_WRITES
4040
};
4141

42+
struct per_bio_data {
43+
bool bio_submitted;
44+
};
45+
4246
static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
4347
struct dm_target *ti)
4448
{
@@ -214,6 +218,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
214218

215219
ti->num_flush_requests = 1;
216220
ti->num_discard_requests = 1;
221+
ti->per_bio_data_size = sizeof(struct per_bio_data);
217222
ti->private = fc;
218223
return 0;
219224

@@ -270,14 +275,16 @@ static int flakey_map(struct dm_target *ti, struct bio *bio,
270275
{
271276
struct flakey_c *fc = ti->private;
272277
unsigned elapsed;
278+
struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
279+
pb->bio_submitted = false;
273280

274281
/* Are we alive ? */
275282
elapsed = (jiffies - fc->start_time) / HZ;
276283
if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) {
277284
/*
278285
* Flag this bio as submitted while down.
279286
*/
280-
map_context->ll = 1;
287+
pb->bio_submitted = true;
281288

282289
/*
283290
* Map reads as normal.
@@ -318,13 +325,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio,
318325
int error, union map_info *map_context)
319326
{
320327
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));
322329

323330
/*
324331
* Corrupt successful READs while in down state.
325332
* If flags were specified, only corrupt those that match.
326333
*/
327-
if (fc->corrupt_bio_byte && !error && bio_submitted_while_down &&
334+
if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
328335
(bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
329336
all_corrupt_bio_flags_match(bio, fc))
330337
corrupt_bio_data(bio, fc);
@@ -406,7 +413,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_
406413

407414
static struct target_type flakey_target = {
408415
.name = "flakey",
409-
.version = {1, 2, 0},
416+
.version = {1, 3, 0},
410417
.module = THIS_MODULE,
411418
.ctr = flakey_ctr,
412419
.dtr = flakey_dtr,

0 commit comments

Comments
 (0)