bio: adapt to upstream bi_status

This commit is contained in:
Thomas Schoebel-Theuer 2019-08-06 09:01:08 +02:00 committed by Thomas Schoebel-Theuer
parent b2d3433b21
commit b4a1b6f900
2 changed files with 20 additions and 3 deletions

View File

@ -67,6 +67,10 @@ extern int _compat_unlink(
* This is a hell. * This is a hell.
*/ */
/* For bio block layer compatibility */
#include <linux/blk_types.h>
#include <linux/bio.h>
#ifdef __bvec_iter_bvec #ifdef __bvec_iter_bvec
#define MARS_HAS_BVEC_ITER #define MARS_HAS_BVEC_ITER
#endif #endif
@ -85,12 +89,21 @@ extern int _compat_unlink(
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
#endif #endif
/* Detect upstream commits
* 2a842acab109f40f0d7d10b38e9ca88390628996
* 4e4cbee93d56137ebff722be022cae5f70ef84fb
* & neighbour commits.
*/
#ifdef BLK_STS_OK
#define MARS_HAS_BI_STATUS
#else
/* adaptation to 4246a0b63bd8f56a1469b12eafeb875b1041a451 and 8ae126660fddbeebb9251a174e6fa45b6ad8f932 */ /* adaptation to 4246a0b63bd8f56a1469b12eafeb875b1041a451 and 8ae126660fddbeebb9251a174e6fa45b6ad8f932 */
#ifndef bio_io_error #ifndef bio_io_error
#define MARS_HAS_BI_ERROR #define MARS_HAS_BI_ERROR
#else #else
#define MARS_HAS_MERGE_BVEC #define MARS_HAS_MERGE_BVEC
#endif #endif
#endif
/* adapt to 4e1b2d52a80d79296a5d899d73249748dea71a53 and many others */ /* adapt to 4e1b2d52a80d79296a5d899d73249748dea71a53 and many others */
#ifdef bio_op #ifdef bio_op

View File

@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(bio_io_threshold);
/* This is called from the kernel bio layer. /* This is called from the kernel bio layer.
*/ */
// remove_this // remove_this
#ifdef MARS_HAS_BI_ERROR #if defined(MARS_HAS_BI_STATUS) || defined(MARS_HAS_BI_ERROR)
// end_remove_this // end_remove_this
static static
void bio_callback(struct bio *bio) void bio_callback(struct bio *bio)
@ -102,13 +102,17 @@ void bio_callback(struct bio *bio, int code)
CHECK_PTR(brick, err); CHECK_PTR(brick, err);
// remove_this // remove_this
#ifdef MARS_HAS_BI_ERROR #ifdef MARS_HAS_BI_STATUS
// end_remove_this // end_remove_this
mref_a->status_code = bio->bi_error; mref_a->status_code = blk_status_to_errno(bio->bi_status);
// remove_this // remove_this
#else
#ifdef MARS_HAS_BI_ERROR
mref_a->status_code = bio->bi_error;
#else #else
mref_a->status_code = code; mref_a->status_code = code;
#endif #endif
#endif
// end_remove_this // end_remove_this
spin_lock_irqsave(&brick->lock, flags); spin_lock_irqsave(&brick->lock, flags);