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>
This commit is contained in:
Jens Axboe 2018-10-16 08:37:23 -06:00 committed by Martin K. Petersen
parent 6c714d4425
commit 4d5b4ac1ea

View File

@ -2266,33 +2266,17 @@ clean_pending_aborts_end:
static inline int static inline int
fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
{ {
struct blk_queue_tag *bqt = fnic->lport->host->bqt; struct request_queue *q = sc->request->q;
int tag, ret = SCSI_NO_TAG; struct request *dummy;
BUG_ON(!bqt); dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT);
if (!bqt) { if (IS_ERR(dummy))
pr_err("Tags are not supported\n"); return SCSI_NO_TAG;
goto end;
}
do { sc->tag = sc->request->tag = dummy->tag;
tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1); sc->request->special = sc;
if (tag >= bqt->max_depth) {
pr_err("Tag allocation failure\n");
goto end;
}
} while (test_and_set_bit(tag, bqt->tag_map));
bqt->tag_index[tag] = sc->request; return dummy->tag;
sc->request->tag = tag;
sc->tag = tag;
if (!sc->request->special)
sc->request->special = sc;
ret = tag;
end:
return ret;
} }
/** /**
@ -2302,20 +2286,9 @@ end:
static inline void static inline void
fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc)
{ {
struct blk_queue_tag *bqt = fnic->lport->host->bqt; struct request *dummy = sc->request->special;
int tag = sc->request->tag;
if (tag == SCSI_NO_TAG) blk_mq_free_request(dummy);
return;
BUG_ON(!bqt || !bqt->tag_index[tag]);
if (!bqt)
return;
bqt->tag_index[tag] = NULL;
clear_bit(tag, bqt->tag_map);
return;
} }
/* /*
@ -2374,19 +2347,9 @@ int fnic_device_reset(struct scsi_cmnd *sc)
tag = sc->request->tag; tag = sc->request->tag;
if (unlikely(tag < 0)) { if (unlikely(tag < 0)) {
/* /*
* XXX(hch): current the midlayer fakes up a struct * Really should fix the midlayer to pass in a proper
* request for the explicit reset ioctls, and those * request for ioctls...
* don't have a tag allocated to them. The below
* code pokes into midlayer structures to paper over
* this design issue, but that won't work for blk-mq.
*
* Either someone who can actually test the hardware
* will have to come up with a similar hack for the
* blk-mq case, or we'll have to bite the bullet and
* fix the way the EH ioctls work for real, but until
* that happens we fail these explicit requests here.
*/ */
tag = fnic_scsi_host_start_tag(fnic, sc); tag = fnic_scsi_host_start_tag(fnic, sc);
if (unlikely(tag == SCSI_NO_TAG)) if (unlikely(tag == SCSI_NO_TAG))
goto fnic_device_reset_end; goto fnic_device_reset_end;