]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - 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/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.fixes / block-use-bio_has_data
1 From 0f96bb8e2923065d58d89c5c82c9f37ad1f18404 Mon Sep 17 00:00:00 2001
2 From: Hannes Reinecke <hare@suse.de>
3 Date: Thu, 23 Oct 2008 13:42:06 +0200
4 Subject: [PATCH] Implement bio_has_data()
5
6 Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
7 Signed-off-by: Hannes Reinecke <hare@suse.de>
8 ---
9 block/blk-core.c | 21 +++++++--------------
10 include/linux/bio.h | 14 +++++++++++---
11 include/linux/blkdev.h | 2 +-
12 mm/bounce.c | 2 +-
13 4 files changed, 20 insertions(+), 19 deletions(-)
14
15 --- a/block/blk-core.c
16 +++ b/block/blk-core.c
17 @@ -624,10 +624,6 @@ blk_alloc_request(struct request_queue *
18
19 blk_rq_init(q, rq);
20
21 - /*
22 - * first three bits are identical in rq->cmd_flags and bio->bi_rw,
23 - * see bio.h and blkdev.h
24 - */
25 rq->cmd_flags = rw | REQ_ALLOCED;
26
27 if (priv) {
28 @@ -1490,10 +1486,7 @@ void submit_bio(int rw, struct bio *bio)
29 * If it's a regular read/write or a barrier with data attached,
30 * go through the normal accounting stuff before submission.
31 */
32 - if (!bio_empty_barrier(bio)) {
33 -
34 - BIO_BUG_ON(!bio->bi_size);
35 - BIO_BUG_ON(!bio->bi_io_vec);
36 + if (bio_has_data(bio)) {
37
38 if (rw & WRITE) {
39 count_vm_events(PGPGOUT, count);
40 @@ -1888,7 +1881,7 @@ static int blk_end_io(struct request *rq
41 struct request_queue *q = rq->q;
42 unsigned long flags = 0UL;
43
44 - if (blk_fs_request(rq) || blk_pc_request(rq)) {
45 + if (bio_has_data(rq->bio)) {
46 if (__end_that_request_first(rq, error, nr_bytes))
47 return 1;
48
49 @@ -1946,10 +1939,9 @@ EXPORT_SYMBOL_GPL(blk_end_request);
50 **/
51 int __blk_end_request(struct request *rq, int error, unsigned int nr_bytes)
52 {
53 - if (blk_fs_request(rq) || blk_pc_request(rq)) {
54 - if (__end_that_request_first(rq, error, nr_bytes))
55 - return 1;
56 - }
57 + if (bio_has_data(rq->bio) &&
58 + __end_that_request_first(rq, error, nr_bytes))
59 + return 1;
60
61 add_disk_randomness(rq->rq_disk);
62
63 @@ -2016,7 +2008,8 @@ EXPORT_SYMBOL_GPL(blk_end_request_callba
64 void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
65 struct bio *bio)
66 {
67 - /* first two bits are identical in rq->cmd_flags and bio->bi_rw */
68 + /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw, and
69 + we want BIO_RW_AHEAD (bit 1) to imply REQ_FAILFAST (bit 1). */
70 rq->cmd_flags |= (bio->bi_rw & 3);
71
72 rq->nr_phys_segments = bio_phys_segments(q, bio);
73 --- a/include/linux/bio.h
74 +++ b/include/linux/bio.h
75 @@ -157,8 +157,8 @@ struct bio {
76 * bit 3 -- fail fast, don't want low level driver retries
77 * bit 4 -- synchronous I/O hint: the block layer will unplug immediately
78 */
79 -#define BIO_RW 0
80 -#define BIO_RW_AHEAD 1
81 +#define BIO_RW 0 /* Must match RW in req flags (blkdev.h) */
82 +#define BIO_RW_AHEAD 1 /* Must match FAILFAST in req flags */
83 #define BIO_RW_BARRIER 2
84 #define BIO_RW_FAILFAST 3
85 #define BIO_RW_SYNC 4
86 @@ -192,7 +192,7 @@ struct bio {
87 #define bio_failfast(bio) ((bio)->bi_rw & (1 << BIO_RW_FAILFAST))
88 #define bio_rw_ahead(bio) ((bio)->bi_rw & (1 << BIO_RW_AHEAD))
89 #define bio_rw_meta(bio) ((bio)->bi_rw & (1 << BIO_RW_META))
90 -#define bio_empty_barrier(bio) (bio_barrier(bio) && !(bio)->bi_size)
91 +#define bio_empty_barrier(bio) (bio_barrier(bio) && !bio_has_data(bio))
92
93 static inline unsigned int bio_cur_sectors(struct bio *bio)
94 {
95 @@ -452,6 +452,14 @@ static inline char *__bio_kmap_irq(struc
96 __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
97 #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
98
99 +/*
100 + * Check whether this bio carries any data or not. A NULL bio is allowed.
101 + */
102 +static inline int bio_has_data(struct bio *bio)
103 +{
104 + return bio && bio->bi_io_vec != NULL;
105 +}
106 +
107 #if defined(CONFIG_BLK_DEV_INTEGRITY)
108
109 #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)]))
110 --- a/include/linux/blkdev.h
111 +++ b/include/linux/blkdev.h
112 @@ -84,7 +84,7 @@ enum {
113 };
114
115 /*
116 - * request type modified bits. first three bits match BIO_RW* bits, important
117 + * request type modified bits. first two bits match BIO_RW* bits, important
118 */
119 enum rq_flag_bits {
120 __REQ_RW, /* not set, read. set, write */
121 --- a/mm/bounce.c
122 +++ b/mm/bounce.c
123 @@ -267,7 +267,7 @@ void blk_queue_bounce(struct request_que
124 /*
125 * Data-less bio, nothing to bounce
126 */
127 - if (bio_empty_barrier(*bio_orig))
128 + if (!bio_has_data(*bio_orig))
129 return;
130
131 /*