diff options
author | NeilBrown <neilb@suse.de> | 2007-09-25 06:35:59 -0400 |
---|---|---|
committer | Jens Axboe <axboe@carl.home.kernel.dk> | 2007-10-10 03:25:56 -0400 |
commit | 5705f7021748a69d84d6567e68e8851dab551464 (patch) | |
tree | 5a6dbc8fc6055c0334f4a97540e36a7844b9c482 /drivers/block/nbd.c | |
parent | 9dfa52831e96194b8649613e3131baa2c109f7dc (diff) |
Introduce rq_for_each_segment replacing rq_for_each_bio
Every usage of rq_for_each_bio wraps a usage of
bio_for_each_segment, so these can be combined into
rq_for_each_segment.
We define "struct req_iterator" to hold the 'bio' and 'index' that
are needed for the double iteration.
Signed-off-by: Neil Brown <neilb@suse.de>
Various compile fixes by me...
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index be92c658f06e..228b2ff577aa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -180,7 +180,7 @@ static inline int sock_send_bvec(struct socket *sock, struct bio_vec *bvec, | |||
180 | 180 | ||
181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) | 181 | static int nbd_send_req(struct nbd_device *lo, struct request *req) |
182 | { | 182 | { |
183 | int result, i, flags; | 183 | int result, flags; |
184 | struct nbd_request request; | 184 | struct nbd_request request; |
185 | unsigned long size = req->nr_sectors << 9; | 185 | unsigned long size = req->nr_sectors << 9; |
186 | struct socket *sock = lo->sock; | 186 | struct socket *sock = lo->sock; |
@@ -205,16 +205,15 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
205 | } | 205 | } |
206 | 206 | ||
207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { | 207 | if (nbd_cmd(req) == NBD_CMD_WRITE) { |
208 | struct bio *bio; | 208 | struct req_iterator iter; |
209 | struct bio_vec *bvec; | ||
209 | /* | 210 | /* |
210 | * we are really probing at internals to determine | 211 | * we are really probing at internals to determine |
211 | * whether to set MSG_MORE or not... | 212 | * whether to set MSG_MORE or not... |
212 | */ | 213 | */ |
213 | rq_for_each_bio(bio, req) { | 214 | rq_for_each_segment(bvec, req, iter) { |
214 | struct bio_vec *bvec; | ||
215 | bio_for_each_segment(bvec, bio, i) { | ||
216 | flags = 0; | 215 | flags = 0; |
217 | if ((i < (bio->bi_vcnt - 1)) || bio->bi_next) | 216 | if (!rq_iter_last(req, iter)) |
218 | flags = MSG_MORE; | 217 | flags = MSG_MORE; |
219 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", | 218 | dprintk(DBG_TX, "%s: request %p: sending %d bytes data\n", |
220 | lo->disk->disk_name, req, | 219 | lo->disk->disk_name, req, |
@@ -226,7 +225,6 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) | |||
226 | result); | 225 | result); |
227 | goto error_out; | 226 | goto error_out; |
228 | } | 227 | } |
229 | } | ||
230 | } | 228 | } |
231 | } | 229 | } |
232 | return 0; | 230 | return 0; |
@@ -321,11 +319,10 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
321 | dprintk(DBG_RX, "%s: request %p: got reply\n", | 319 | dprintk(DBG_RX, "%s: request %p: got reply\n", |
322 | lo->disk->disk_name, req); | 320 | lo->disk->disk_name, req); |
323 | if (nbd_cmd(req) == NBD_CMD_READ) { | 321 | if (nbd_cmd(req) == NBD_CMD_READ) { |
324 | int i; | 322 | struct req_iterator iter; |
325 | struct bio *bio; | 323 | struct bio_vec *bvec; |
326 | rq_for_each_bio(bio, req) { | 324 | |
327 | struct bio_vec *bvec; | 325 | rq_for_each_segment(bvec, req, iter) { |
328 | bio_for_each_segment(bvec, bio, i) { | ||
329 | result = sock_recv_bvec(sock, bvec); | 326 | result = sock_recv_bvec(sock, bvec); |
330 | if (result <= 0) { | 327 | if (result <= 0) { |
331 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", | 328 | printk(KERN_ERR "%s: Receive data failed (result %d)\n", |
@@ -336,7 +333,6 @@ static struct request *nbd_read_stat(struct nbd_device *lo) | |||
336 | } | 333 | } |
337 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", | 334 | dprintk(DBG_RX, "%s: request %p: got %d bytes data\n", |
338 | lo->disk->disk_name, req, bvec->bv_len); | 335 | lo->disk->disk_name, req, bvec->bv_len); |
339 | } | ||
340 | } | 336 | } |
341 | } | 337 | } |
342 | return req; | 338 | return req; |