aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2018-10-16 10:37:23 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-10-17 22:06:04 -0400
commit4d5b4ac1eae471bcd0fa381ab4099cc33e94e15d (patch)
treeb7ba4ec1133d693f963230ea0301f0cec057a636
parent6c714d44259494b4d593dd88d2b5a43ff1730680 (diff)
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>
-rw-r--r--drivers/scsi/fnic/fnic_scsi.c61
1 files changed, 12 insertions, 49 deletions
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index 12a2f8fa4d19..96acfcecd540 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2266,33 +2266,17 @@ clean_pending_aborts_end:
2266static inline int 2266static inline int
2267fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) 2267fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc)
2268{ 2268{
2269 struct blk_queue_tag *bqt = fnic->lport->host->bqt; 2269 struct request_queue *q = sc->request->q;
2270 int tag, ret = SCSI_NO_TAG; 2270 struct request *dummy;
2271 2271
2272 BUG_ON(!bqt); 2272 dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT);
2273 if (!bqt) { 2273 if (IS_ERR(dummy))
2274 pr_err("Tags are not supported\n"); 2274 return SCSI_NO_TAG;
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));
2285 2275
2286 bqt->tag_index[tag] = sc->request; 2276 sc->tag = sc->request->tag = dummy->tag;
2287 sc->request->tag = tag; 2277 sc->request->special = sc;
2288 sc->tag = tag;
2289 if (!sc->request->special)
2290 sc->request->special = sc;
2291 2278
2292 ret = tag; 2279 return dummy->tag;
2293
2294end:
2295 return ret;
2296} 2280}
2297 2281
2298/** 2282/**
@@ -2302,20 +2286,9 @@ end:
2302static inline void 2286static inline void
2303fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) 2287fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc)
2304{ 2288{
2305 struct blk_queue_tag *bqt = fnic->lport->host->bqt; 2289 struct request *dummy = sc->request->special;
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;
2314 2290
2315 bqt->tag_index[tag] = NULL; 2291 blk_mq_free_request(dummy);
2316 clear_bit(tag, bqt->tag_map);
2317
2318 return;
2319} 2292}
2320 2293
2321/* 2294/*
@@ -2374,19 +2347,9 @@ int fnic_device_reset(struct scsi_cmnd *sc)
2374 tag = sc->request->tag; 2347 tag = sc->request->tag;
2375 if (unlikely(tag < 0)) { 2348 if (unlikely(tag < 0)) {
2376 /* 2349 /*
2377 * XXX(hch): current the midlayer fakes up a struct 2350 * Really should fix the midlayer to pass in a proper
2378 * request for the explicit reset ioctls, and those 2351 * request for ioctls...
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.
2388 */ 2352 */
2389
2390 tag = fnic_scsi_host_start_tag(fnic, sc); 2353 tag = fnic_scsi_host_start_tag(fnic, sc);
2391 if (unlikely(tag == SCSI_NO_TAG)) 2354 if (unlikely(tag == SCSI_NO_TAG))
2392 goto fnic_device_reset_end; 2355 goto fnic_device_reset_end;