Commit 61e7712e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

aoe: replace ->special use with private data in the request

Makes the code a whole lot easier to read.
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1bee4243
...@@ -100,6 +100,10 @@ enum { ...@@ -100,6 +100,10 @@ enum {
MAX_TAINT = 1000, /* cap on aoetgt taint */ MAX_TAINT = 1000, /* cap on aoetgt taint */
}; };
struct aoe_req {
unsigned long nr_bios;
};
struct buf { struct buf {
ulong nframesout; ulong nframesout;
struct bio *bio; struct bio *bio;
......
...@@ -387,6 +387,7 @@ aoeblk_gdalloc(void *vp) ...@@ -387,6 +387,7 @@ aoeblk_gdalloc(void *vp)
set = &d->tag_set; set = &d->tag_set;
set->ops = &aoeblk_mq_ops; set->ops = &aoeblk_mq_ops;
set->cmd_size = sizeof(struct aoe_req);
set->nr_hw_queues = 1; set->nr_hw_queues = 1;
set->queue_depth = 128; set->queue_depth = 128;
set->numa_node = NUMA_NO_NODE; set->numa_node = NUMA_NO_NODE;
......
...@@ -822,17 +822,6 @@ rexmit_timer(struct timer_list *timer) ...@@ -822,17 +822,6 @@ rexmit_timer(struct timer_list *timer)
spin_unlock_irqrestore(&d->lock, flags); spin_unlock_irqrestore(&d->lock, flags);
} }
static unsigned long
rqbiocnt(struct request *r)
{
struct bio *bio;
unsigned long n = 0;
__rq_for_each_bio(bio, r)
n++;
return n;
}
static void static void
bufinit(struct buf *buf, struct request *rq, struct bio *bio) bufinit(struct buf *buf, struct request *rq, struct bio *bio)
{ {
...@@ -847,6 +836,7 @@ nextbuf(struct aoedev *d) ...@@ -847,6 +836,7 @@ nextbuf(struct aoedev *d)
{ {
struct request *rq; struct request *rq;
struct request_queue *q; struct request_queue *q;
struct aoe_req *req;
struct buf *buf; struct buf *buf;
struct bio *bio; struct bio *bio;
...@@ -865,7 +855,11 @@ nextbuf(struct aoedev *d) ...@@ -865,7 +855,11 @@ nextbuf(struct aoedev *d)
blk_mq_start_request(rq); blk_mq_start_request(rq);
d->ip.rq = rq; d->ip.rq = rq;
d->ip.nxbio = rq->bio; d->ip.nxbio = rq->bio;
rq->special = (void *) rqbiocnt(rq);
req = blk_mq_rq_to_pdu(rq);
req->nr_bios = 0;
__rq_for_each_bio(bio, rq)
req->nr_bios++;
} }
buf = mempool_alloc(d->bufpool, GFP_ATOMIC); buf = mempool_alloc(d->bufpool, GFP_ATOMIC);
if (buf == NULL) { if (buf == NULL) {
...@@ -1069,16 +1063,13 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) ...@@ -1069,16 +1063,13 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail)
static void static void
aoe_end_buf(struct aoedev *d, struct buf *buf) aoe_end_buf(struct aoedev *d, struct buf *buf)
{ {
struct request *rq; struct request *rq = buf->rq;
unsigned long n; struct aoe_req *req = blk_mq_rq_to_pdu(rq);
if (buf == d->ip.buf) if (buf == d->ip.buf)
d->ip.buf = NULL; d->ip.buf = NULL;
rq = buf->rq;
mempool_free(buf, d->bufpool); mempool_free(buf, d->bufpool);
n = (unsigned long) rq->special; if (--req->nr_bios == 0)
rq->special = (void *) --n;
if (n == 0)
aoe_end_request(d, rq, 0); aoe_end_request(d, rq, 0);
} }
......
...@@ -160,21 +160,22 @@ static void ...@@ -160,21 +160,22 @@ static void
aoe_failip(struct aoedev *d) aoe_failip(struct aoedev *d)
{ {
struct request *rq; struct request *rq;
struct aoe_req *req;
struct bio *bio; struct bio *bio;
unsigned long n;
aoe_failbuf(d, d->ip.buf); aoe_failbuf(d, d->ip.buf);
rq = d->ip.rq; rq = d->ip.rq;
if (rq == NULL) if (rq == NULL)
return; return;
req = blk_mq_rq_to_pdu(rq);
while ((bio = d->ip.nxbio)) { while ((bio = d->ip.nxbio)) {
bio->bi_status = BLK_STS_IOERR; bio->bi_status = BLK_STS_IOERR;
d->ip.nxbio = bio->bi_next; d->ip.nxbio = bio->bi_next;
n = (unsigned long) rq->special; req->nr_bios--;
rq->special = (void *) --n;
} }
if ((unsigned long) rq->special == 0)
if (!req->nr_bios)
aoe_end_request(d, rq, 0); aoe_end_request(d, rq, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment