forked from luck/tmp_suning_uos_patched
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>
This commit is contained in:
parent
89c7cd8974
commit
c7cfdf5973
|
@ -39,6 +39,10 @@ enum feature_flag_bits {
|
||||||
DROP_WRITES
|
DROP_WRITES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct per_bio_data {
|
||||||
|
bool bio_submitted;
|
||||||
|
};
|
||||||
|
|
||||||
static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
|
static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
|
||||||
struct dm_target *ti)
|
struct dm_target *ti)
|
||||||
{
|
{
|
||||||
|
@ -214,6 +218,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
|
||||||
|
|
||||||
ti->num_flush_requests = 1;
|
ti->num_flush_requests = 1;
|
||||||
ti->num_discard_requests = 1;
|
ti->num_discard_requests = 1;
|
||||||
|
ti->per_bio_data_size = sizeof(struct per_bio_data);
|
||||||
ti->private = fc;
|
ti->private = fc;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -270,6 +275,8 @@ static int flakey_map(struct dm_target *ti, struct bio *bio,
|
||||||
{
|
{
|
||||||
struct flakey_c *fc = ti->private;
|
struct flakey_c *fc = ti->private;
|
||||||
unsigned elapsed;
|
unsigned elapsed;
|
||||||
|
struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
|
||||||
|
pb->bio_submitted = false;
|
||||||
|
|
||||||
/* Are we alive ? */
|
/* Are we alive ? */
|
||||||
elapsed = (jiffies - fc->start_time) / HZ;
|
elapsed = (jiffies - fc->start_time) / HZ;
|
||||||
|
@ -277,7 +284,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio,
|
||||||
/*
|
/*
|
||||||
* Flag this bio as submitted while down.
|
* Flag this bio as submitted while down.
|
||||||
*/
|
*/
|
||||||
map_context->ll = 1;
|
pb->bio_submitted = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map reads as normal.
|
* Map reads as normal.
|
||||||
|
@ -318,13 +325,13 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio,
|
||||||
int error, union map_info *map_context)
|
int error, union map_info *map_context)
|
||||||
{
|
{
|
||||||
struct flakey_c *fc = ti->private;
|
struct flakey_c *fc = ti->private;
|
||||||
unsigned bio_submitted_while_down = map_context->ll;
|
struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Corrupt successful READs while in down state.
|
* Corrupt successful READs while in down state.
|
||||||
* If flags were specified, only corrupt those that match.
|
* If flags were specified, only corrupt those that match.
|
||||||
*/
|
*/
|
||||||
if (fc->corrupt_bio_byte && !error && bio_submitted_while_down &&
|
if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
|
||||||
(bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
|
(bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
|
||||||
all_corrupt_bio_flags_match(bio, fc))
|
all_corrupt_bio_flags_match(bio, fc))
|
||||||
corrupt_bio_data(bio, fc);
|
corrupt_bio_data(bio, fc);
|
||||||
|
@ -406,7 +413,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_
|
||||||
|
|
||||||
static struct target_type flakey_target = {
|
static struct target_type flakey_target = {
|
||||||
.name = "flakey",
|
.name = "flakey",
|
||||||
.version = {1, 2, 0},
|
.version = {1, 3, 0},
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
.ctr = flakey_ctr,
|
.ctr = flakey_ctr,
|
||||||
.dtr = flakey_dtr,
|
.dtr = flakey_dtr,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user