dm-flakey.c (5e3cdecf7834a764b9d24f6e696adf3e03813fab) | dm-flakey.c (e76239a3748c90a8b0e197f8f4544a8ce52f126e) |
---|---|
1/* 2 * Copyright (C) 2003 Sistina Software (UK) Limited. 3 * Copyright (C) 2004, 2010-2011 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 301 unchanged lines hidden (view full) --- 310 unsigned elapsed; 311 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 312 pb->bio_submitted = false; 313 314 /* Do not fail reset zone */ 315 if (bio_op(bio) == REQ_OP_ZONE_RESET) 316 goto map_bio; 317 | 1/* 2 * Copyright (C) 2003 Sistina Software (UK) Limited. 3 * Copyright (C) 2004, 2010-2011 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 301 unchanged lines hidden (view full) --- 310 unsigned elapsed; 311 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 312 pb->bio_submitted = false; 313 314 /* Do not fail reset zone */ 315 if (bio_op(bio) == REQ_OP_ZONE_RESET) 316 goto map_bio; 317 |
318 /* We need to remap reported zones, so remember the BIO iter */ 319 if (bio_op(bio) == REQ_OP_ZONE_REPORT) 320 goto map_bio; 321 | |
322 /* Are we alive ? */ 323 elapsed = (jiffies - fc->start_time) / HZ; 324 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { 325 /* 326 * Flag this bio as submitted while down. 327 */ 328 pb->bio_submitted = true; 329 --- 45 unchanged lines hidden (view full) --- 375 blk_status_t *error) 376{ 377 struct flakey_c *fc = ti->private; 378 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 379 380 if (bio_op(bio) == REQ_OP_ZONE_RESET) 381 return DM_ENDIO_DONE; 382 | 318 /* Are we alive ? */ 319 elapsed = (jiffies - fc->start_time) / HZ; 320 if (elapsed % (fc->up_interval + fc->down_interval) >= fc->up_interval) { 321 /* 322 * Flag this bio as submitted while down. 323 */ 324 pb->bio_submitted = true; 325 --- 45 unchanged lines hidden (view full) --- 371 blk_status_t *error) 372{ 373 struct flakey_c *fc = ti->private; 374 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data)); 375 376 if (bio_op(bio) == REQ_OP_ZONE_RESET) 377 return DM_ENDIO_DONE; 378 |
383 if (bio_op(bio) == REQ_OP_ZONE_REPORT) { 384 dm_remap_zone_report(ti, bio, fc->start); 385 return DM_ENDIO_DONE; 386 } 387 | |
388 if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { 389 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && 390 all_corrupt_bio_flags_match(bio, fc)) { 391 /* 392 * Corrupt successful matching READs while in down state. 393 */ 394 corrupt_bio_data(bio, fc); 395 --- 56 unchanged lines hidden (view full) --- 452 * Only pass ioctls through if the device sizes match exactly. 453 */ 454 if (fc->start || 455 ti->len != i_size_read((*bdev)->bd_inode) >> SECTOR_SHIFT) 456 return 1; 457 return 0; 458} 459 | 379 if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) { 380 if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) && 381 all_corrupt_bio_flags_match(bio, fc)) { 382 /* 383 * Corrupt successful matching READs while in down state. 384 */ 385 corrupt_bio_data(bio, fc); 386 --- 56 unchanged lines hidden (view full) --- 443 * Only pass ioctls through if the device sizes match exactly. 444 */ 445 if (fc->start || 446 ti->len != i_size_read((*bdev)->bd_inode) >> SECTOR_SHIFT) 447 return 1; 448 return 0; 449} 450 |
451#ifdef CONFIG_BLK_DEV_ZONED 452static int flakey_report_zones(struct dm_target *ti, sector_t sector, 453 struct blk_zone *zones, unsigned int *nr_zones, 454 gfp_t gfp_mask) 455{ 456 struct flakey_c *fc = ti->private; 457 int ret; 458 459 /* Do report and remap it */ 460 ret = blkdev_report_zones(fc->dev->bdev, flakey_map_sector(ti, sector), 461 zones, nr_zones, gfp_mask); 462 if (ret != 0) 463 return ret; 464 465 if (*nr_zones) 466 dm_remap_zone_report(ti, fc->start, zones, nr_zones); 467 return 0; 468} 469#endif 470 |
|
460static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) 461{ 462 struct flakey_c *fc = ti->private; 463 464 return fn(ti, fc->dev, fc->start, ti->len, data); 465} 466 467static struct target_type flakey_target = { 468 .name = "flakey", 469 .version = {1, 5, 0}, 470#ifdef CONFIG_BLK_DEV_ZONED 471 .features = DM_TARGET_ZONED_HM, | 471static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data) 472{ 473 struct flakey_c *fc = ti->private; 474 475 return fn(ti, fc->dev, fc->start, ti->len, data); 476} 477 478static struct target_type flakey_target = { 479 .name = "flakey", 480 .version = {1, 5, 0}, 481#ifdef CONFIG_BLK_DEV_ZONED 482 .features = DM_TARGET_ZONED_HM, |
483 .report_zones = flakey_report_zones, |
|
472#endif 473 .module = THIS_MODULE, 474 .ctr = flakey_ctr, 475 .dtr = flakey_dtr, 476 .map = flakey_map, 477 .end_io = flakey_end_io, 478 .status = flakey_status, 479 .prepare_ioctl = flakey_prepare_ioctl, --- 25 unchanged lines hidden --- | 484#endif 485 .module = THIS_MODULE, 486 .ctr = flakey_ctr, 487 .dtr = flakey_dtr, 488 .map = flakey_map, 489 .end_io = flakey_end_io, 490 .status = flakey_status, 491 .prepare_ioctl = flakey_prepare_ioctl, --- 25 unchanged lines hidden --- |