Skip to content

Commit 61e7712

Browse files
Christoph Hellwigaxboe
authored andcommitted
aoe: replace ->special use with private data in the request
Makes the code a whole lot easier to read. Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1bee424 commit 61e7712

4 files changed

Lines changed: 20 additions & 23 deletions

File tree

‎drivers/block/aoe/aoe.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ enum {
100100
MAX_TAINT = 1000, /* cap on aoetgt taint */
101101
};
102102

103+
struct aoe_req {
104+
unsigned long nr_bios;
105+
};
106+
103107
struct buf {
104108
ulong nframesout;
105109
struct bio *bio;

‎drivers/block/aoe/aoeblk.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ aoeblk_gdalloc(void *vp)
387387

388388
set = &d->tag_set;
389389
set->ops = &aoeblk_mq_ops;
390+
set->cmd_size = sizeof(struct aoe_req);
390391
set->nr_hw_queues = 1;
391392
set->queue_depth = 128;
392393
set->numa_node = NUMA_NO_NODE;

‎drivers/block/aoe/aoecmd.c‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -822,17 +822,6 @@ rexmit_timer(struct timer_list *timer)
822822
spin_unlock_irqrestore(&d->lock, flags);
823823
}
824824

825-
static unsigned long
826-
rqbiocnt(struct request *r)
827-
{
828-
struct bio *bio;
829-
unsigned long n = 0;
830-
831-
__rq_for_each_bio(bio, r)
832-
n++;
833-
return n;
834-
}
835-
836825
static void
837826
bufinit(struct buf *buf, struct request *rq, struct bio *bio)
838827
{
@@ -847,6 +836,7 @@ nextbuf(struct aoedev *d)
847836
{
848837
struct request *rq;
849838
struct request_queue *q;
839+
struct aoe_req *req;
850840
struct buf *buf;
851841
struct bio *bio;
852842

@@ -865,7 +855,11 @@ nextbuf(struct aoedev *d)
865855
blk_mq_start_request(rq);
866856
d->ip.rq = rq;
867857
d->ip.nxbio = rq->bio;
868-
rq->special = (void *) rqbiocnt(rq);
858+
859+
req = blk_mq_rq_to_pdu(rq);
860+
req->nr_bios = 0;
861+
__rq_for_each_bio(bio, rq)
862+
req->nr_bios++;
869863
}
870864
buf = mempool_alloc(d->bufpool, GFP_ATOMIC);
871865
if (buf == NULL) {
@@ -1069,16 +1063,13 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail)
10691063
static void
10701064
aoe_end_buf(struct aoedev *d, struct buf *buf)
10711065
{
1072-
struct request *rq;
1073-
unsigned long n;
1066+
struct request *rq = buf->rq;
1067+
struct aoe_req *req = blk_mq_rq_to_pdu(rq);
10741068

10751069
if (buf == d->ip.buf)
10761070
d->ip.buf = NULL;
1077-
rq = buf->rq;
10781071
mempool_free(buf, d->bufpool);
1079-
n = (unsigned long) rq->special;
1080-
rq->special = (void *) --n;
1081-
if (n == 0)
1072+
if (--req->nr_bios == 0)
10821073
aoe_end_request(d, rq, 0);
10831074
}
10841075

‎drivers/block/aoe/aoedev.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,22 @@ static void
160160
aoe_failip(struct aoedev *d)
161161
{
162162
struct request *rq;
163+
struct aoe_req *req;
163164
struct bio *bio;
164-
unsigned long n;
165165

166166
aoe_failbuf(d, d->ip.buf);
167-
168167
rq = d->ip.rq;
169168
if (rq == NULL)
170169
return;
170+
171+
req = blk_mq_rq_to_pdu(rq);
171172
while ((bio = d->ip.nxbio)) {
172173
bio->bi_status = BLK_STS_IOERR;
173174
d->ip.nxbio = bio->bi_next;
174-
n = (unsigned long) rq->special;
175-
rq->special = (void *) --n;
175+
req->nr_bios--;
176176
}
177-
if ((unsigned long) rq->special == 0)
177+
178+
if (!req->nr_bios)
178179
aoe_end_request(d, rq, 0);
179180
}
180181

0 commit comments

Comments
 (0)