Skip to content

Commit eddb2e2

Browse files
htejunJens Axboe
authored andcommitted
block: kill GENHD_FL_FAIL and use part0->make_it_fail
GENHD_FL_FAIL for disk is what make_it_fail is for parts. Kill it and use part0->make_it_fail. Sysfs node handling is unified too. Signed-off-by: Tejun Heo <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0762b8b commit eddb2e2

File tree

4 files changed

+16
-37
lines changed

4 files changed

+16
-37
lines changed

block/blk-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,8 +1273,9 @@ __setup("fail_make_request=", setup_fail_make_request);
12731273

12741274
static int should_fail_request(struct bio *bio)
12751275
{
1276-
if ((bio->bi_bdev->bd_disk->flags & GENHD_FL_FAIL) ||
1277-
bio->bi_bdev->bd_part->make_it_fail)
1276+
struct hd_struct *part = bio->bi_bdev->bd_part;
1277+
1278+
if (part_to_disk(part)->part0.make_it_fail || part->make_it_fail)
12781279
return should_fail(&fail_make_request, bio->bi_size);
12791280

12801281
return 0;

block/genhd.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -795,34 +795,6 @@ static ssize_t disk_stat_show(struct device *dev,
795795
jiffies_to_msecs(disk_stat_read(disk, time_in_queue)));
796796
}
797797

798-
#ifdef CONFIG_FAIL_MAKE_REQUEST
799-
static ssize_t disk_fail_show(struct device *dev,
800-
struct device_attribute *attr, char *buf)
801-
{
802-
struct gendisk *disk = dev_to_disk(dev);
803-
804-
return sprintf(buf, "%d\n", disk->flags & GENHD_FL_FAIL ? 1 : 0);
805-
}
806-
807-
static ssize_t disk_fail_store(struct device *dev,
808-
struct device_attribute *attr,
809-
const char *buf, size_t count)
810-
{
811-
struct gendisk *disk = dev_to_disk(dev);
812-
int i;
813-
814-
if (count > 0 && sscanf(buf, "%d", &i) > 0) {
815-
if (i == 0)
816-
disk->flags &= ~GENHD_FL_FAIL;
817-
else
818-
disk->flags |= GENHD_FL_FAIL;
819-
}
820-
821-
return count;
822-
}
823-
824-
#endif
825-
826798
static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
827799
static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
828800
static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
@@ -832,7 +804,7 @@ static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL);
832804
static DEVICE_ATTR(stat, S_IRUGO, disk_stat_show, NULL);
833805
#ifdef CONFIG_FAIL_MAKE_REQUEST
834806
static struct device_attribute dev_attr_fail =
835-
__ATTR(make-it-fail, S_IRUGO|S_IWUSR, disk_fail_show, disk_fail_store);
807+
__ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store);
836808
#endif
837809

838810
static struct attribute *disk_attrs[] = {

fs/partitions/check.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,17 @@ static ssize_t part_stat_show(struct device *dev,
238238
}
239239

240240
#ifdef CONFIG_FAIL_MAKE_REQUEST
241-
static ssize_t part_fail_show(struct device *dev,
242-
struct device_attribute *attr, char *buf)
241+
ssize_t part_fail_show(struct device *dev,
242+
struct device_attribute *attr, char *buf)
243243
{
244244
struct hd_struct *p = dev_to_part(dev);
245245

246246
return sprintf(buf, "%d\n", p->make_it_fail);
247247
}
248248

249-
static ssize_t part_fail_store(struct device *dev,
250-
struct device_attribute *attr,
251-
const char *buf, size_t count)
249+
ssize_t part_fail_store(struct device *dev,
250+
struct device_attribute *attr,
251+
const char *buf, size_t count)
252252
{
253253
struct hd_struct *p = dev_to_part(dev);
254254
int i;

include/linux/genhd.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ struct hd_struct {
112112
#define GENHD_FL_CD 8
113113
#define GENHD_FL_UP 16
114114
#define GENHD_FL_SUPPRESS_PARTITION_INFO 32
115-
#define GENHD_FL_FAIL 64
116115

117116
struct gendisk {
118117
/* major, first_minor, minors and ext_minors are input
@@ -596,6 +595,13 @@ extern void blk_unregister_region(dev_t devt, unsigned long range);
596595

597596
extern ssize_t part_size_show(struct device *dev,
598597
struct device_attribute *attr, char *buf);
598+
#ifdef CONFIG_FAIL_MAKE_REQUEST
599+
extern ssize_t part_fail_show(struct device *dev,
600+
struct device_attribute *attr, char *buf);
601+
extern ssize_t part_fail_store(struct device *dev,
602+
struct device_attribute *attr,
603+
const char *buf, size_t count);
604+
#endif /* CONFIG_FAIL_MAKE_REQUEST */
599605

600606
#else /* CONFIG_BLOCK */
601607

0 commit comments

Comments
 (0)