From c420d6ade80911013c691ac18fa666b2284ea55d Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Fri, 17 Mar 2017 14:38:17 +0300 Subject: [PATCH] rule-spec:block:request: fix error: '__GFP_WAIT' undeclared __GFP_WAIT is not available since 4.4 as a result of gfp revolution introduced by commit d0164adc8 "mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd". The patch introduces new macro ldv_blk_get_request_cannot_fail() that is defined differently depending on __GFP_WAIT availability. Signed-off-by: Alexey Khoroshilov --- .../jobs/presets/linux-3.14/linux/block/request.c | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/bridge/jobs/presets/linux-3.14/linux/block/request.c b/bridge/jobs/presets/linux-3.14/linux/block/request.c index 03b1a37..d88cae8 100644 --- a/bridge/jobs/presets/linux-3.14/linux/block/request.c +++ b/bridge/jobs/presets/linux-3.14/linux/block/request.c @@ -21,6 +21,31 @@ #include #include +/* + * If gfp_mask argument of blk_get_request() has __GFP_WAIT(linux 4.4 or below) + * or __GFP_DIRECT_RECLAIM(linux 4.4+) set, blk_get_request() cannot fail. + * Potentially it can fail if queue is dying, but we ingnore that for now. + */ +#if defined(__GFP_WAIT) +#ifdef LDV_BITWISE + #define ldv_blk_get_request_cannot_fail(gfp_mask) (gfp_mask | __GFP_WAIT) +#else + /* Let's use approximation if verifier does not support bitwise operations */ + #define ldv_blk_get_request_cannot_fail(gfp_mask) \ + (gfp_mask == __GFP_WAIT || gfp_mask == GFP_KERNEL || gfp_mask == GFP_NOIO) +#endif +#else +#ifdef LDV_BITWISE + #define ldv_blk_get_request_cannot_fail(gfp_mask) (gfp_mask | __GFP_DIRECT_RECLAIM) +#else + /* Let's use approximation if verifier does not support bitwise operations */ + /* __GFP_RECLAIM is used where __GFP_WAIT was used before at call side */ + #define ldv_blk_get_request_cannot_fail(gfp_mask) \ + (gfp_mask == __GFP_RECLAIM || gfp_mask == GFP_KERNEL || gfp_mask == GFP_NOIO) +#endif +#endif + + /* There are 2 possible states of blk request. */ enum { @@ -42,8 +67,8 @@ struct request *ldv_blk_get_request(gfp_t mask) /* NOTE Generate valid pointer or NULL. */ res = (struct request *)ldv_undef_ptr(); - /* NOTE If gfp_mask argument has __GFP_WAIT set, blk_get_request() cannot fail. */ - if (mask == __GFP_WAIT || mask == GFP_KERNEL || mask == GFP_NOIO) + /* NOTE If gfp_mask argument has __GFP_WAIT(before 4.4) or __GFP_DIRECT_RECLAIM(4.4+) set, blk_get_request() cannot fail. */ + if (ldv_blk_get_request_cannot_fail(mask)) ldv_assume(res != NULL); if (res != NULL) { -- 2.7.4