From patchwork Fri Apr 3 15:58:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 6157301 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CD11ABF4A6 for ; Fri, 3 Apr 2015 16:00:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE07720259 for ; Fri, 3 Apr 2015 16:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 131412012E for ; Fri, 3 Apr 2015 16:00:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbbDCQAM (ORCPT ); Fri, 3 Apr 2015 12:00:12 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:46187 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753131AbbDCP6c (ORCPT ); Fri, 3 Apr 2015 11:58:32 -0400 Received: from pps.filterd (m0004060 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t33FtdXs003988; Fri, 3 Apr 2015 08:58:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=QGeGdhlU7bZyw7CgCffAU92b2V16YEfRzqzQODa1S28=; b=pEsxs/Psv+epekMO4+IC73nXIEtHBHLAoiCSsO4rfUZLdbnPscOqN6SkDyAByPHnkrRt aBj/1nZRu0TMHj9enkqG+VKQtEA1hBYfQ4gx0X98sq5gVI49IKDBHL4XrjQXEhIY8JEQ t2bKCnpRxctEo7L+f1qpDvjnm+7IckcdfFU= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1thvcq89rg-3 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Fri, 03 Apr 2015 08:58:29 -0700 Received: from lenny.thefacebook.com (192.168.52.13) by mail.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 3 Apr 2015 08:58:28 -0700 From: Jens Axboe To: , , CC: , Jens Axboe Subject: [PATCH 4/7] scsi: add scsi-mq helper for iterating over busy commands Date: Fri, 3 Apr 2015 09:58:20 -0600 Message-ID: <1428076703-31014-5-git-send-email-axboe@fb.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428076703-31014-1-git-send-email-axboe@fb.com> References: <1428076703-31014-1-git-send-email-axboe@fb.com> MIME-Version: 1.0 X-Originating-IP: [192.168.52.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-04-03_06:2015-04-03, 2015-04-03, 1970-01-01 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is basically just a wrapper around blk_mq_queue_busy_iter(), so that LLDs don't have to deal with or worry about blk-mq hardware queues. Signed-off-by: Jens Axboe --- drivers/scsi/scsi_lib.c | 25 +++++++++++++++++++++++++ include/scsi/scsi_device.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 54d7a6cbb98a..87a4c53c8b48 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -648,6 +648,31 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd) } } +struct scsi_mq_iter_data { + scsi_scmd_iter *fn; + void *priv; +}; + +static bool scsi_mq_iter_fn(struct blk_mq_hw_ctx *hctx, struct request *rq, + void *priv, bool reserved) +{ + struct scsi_mq_iter_data *data = priv; + struct scsi_cmnd *scmd = rq->special; + + return data->fn(scmd, data->priv); +} + +void scsi_mq_scmd_busy_iter(struct scsi_device *sdev, scsi_scmd_iter *fn, + void *priv) +{ + struct scsi_mq_iter_data data; + + data.fn = fn; + data.priv = priv; + blk_mq_queue_busy_iter(sdev->request_queue, scsi_mq_iter_fn, &data); +} +EXPORT_SYMBOL(scsi_mq_scmd_busy_iter); + /* * Function: scsi_release_buffers() * diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index a4c9336811d1..9250b03613f2 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -536,4 +536,7 @@ static inline int scsi_device_tpgs(struct scsi_device *sdev) MODULE_ALIAS("scsi:t-" __stringify(type) "*") #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x" +typedef bool (scsi_scmd_iter)(struct scsi_cmnd *, void *); +void scsi_mq_scmd_busy_iter(struct scsi_device *sdev, scsi_scmd_iter *fn, void *priv); + #endif /* _SCSI_SCSI_DEVICE_H */