* [PATCH] block: Add should_fail_bio() for bpf error injection
@ 2018-01-24 23:22 Howard McLauchlan
2018-02-06 19:27 ` Omar Sandoval
0 siblings, 1 reply; 3+ messages in thread
From: Howard McLauchlan @ 2018-01-24 23:22 UTC (permalink / raw)
To: linux-block; +Cc: Jens Axboe, Josef Bacik, Omar Sandoval, Howard McLauchlan
The classic error injection mechanism, should_fail_request() does not
support use cases where more information is required (from the entire
struct bio, for example).
To that end, this patch introduces should_fail_bio(), which calls
should_fail_request() under the hood but provides a convenient
place for kprobes to hook into if they require the entire struct bio.
This patch also replaces some existing calls to should_fail_request()
with should_fail_bio() with no degradation in performance.
Signed-off-by: Howard McLauchlan <hmclauchlan@fb.com>
---
block/blk-core.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index b8881750a3ac..5e73c996d338 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -34,6 +34,7 @@
#include <linux/pm_runtime.h>
#include <linux/blk-cgroup.h>
#include <linux/debugfs.h>
+#include <linux/bpf.h>
#define CREATE_TRACE_POINTS
#include <trace/events/block.h>
@@ -2050,6 +2051,12 @@ static inline bool should_fail_request(struct hd_struct *part,
#endif /* CONFIG_FAIL_MAKE_REQUEST */
+static noinline bool should_fail_bio(struct bio *bio)
+{
+ return should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size);
+}
+BPF_ALLOW_ERROR_INJECTION(should_fail_bio);
+
/*
* Remap block n of partition p to block n+start(p) of the disk.
*/
@@ -2141,7 +2148,7 @@ generic_make_request_checks(struct bio *bio)
if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q))
goto not_supported;
- if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
+ if (should_fail_bio(bio))
goto end_io;
if (blk_partition_remap(bio))
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] block: Add should_fail_bio() for bpf error injection
2018-01-24 23:22 [PATCH] block: Add should_fail_bio() for bpf error injection Howard McLauchlan
@ 2018-02-06 19:27 ` Omar Sandoval
2018-02-06 19:50 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Omar Sandoval @ 2018-02-06 19:27 UTC (permalink / raw)
To: Howard McLauchlan; +Cc: linux-block, Jens Axboe, Josef Bacik
On Wed, Jan 24, 2018 at 03:22:58PM -0800, Howard McLauchlan wrote:
> The classic error injection mechanism, should_fail_request() does not
> support use cases where more information is required (from the entire
> struct bio, for example).
>
> To that end, this patch introduces should_fail_bio(), which calls
> should_fail_request() under the hood but provides a convenient
> place for kprobes to hook into if they require the entire struct bio.
> This patch also replaces some existing calls to should_fail_request()
> with should_fail_bio() with no degradation in performance.
Reviewed-by: Omar Sandoval <osandov@fb.com>
Jens, can we pick this up for 4.16? The necessary BPF support has been
merged into Linus' tree.
> Signed-off-by: Howard McLauchlan <hmclauchlan@fb.com>
> ---
> block/blk-core.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index b8881750a3ac..5e73c996d338 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -34,6 +34,7 @@
> #include <linux/pm_runtime.h>
> #include <linux/blk-cgroup.h>
> #include <linux/debugfs.h>
> +#include <linux/bpf.h>
>
> #define CREATE_TRACE_POINTS
> #include <trace/events/block.h>
> @@ -2050,6 +2051,12 @@ static inline bool should_fail_request(struct hd_struct *part,
>
> #endif /* CONFIG_FAIL_MAKE_REQUEST */
>
> +static noinline bool should_fail_bio(struct bio *bio)
> +{
> + return should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size);
> +}
> +BPF_ALLOW_ERROR_INJECTION(should_fail_bio);
> +
> /*
> * Remap block n of partition p to block n+start(p) of the disk.
> */
> @@ -2141,7 +2148,7 @@ generic_make_request_checks(struct bio *bio)
> if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_rq_based(q))
> goto not_supported;
>
> - if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
> + if (should_fail_bio(bio))
> goto end_io;
>
> if (blk_partition_remap(bio))
> --
> 2.14.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] block: Add should_fail_bio() for bpf error injection
2018-02-06 19:27 ` Omar Sandoval
@ 2018-02-06 19:50 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-02-06 19:50 UTC (permalink / raw)
To: Omar Sandoval, Howard McLauchlan; +Cc: linux-block, Josef Bacik
On 2/6/18 12:27 PM, Omar Sandoval wrote:
> On Wed, Jan 24, 2018 at 03:22:58PM -0800, Howard McLauchlan wrote:
>> The classic error injection mechanism, should_fail_request() does not
>> support use cases where more information is required (from the entire
>> struct bio, for example).
>>
>> To that end, this patch introduces should_fail_bio(), which calls
>> should_fail_request() under the hood but provides a convenient
>> place for kprobes to hook into if they require the entire struct bio.
>> This patch also replaces some existing calls to should_fail_request()
>> with should_fail_bio() with no degradation in performance.
>
> Reviewed-by: Omar Sandoval <osandov@fb.com>
>
> Jens, can we pick this up for 4.16? The necessary BPF support has been
> merged into Linus' tree.
I don't see why not - but the patch no longer applies. Howard, can you
respin it?
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-06 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-24 23:22 [PATCH] block: Add should_fail_bio() for bpf error injection Howard McLauchlan
2018-02-06 19:27 ` Omar Sandoval
2018-02-06 19:50 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox