From b4a1b6f900fe0439950b3e3f797570e2a3e8ba1e Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 6 Aug 2019 09:01:08 +0200 Subject: [PATCH] bio: adapt to upstream bi_status --- kernel/compat.h | 13 +++++++++++++ kernel/mars_bio.c | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/compat.h b/kernel/compat.h index 3f94166a..012deeaf 100644 --- a/kernel/compat.h +++ b/kernel/compat.h @@ -67,6 +67,10 @@ extern int _compat_unlink( * This is a hell. */ +/* For bio block layer compatibility */ +#include +#include + #ifdef __bvec_iter_bvec #define MARS_HAS_BVEC_ITER #endif @@ -85,12 +89,21 @@ extern int _compat_unlink( #include #endif +/* Detect upstream commits + * 2a842acab109f40f0d7d10b38e9ca88390628996 + * 4e4cbee93d56137ebff722be022cae5f70ef84fb + * & neighbour commits. + */ +#ifdef BLK_STS_OK +#define MARS_HAS_BI_STATUS +#else /* adaptation to 4246a0b63bd8f56a1469b12eafeb875b1041a451 and 8ae126660fddbeebb9251a174e6fa45b6ad8f932 */ #ifndef bio_io_error #define MARS_HAS_BI_ERROR #else #define MARS_HAS_MERGE_BVEC #endif +#endif /* adapt to 4e1b2d52a80d79296a5d899d73249748dea71a53 and many others */ #ifdef bio_op diff --git a/kernel/mars_bio.c b/kernel/mars_bio.c index 1f2dc32c..d9124770 100644 --- a/kernel/mars_bio.c +++ b/kernel/mars_bio.c @@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(bio_io_threshold); /* This is called from the kernel bio layer. */ // remove_this -#ifdef MARS_HAS_BI_ERROR +#if defined(MARS_HAS_BI_STATUS) || defined(MARS_HAS_BI_ERROR) // end_remove_this static void bio_callback(struct bio *bio) @@ -102,13 +102,17 @@ void bio_callback(struct bio *bio, int code) CHECK_PTR(brick, err); // remove_this -#ifdef MARS_HAS_BI_ERROR +#ifdef MARS_HAS_BI_STATUS // end_remove_this - mref_a->status_code = bio->bi_error; + mref_a->status_code = blk_status_to_errno(bio->bi_status); // remove_this +#else +#ifdef MARS_HAS_BI_ERROR + mref_a->status_code = bio->bi_error; #else mref_a->status_code = code; #endif +#endif // end_remove_this spin_lock_irqsave(&brick->lock, flags);