From 0c7bb9d00f00061d7c4edde4b164256b6bb91a60 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Fri, 19 Apr 2013 09:07:32 +0200 Subject: [PATCH] if: fix bio flags for newer kernels The old code was just bullshit. --- kernel/mars_bio.c | 21 ++++++++++++++++----- kernel/mars_if.c | 18 +++++++++++------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/kernel/mars_bio.c b/kernel/mars_bio.c index 40e8de4e..9eaf34db 100644 --- a/kernel/mars_bio.c +++ b/kernel/mars_bio.c @@ -353,21 +353,32 @@ void _bio_ref_io(struct bio_output *output, struct mref_object *mref, bool cork) bio_get(bio); rw = mref->ref_rw & 1; -#ifdef BIO_RW_NOIDLE if (brick->do_noidle && !cork) { +// adapt to different kernel versions (TBD: improve) +#if defined(BIO_RW_RQ_MASK) || defined(BIO_FLUSH) rw |= (1 << BIO_RW_NOIDLE); +#elif defined(REQ_NOIDLE) + rw |= REQ_NOIDLE; +#else +#warning Cannot control the NOIDLE flag +#endif } -#endif if (!mref->ref_skip_sync) { -#ifdef BIO_RW_SYNCIO if (brick->do_sync) { +#if defined(BIO_RW_RQ_MASK) || defined(BIO_FLUSH) rw |= (1 << BIO_RW_SYNCIO); - } +#elif defined(REQ_SYNC) + rw |= REQ_SYNC; +#else +#warning Cannot control the SYNC flag #endif -#ifdef BIO_RW_UNPLUG + } +#if defined(BIO_RW_RQ_MASK) || defined(BIO_FLUSH) if (brick->do_unplug && !cork) { rw |= (1 << BIO_RW_UNPLUG); } +#else + // there is no substitute, but the above NOIDLE should do the job (CHECK!) #endif } diff --git a/kernel/mars_if.c b/kernel/mars_if.c index d75d6859..0b4a7bec 100644 --- a/kernel/mars_if.c +++ b/kernel/mars_if.c @@ -246,6 +246,7 @@ if_make_request(struct request_queue *q, struct bio *bio) */ const int rw = bio_data_dir(bio); const int sectors = bio_sectors(bio); +// adapt to different kernel versions (TBD: improve) #if defined(BIO_RW_RQ_MASK) || defined(BIO_FLUSH) const bool ahead = bio_rw_flagged(bio, BIO_RW_AHEAD) && rw == READ; const bool barrier = bio_rw_flagged(bio, BIO_RW_BARRIER); @@ -254,14 +255,17 @@ if_make_request(struct request_queue *q, struct bio *bio) const bool meta = bio_rw_flagged(bio, BIO_RW_META); const bool discard = bio_rw_flagged(bio, BIO_RW_DISCARD); const bool noidle = bio_rw_flagged(bio, BIO_RW_NOIDLE); -#else - const bool ahead = bio_flagged(bio, __REQ_RAHEAD) && rw == READ; - const bool barrier = bio_flagged(bio, __REQ_FLUSH); - const bool syncio = bio_flagged(bio, __REQ_SYNC); +#elif defined(REQ_FLUSH) && defined(REQ_SYNC) +#define _flagged(x) (bio->bi_rw & (x)) + const bool ahead = _flagged(REQ_RAHEAD) && rw == READ; + const bool barrier = _flagged(REQ_FLUSH); + const bool syncio = _flagged(REQ_SYNC); const bool unplug = false; - const bool meta = bio_flagged(bio, __REQ_META); - const bool discard = bio_flagged(bio, __REQ_DISCARD); - const bool noidle = bio_flagged(bio, __REQ_THROTTLED); + const bool meta = _flagged(REQ_META); + const bool discard = _flagged(REQ_DISCARD); + const bool noidle = _flagged(REQ_THROTTLED); +#else +#error Cannot decode the bio flags #endif const int prio = bio_prio(bio);