Skip to content

Commit 4d5b4ac

Browse files
axboemartinkpetersen
authored andcommitted
scsi: fnic: replace gross legacy tag hack with blk-mq hack
Would be nice to fix up the SCSI midlayer instead, but this will do for now. Cc: Christoph Hellwig <hch@lst.de> Cc: Satish Kharat <satishkh@cisco.com> Cc: linux-scsi@vger.kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 6c714d4 commit 4d5b4ac

File tree

1 file changed

+12
-49
lines changed

1 file changed

+12
-49
lines changed

drivers/scsi/fnic/fnic_scsi.c

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,33 +2266,17 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
22662266
static inline int
22672267
fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
22682268
{
2269-
struct blk_queue_tag *bqt = fnic->lport->host->bqt;
2270-
int tag, ret = SCSI_NO_TAG;
2269+
struct request_queue *q = sc->request->q;
2270+
struct request *dummy;
22712271

2272-
BUG_ON(!bqt);
2273-
if (!bqt) {
2274-
pr_err("Tags are not supported\n");
2275-
goto end;
2276-
}
2277-
2278-
do {
2279-
tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1);
2280-
if (tag >= bqt->max_depth) {
2281-
pr_err("Tag allocation failure\n");
2282-
goto end;
2283-
}
2284-
} while (test_and_set_bit(tag, bqt->tag_map));
2272+
dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT);
2273+
if (IS_ERR(dummy))
2274+
return SCSI_NO_TAG;
22852275

2286-
bqt->tag_index[tag] = sc->request;
2287-
sc->request->tag = tag;
2288-
sc->tag = tag;
2289-
if (!sc->request->special)
2290-
sc->request->special = sc;
2276+
sc->tag = sc->request->tag = dummy->tag;
2277+
sc->request->special = sc;
22912278

2292-
ret = tag;
2293-
2294-
end:
2295-
return ret;
2279+
return dummy->tag;
22962280
}
22972281

22982282
/**
@@ -2302,20 +2286,9 @@ fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
23022286
static inline void
23032287
fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc)
23042288
{
2305-
struct blk_queue_tag *bqt = fnic->lport->host->bqt;
2306-
int tag = sc->request->tag;
2307-
2308-
if (tag == SCSI_NO_TAG)
2309-
return;
2310-
2311-
BUG_ON(!bqt || !bqt->tag_index[tag]);
2312-
if (!bqt)
2313-
return;
2289+
struct request *dummy = sc->request->special;
23142290

2315-
bqt->tag_index[tag] = NULL;
2316-
clear_bit(tag, bqt->tag_map);
2317-
2318-
return;
2291+
blk_mq_free_request(dummy);
23192292
}
23202293

23212294
/*
@@ -2374,19 +2347,9 @@ int fnic_device_reset(struct scsi_cmnd *sc)
23742347
tag = sc->request->tag;
23752348
if (unlikely(tag < 0)) {
23762349
/*
2377-
* XXX(hch): current the midlayer fakes up a struct
2378-
* request for the explicit reset ioctls, and those
2379-
* don't have a tag allocated to them. The below
2380-
* code pokes into midlayer structures to paper over
2381-
* this design issue, but that won't work for blk-mq.
2382-
*
2383-
* Either someone who can actually test the hardware
2384-
* will have to come up with a similar hack for the
2385-
* blk-mq case, or we'll have to bite the bullet and
2386-
* fix the way the EH ioctls work for real, but until
2387-
* that happens we fail these explicit requests here.
2350+
* Really should fix the midlayer to pass in a proper
2351+
* request for ioctls...
23882352
*/
2389-
23902353
tag = fnic_scsi_host_start_tag(fnic, sc);
23912354
if (unlikely(tag == SCSI_NO_TAG))
23922355
goto fnic_device_reset_end;

0 commit comments

Comments
 (0)