]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - src/patches/suse-2.6.27.31/patches.fixes/block-use-bio_has_data
Reenabled linux-xen, added patches for Xen Kernel Version 2.6.27.31,
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.fixes / block-use-bio_has_data
diff --git a/src/patches/suse-2.6.27.31/patches.fixes/block-use-bio_has_data b/src/patches/suse-2.6.27.31/patches.fixes/block-use-bio_has_data
new file mode 100644 (file)
index 0000000..d11dd50
--- /dev/null
@@ -0,0 +1,131 @@
+From 0f96bb8e2923065d58d89c5c82c9f37ad1f18404 Mon Sep 17 00:00:00 2001
+From: Hannes Reinecke <hare@suse.de>
+Date: Thu, 23 Oct 2008 13:42:06 +0200
+Subject: [PATCH] Implement bio_has_data()
+
+Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
+Signed-off-by: Hannes Reinecke <hare@suse.de>
+---
+ block/blk-core.c       |   21 +++++++--------------
+ include/linux/bio.h    |   14 +++++++++++---
+ include/linux/blkdev.h |    2 +-
+ mm/bounce.c            |    2 +-
+ 4 files changed, 20 insertions(+), 19 deletions(-)
+
+--- a/block/blk-core.c
++++ b/block/blk-core.c
+@@ -624,10 +624,6 @@ blk_alloc_request(struct request_queue *
+       blk_rq_init(q, rq);
+-      /*
+-       * first three bits are identical in rq->cmd_flags and bio->bi_rw,
+-       * see bio.h and blkdev.h
+-       */
+       rq->cmd_flags = rw | REQ_ALLOCED;
+       if (priv) {
+@@ -1490,10 +1486,7 @@ void submit_bio(int rw, struct bio *bio)
+        * If it's a regular read/write or a barrier with data attached,
+        * go through the normal accounting stuff before submission.
+        */
+-      if (!bio_empty_barrier(bio)) {
+-
+-              BIO_BUG_ON(!bio->bi_size);
+-              BIO_BUG_ON(!bio->bi_io_vec);
++      if (bio_has_data(bio)) {
+               if (rw & WRITE) {
+                       count_vm_events(PGPGOUT, count);
+@@ -1888,7 +1881,7 @@ static int blk_end_io(struct request *rq
+       struct request_queue *q = rq->q;
+       unsigned long flags = 0UL;
+-      if (blk_fs_request(rq) || blk_pc_request(rq)) {
++      if (bio_has_data(rq->bio)) {
+               if (__end_that_request_first(rq, error, nr_bytes))
+                       return 1;
+@@ -1946,10 +1939,9 @@ EXPORT_SYMBOL_GPL(blk_end_request);
+  **/
+ int __blk_end_request(struct request *rq, int error, unsigned int nr_bytes)
+ {
+-      if (blk_fs_request(rq) || blk_pc_request(rq)) {
+-              if (__end_that_request_first(rq, error, nr_bytes))
+-                      return 1;
+-      }
++      if (bio_has_data(rq->bio) &&
++          __end_that_request_first(rq, error, nr_bytes))
++              return 1;
+       add_disk_randomness(rq->rq_disk);
+@@ -2016,7 +2008,8 @@ EXPORT_SYMBOL_GPL(blk_end_request_callba
+ void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
+                    struct bio *bio)
+ {
+-      /* first two bits are identical in rq->cmd_flags and bio->bi_rw */
++      /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw, and
++         we want BIO_RW_AHEAD (bit 1) to imply REQ_FAILFAST (bit 1). */
+       rq->cmd_flags |= (bio->bi_rw & 3);
+       rq->nr_phys_segments = bio_phys_segments(q, bio);
+--- a/include/linux/bio.h
++++ b/include/linux/bio.h
+@@ -157,8 +157,8 @@ struct bio {
+  * bit 3 -- fail fast, don't want low level driver retries
+  * bit 4 -- synchronous I/O hint: the block layer will unplug immediately
+  */
+-#define BIO_RW                0
+-#define BIO_RW_AHEAD  1
++#define BIO_RW                0       /* Must match RW in req flags (blkdev.h) */
++#define BIO_RW_AHEAD  1       /* Must match FAILFAST in req flags */
+ #define BIO_RW_BARRIER        2
+ #define BIO_RW_FAILFAST       3
+ #define BIO_RW_SYNC   4
+@@ -192,7 +192,7 @@ struct bio {
+ #define bio_failfast(bio)     ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
+ #define bio_rw_ahead(bio)     ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
+ #define bio_rw_meta(bio)      ((bio)->bi_rw & (1 << BIO_RW_META))
+-#define bio_empty_barrier(bio)        (bio_barrier(bio) && !(bio)->bi_size)
++#define bio_empty_barrier(bio)        (bio_barrier(bio) && !bio_has_data(bio))
+ static inline unsigned int bio_cur_sectors(struct bio *bio)
+ {
+@@ -452,6 +452,14 @@ static inline char *__bio_kmap_irq(struc
+       __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
+ #define bio_kunmap_irq(buf,flags)     __bio_kunmap_irq(buf, flags)
++/*
++ * Check whether this bio carries any data or not. A NULL bio is allowed.
++ */
++static inline int bio_has_data(struct bio *bio)
++{
++      return bio && bio->bi_io_vec != NULL;
++}
++
+ #if defined(CONFIG_BLK_DEV_INTEGRITY)
+ #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)]))
+--- a/include/linux/blkdev.h
++++ b/include/linux/blkdev.h
+@@ -84,7 +84,7 @@ enum {
+ };
+ /*
+- * request type modified bits. first three bits match BIO_RW* bits, important
++ * request type modified bits. first two bits match BIO_RW* bits, important
+  */
+ enum rq_flag_bits {
+       __REQ_RW,               /* not set, read. set, write */
+--- a/mm/bounce.c
++++ b/mm/bounce.c
+@@ -267,7 +267,7 @@ void blk_queue_bounce(struct request_que
+       /*
+        * Data-less bio, nothing to bounce
+        */
+-      if (bio_empty_barrier(*bio_orig))
++      if (!bio_has_data(*bio_orig))
+               return;
+       /*