From patchwork Tue Oct 16 14:37:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10643673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 916E113AD for ; Tue, 16 Oct 2018 14:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E43729C77 for ; Tue, 16 Oct 2018 14:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 721832A1B8; Tue, 16 Oct 2018 14:37:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A84E29C77 for ; Tue, 16 Oct 2018 14:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727034AbeJPW2M (ORCPT ); Tue, 16 Oct 2018 18:28:12 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:38044 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeJPW2M (ORCPT ); Tue, 16 Oct 2018 18:28:12 -0400 Received: by mail-it1-f195.google.com with SMTP id i76-v6so32424335ita.3 for ; Tue, 16 Oct 2018 07:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=AjiNqqe/XNmbv8fULVpJefY8BsP51E7C/fL0NJa1730=; b=Q83jytIx4QdzmWmEVNQ579XGA2W6J2bd7LP7smHUP+6qf50eZG3Aa12Cf/9iZZ97cL ylAt8wXt/iRhmO7ZIj4lIIrCNciEMokMaH1Ad0Hf12UZZTfHOTigQxSZc7YwUEOiu+C+ fBRJua+KxO2pVqss9n8+Hm5eAXNo+FLj3EUA8QYtajT/XFs6qbo2IQWn9R8/ft7YRlyn lOhuYfOPU5kSIUrbFc1nEsUESd+YyV6mmqMKZK87AmJH/L3z0+k8NrejMUU4d/5Q6KnW rsTbgNaEfRN7VSbt0607/oU0nRje83vXP+QZc2Mwhx9pGaARHub3nHeXZ/lENJ6snczq 6IhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=AjiNqqe/XNmbv8fULVpJefY8BsP51E7C/fL0NJa1730=; b=NxF7T+fUZauc6L9QT2roUy0dMcDH+Pb6Vo61XpmNMvOJVl/l5NTnOhffC/Wl/pblJm 17PhwAF3oTvTGBSFRVY4wt15LtmuPT+ibcAbeCwCsTJS0ePWrGHCGfUDi5rljSYnupK/ 0YDYUv3W/i1ftU3+k6INc4x1sE0he+fcoaI3niX4BC4XMS3TD9oxsAawtTkUoaNTAZGh xNO3vFaqwdA7pz7naTIsTO78HVeAMMuQ7fIwAsd7ycRyH3WssqDBBBkFiXXsmbhPxbJ5 yOnwsyAh9tp3bLksg0OwNvJN8jG3FW6kwWVW1ZJbcMI75jxICJDl7P3a/p4ylcb8tGDu 2PxQ== X-Gm-Message-State: ABuFfogioecXRG0qYLbh5pMKxIv+excbgfbBFkKUqSCSDBCF2QBHAR9h n4g1hgzRgr2fNF9orokCQG5naX3ug3o= X-Google-Smtp-Source: ACcGV63vtIcDumVmccKl4YxYj28c0rxL0JiILFKoRler2BiXgTbH7C+kraunUooiwv202Mc1PUMz9g== X-Received: by 2002:a02:a98e:: with SMTP id q14-v6mr16519316jam.109.1539700646306; Tue, 16 Oct 2018 07:37:26 -0700 (PDT) Received: from [192.168.1.56] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id w140-v6sm5092204iof.22.2018.10.16.07.37.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 07:37:24 -0700 (PDT) To: linux-scsi Cc: Christoph Hellwig , satishkh@cisco.com From: Jens Axboe Subject: [PATCH] fnic_scsi: replace gross legacy tag hack with blk-mq hack Message-ID: Date: Tue, 16 Oct 2018 08:37:23 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Would be nice to fix up the SCSI midlayer instead, but this will do for now. Cc: Christoph Hellwig Cc: Satish Kharat Cc: linux-scsi@vger.kernel.org Signed-off-by: Jens Axboe --- drivers/scsi/fnic/fnic_scsi.c | 61 +++++++---------------------------- 1 file changed, 12 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 8cbd3c9f0b4c..c156bab6a2ee 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -2272,33 +2272,17 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, static inline int fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) { - struct blk_queue_tag *bqt = fnic->lport->host->bqt; - int tag, ret = SCSI_NO_TAG; + struct request_queue *q = sc->request->q; + struct request *dummy; - BUG_ON(!bqt); - if (!bqt) { - pr_err("Tags are not supported\n"); - goto end; - } - - do { - tag = find_next_zero_bit(bqt->tag_map, bqt->max_depth, 1); - if (tag >= bqt->max_depth) { - pr_err("Tag allocation failure\n"); - goto end; - } - } while (test_and_set_bit(tag, bqt->tag_map)); + dummy = blk_mq_alloc_request(q, REQ_OP_WRITE, BLK_MQ_REQ_NOWAIT); + if (IS_ERR(dummy)) + return SCSI_NO_TAG; - bqt->tag_index[tag] = sc->request; - sc->request->tag = tag; - sc->tag = tag; - if (!sc->request->special) - sc->request->special = sc; + sc->tag = sc->request->tag = dummy->tag; + sc->request->special = sc; - ret = tag; - -end: - return ret; + return dummy->tag; } /** @@ -2308,20 +2292,9 @@ fnic_scsi_host_start_tag(struct fnic *fnic, struct scsi_cmnd *sc) static inline void fnic_scsi_host_end_tag(struct fnic *fnic, struct scsi_cmnd *sc) { - struct blk_queue_tag *bqt = fnic->lport->host->bqt; - int tag = sc->request->tag; - - if (tag == SCSI_NO_TAG) - return; - - BUG_ON(!bqt || !bqt->tag_index[tag]); - if (!bqt) - return; + struct request *dummy = sc->request->special; - bqt->tag_index[tag] = NULL; - clear_bit(tag, bqt->tag_map); - - return; + blk_mq_free_request(dummy); } /* @@ -2380,19 +2353,9 @@ int fnic_device_reset(struct scsi_cmnd *sc) tag = sc->request->tag; if (unlikely(tag < 0)) { /* - * XXX(hch): current the midlayer fakes up a struct - * request for the explicit reset ioctls, and those - * 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. + * Really should fix the midlayer to pass in a proper + * request for ioctls... */ - tag = fnic_scsi_host_start_tag(fnic, sc); if (unlikely(tag == SCSI_NO_TAG)) goto fnic_device_reset_end;