aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-flakey.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/md/dm-flakey.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/md/dm-flakey.c')
-rw-r--r--drivers/md/dm-flakey.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 9721f2ffb1a..f84c08029b2 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -39,10 +39,6 @@ enum feature_flag_bits {
39 DROP_WRITES 39 DROP_WRITES
40}; 40};
41 41
42struct per_bio_data {
43 bool bio_submitted;
44};
45
46static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, 42static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
47 struct dm_target *ti) 43 struct dm_target *ti)
48{ 44{
@@ -164,7 +160,6 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
164 unsigned long long tmpll; 160 unsigned long long tmpll;
165 struct dm_arg_set as; 161 struct dm_arg_set as;
166 const char *devname; 162 const char *devname;
167 char dummy;
168 163
169 as.argc = argc; 164 as.argc = argc;
170 as.argv = argv; 165 as.argv = argv;
@@ -183,7 +178,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
183 178
184 devname = dm_shift_arg(&as); 179 devname = dm_shift_arg(&as);
185 180
186 if (sscanf(dm_shift_arg(&as), "%llu%c", &tmpll, &dummy) != 1) { 181 if (sscanf(dm_shift_arg(&as), "%llu", &tmpll) != 1) {
187 ti->error = "Invalid device sector"; 182 ti->error = "Invalid device sector";
188 goto bad; 183 goto bad;
189 } 184 }
@@ -218,7 +213,6 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv)
218 213
219 ti->num_flush_requests = 1; 214 ti->num_flush_requests = 1;
220 ti->num_discard_requests = 1; 215 ti->num_discard_requests = 1;
221 ti->per_bio_data_size = sizeof(struct per_bio_data);
222 ti->private = fc; 216 ti->private = fc;
223 return 0; 217 return 0;
224 218
@@ -270,12 +264,11 @@ static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc)
270 } 264 }
271} 265}
272 266
273static int flakey_map(struct dm_target *ti, struct bio *bio) 267static int flakey_map(struct dm_target *ti, struct bio *bio,
268 union map_info *map_context)
274{ 269{
275 struct flakey_c *fc = ti->private; 270 struct flakey_c *fc = ti->private;
276 unsigned elapsed; 271 unsigned elapsed;
277 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
278 pb->bio_submitted = false;
279 272
280 /* Are we alive ? */ 273 /* Are we alive ? */
281 elapsed = (jiffies - fc->start_time) / HZ; 274 elapsed = (jiffies - fc->start_time) / HZ;
@@ -283,7 +276,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
283 /* 276 /*
284 * Flag this bio as submitted while down. 277 * Flag this bio as submitted while down.
285 */ 278 */
286 pb->bio_submitted = true; 279 map_context->ll = 1;
287 280
288 /* 281 /*
289 * Map reads as normal. 282 * Map reads as normal.
@@ -320,16 +313,17 @@ map_bio:
320 return DM_MAPIO_REMAPPED; 313 return DM_MAPIO_REMAPPED;
321} 314}
322 315
323static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error) 316static int flakey_end_io(struct dm_target *ti, struct bio *bio,
317 int error, union map_info *map_context)
324{ 318{
325 struct flakey_c *fc = ti->private; 319 struct flakey_c *fc = ti->private;
326 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 320 unsigned bio_submitted_while_down = map_context->ll;
327 321
328 /* 322 /*
329 * Corrupt successful READs while in down state. 323 * Corrupt successful READs while in down state.
330 * If flags were specified, only corrupt those that match. 324 * If flags were specified, only corrupt those that match.
331 */ 325 */
332 if (fc->corrupt_bio_byte && !error && pb->bio_submitted && 326 if (!error && bio_submitted_while_down &&
333 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && 327 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
334 all_corrupt_bio_flags_match(bio, fc)) 328 all_corrupt_bio_flags_match(bio, fc))
335 corrupt_bio_data(bio, fc); 329 corrupt_bio_data(bio, fc);
@@ -338,7 +332,7 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
338} 332}
339 333
340static int flakey_status(struct dm_target *ti, status_type_t type, 334static int flakey_status(struct dm_target *ti, status_type_t type,
341 unsigned status_flags, char *result, unsigned maxlen) 335 char *result, unsigned int maxlen)
342{ 336{
343 unsigned sz = 0; 337 unsigned sz = 0;
344 struct flakey_c *fc = ti->private; 338 struct flakey_c *fc = ti->private;
@@ -374,17 +368,8 @@ static int flakey_status(struct dm_target *ti, status_type_t type,
374static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg) 368static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg)
375{ 369{
376 struct flakey_c *fc = ti->private; 370 struct flakey_c *fc = ti->private;
377 struct dm_dev *dev = fc->dev;
378 int r = 0;
379
380 /*
381 * Only pass ioctls through if the device sizes match exactly.
382 */
383 if (fc->start ||
384 ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
385 r = scsi_verify_blk_ioctl(NULL, cmd);
386 371
387 return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg); 372 return __blkdev_driver_ioctl(fc->dev->bdev, fc->dev->mode, cmd, arg);
388} 373}
389 374
390static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm, 375static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
@@ -411,7 +396,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_
411 396
412static struct target_type flakey_target = { 397static struct target_type flakey_target = {
413 .name = "flakey", 398 .name = "flakey",
414 .version = {1, 3, 0}, 399 .version = {1, 2, 0},
415 .module = THIS_MODULE, 400 .module = THIS_MODULE,
416 .ctr = flakey_ctr, 401 .ctr = flakey_ctr,
417 .dtr = flakey_dtr, 402 .dtr = flakey_dtr,