hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/block/aoe/aoedev.c
....@@ -5,7 +5,7 @@
55 */
66
77 #include <linux/hdreg.h>
8
-#include <linux/blkdev.h>
8
+#include <linux/blk-mq.h>
99 #include <linux/netdevice.h>
1010 #include <linux/delay.h>
1111 #include <linux/slab.h>
....@@ -160,21 +160,22 @@
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
....@@ -197,7 +198,6 @@
197198 {
198199 struct aoetgt *t, **tt, **te;
199200 struct list_head *head, *pos, *nx;
200
- struct request *rq;
201201 int i;
202202
203203 d->flags &= ~DEVFL_UP;
....@@ -225,10 +225,11 @@
225225
226226 /* fast fail all pending I/O */
227227 if (d->blkq) {
228
- while ((rq = blk_peek_request(d->blkq))) {
229
- blk_start_request(rq);
230
- aoe_end_request(d, rq, 1);
231
- }
228
+ /* UP is cleared, freeze+quiesce to insure all are errored */
229
+ blk_mq_freeze_queue(d->blkq);
230
+ blk_mq_quiesce_queue(d->blkq);
231
+ blk_mq_unquiesce_queue(d->blkq);
232
+ blk_mq_unfreeze_queue(d->blkq);
232233 }
233234
234235 if (d->gd)
....@@ -275,9 +276,9 @@
275276 del_timer_sync(&d->timer);
276277 if (d->gd) {
277278 aoedisk_rm_debugfs(d);
278
- aoedisk_rm_sysfs(d);
279279 del_gendisk(d->gd);
280280 put_disk(d->gd);
281
+ blk_mq_free_tag_set(&d->tag_set);
281282 blk_cleanup_queue(d->blkq);
282283 }
283284 t = d->targets;
....@@ -322,10 +323,14 @@
322323 }
323324
324325 flush_scheduled_work();
325
- /* pass one: without sleeping, do aoedev_downdev */
326
+ /* pass one: do aoedev_downdev, which might sleep */
327
+restart1:
326328 spin_lock_irqsave(&devlist_lock, flags);
327329 for (d = devlist; d; d = d->next) {
328330 spin_lock(&d->lock);
331
+ if (d->flags & DEVFL_TKILL)
332
+ goto cont;
333
+
329334 if (exiting) {
330335 /* unconditionally take each device down */
331336 } else if (specified) {
....@@ -337,8 +342,11 @@
337342 || d->ref)
338343 goto cont;
339344
345
+ spin_unlock(&d->lock);
346
+ spin_unlock_irqrestore(&devlist_lock, flags);
340347 aoedev_downdev(d);
341348 d->flags |= DEVFL_TKILL;
349
+ goto restart1;
342350 cont:
343351 spin_unlock(&d->lock);
344352 }
....@@ -347,7 +355,7 @@
347355 /* pass two: call freedev, which might sleep,
348356 * for aoedevs marked with DEVFL_TKILL
349357 */
350
-restart:
358
+restart2:
351359 spin_lock_irqsave(&devlist_lock, flags);
352360 for (d = devlist; d; d = d->next) {
353361 spin_lock(&d->lock);
....@@ -356,7 +364,7 @@
356364 spin_unlock(&d->lock);
357365 spin_unlock_irqrestore(&devlist_lock, flags);
358366 freedev(d);
359
- goto restart;
367
+ goto restart2;
360368 }
361369 spin_unlock(&d->lock);
362370 }
....@@ -464,6 +472,7 @@
464472 d->ntargets = NTARGETS;
465473 INIT_WORK(&d->work, aoecmd_sleepwork);
466474 spin_lock_init(&d->lock);
475
+ INIT_LIST_HEAD(&d->rq_list);
467476 skb_queue_head_init(&d->skbpool);
468477 timer_setup(&d->timer, dummy_timer, 0);
469478 d->timer.expires = jiffies + HZ;