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
 bufinit(struct buf *buf, struct request *rq, struct bio *bio)
 {
 {
        struct request *rq;
        struct request_queue *q;
+       struct aoe_req *req;
        struct buf *buf;
        struct bio *bio;
 
                blk_mq_start_request(rq);
                d->ip.rq = rq;
                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);
        if (buf == NULL) {
 static void
 aoe_end_buf(struct aoedev *d, struct buf *buf)
 {
-       struct request *rq;
-       unsigned long n;
+       struct request *rq = buf->rq;
+       struct aoe_req *req = blk_mq_rq_to_pdu(rq);
 
        if (buf == d->ip.buf)
                d->ip.buf = NULL;
-       rq = buf->rq;
        mempool_free(buf, d->bufpool);
-       n = (unsigned long) rq->special;
-       rq->special = (void *) --n;
-       if (n == 0)
+       if (--req->nr_bios == 0)
                aoe_end_request(d, rq, 0);
 }
 
 
 aoe_failip(struct aoedev *d)
 {
        struct request *rq;
+       struct aoe_req *req;
        struct bio *bio;
-       unsigned long n;
 
        aoe_failbuf(d, d->ip.buf);
-
        rq = d->ip.rq;
        if (rq == NULL)
                return;
+
+       req = blk_mq_rq_to_pdu(rq);
        while ((bio = d->ip.nxbio)) {
                bio->bi_status = BLK_STS_IOERR;
                d->ip.nxbio = bio->bi_next;
-               n = (unsigned long) rq->special;
-               rq->special = (void *) --n;
+               req->nr_bios--;
        }
-       if ((unsigned long) rq->special == 0)
+
+       if (!req->nr_bios)
                aoe_end_request(d, rq, 0);
 }