@@ -668,7 +668,8 @@ __setup("fail_make_request=", setup_fail_make_request);
static bool should_fail_request(struct hd_struct *part, unsigned int bytes)
{
- return part->make_it_fail && should_fail(&fail_make_request, bytes);
+ return test_bit(HD_FAIL_REQUEST, &part->state) &&
+ should_fail(&fail_make_request, bytes);
}
static int __init fail_make_request_debugfs(void)
@@ -1407,7 +1407,7 @@ ssize_t part_fail_show(struct device *dev,
{
struct hd_struct *p = dev_to_part(dev);
- return sprintf(buf, "%d\n", p->make_it_fail);
+ return sprintf(buf, "%d\n", test_bit(HD_FAIL_REQUEST, &p->state));
}
ssize_t part_fail_store(struct device *dev,
@@ -1417,9 +1417,12 @@ ssize_t part_fail_store(struct device *dev,
struct hd_struct *p = dev_to_part(dev);
int i;
- if (count > 0 && sscanf(buf, "%d", &i) > 0)
- p->make_it_fail = (i == 0) ? 0 : 1;
-
+ if (count > 0 && sscanf(buf, "%d", &i) > 0) {
+ if (i)
+ clear_bit(HD_FAIL_REQUEST, &p->state);
+ else
+ set_bit(HD_FAIL_REQUEST, &p->state);
+ }
return count;
}
@@ -70,10 +70,8 @@ struct hd_struct {
int partno;
unsigned long state;
#define HD_RO_POLICY 0
+#define HD_FAIL_REQUEST 1
struct partition_meta_info *info;
-#ifdef CONFIG_FAIL_MAKE_REQUEST
- int make_it_fail;
-#endif
struct rcu_work rcu_work;
};
Use a single bit in ->state instead of a whole int. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-core.c | 3 ++- block/genhd.c | 11 +++++++---- include/linux/genhd.h | 4 +--- 3 files changed, 10 insertions(+), 8 deletions(-)