Skip to content

Commit 811ba89

Browse files
author
Al Viro
committed
bdev: move ->bd_make_it_fail to ->__bd_flags
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 49a43da commit 811ba89

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

block/blk-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ __setup("fail_make_request=", setup_fail_make_request);
494494

495495
bool should_fail_request(struct block_device *part, unsigned int bytes)
496496
{
497-
return part->bd_make_it_fail && should_fail(&fail_make_request, bytes);
497+
return bdev_test_flag(part, BD_MAKE_IT_FAIL) &&
498+
should_fail(&fail_make_request, bytes);
498499
}
499500

500501
static int __init fail_make_request_debugfs(void)

block/genhd.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,8 @@ static DEVICE_ATTR(diskseq, 0444, diskseq_show, NULL);
10661066
ssize_t part_fail_show(struct device *dev,
10671067
struct device_attribute *attr, char *buf)
10681068
{
1069-
return sprintf(buf, "%d\n", dev_to_bdev(dev)->bd_make_it_fail);
1069+
return sprintf(buf, "%d\n",
1070+
bdev_test_flag(dev_to_bdev(dev), BD_MAKE_IT_FAIL));
10701071
}
10711072

10721073
ssize_t part_fail_store(struct device *dev,
@@ -1075,9 +1076,12 @@ ssize_t part_fail_store(struct device *dev,
10751076
{
10761077
int i;
10771078

1078-
if (count > 0 && sscanf(buf, "%d", &i) > 0)
1079-
dev_to_bdev(dev)->bd_make_it_fail = i;
1080-
1079+
if (count > 0 && sscanf(buf, "%d", &i) > 0) {
1080+
if (i)
1081+
bdev_set_flag(dev_to_bdev(dev), BD_MAKE_IT_FAIL);
1082+
else
1083+
bdev_clear_flag(dev_to_bdev(dev), BD_MAKE_IT_FAIL);
1084+
}
10811085
return count;
10821086
}
10831087

include/linux/blk_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ struct block_device {
5151
#define BD_WRITE_HOLDER (1u<<9)
5252
#define BD_HAS_SUBMIT_BIO (1u<<10)
5353
#define BD_RO_WARNED (1u<<11)
54+
#ifdef CONFIG_FAIL_MAKE_REQUEST
55+
#define BD_MAKE_IT_FAIL (1u<<12)
56+
#endif
5457
dev_t bd_dev;
5558
struct inode *bd_inode; /* will die */
5659

@@ -67,9 +70,6 @@ struct block_device {
6770
struct mutex bd_fsfreeze_mutex; /* serialize freeze/thaw */
6871

6972
struct partition_meta_info *bd_meta_info;
70-
#ifdef CONFIG_FAIL_MAKE_REQUEST
71-
bool bd_make_it_fail;
72-
#endif
7373
int bd_writers;
7474
/*
7575
* keep this out-of-line as it's both big and not needed in the fast

0 commit comments

Comments
 (0)