From patchwork Tue Apr 7 17:18:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 6173991 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 A32C0BF4A6 for ; Tue, 7 Apr 2015 17:20:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8C0D203AC for ; Tue, 7 Apr 2015 17:20:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2E7C20395 for ; Tue, 7 Apr 2015 17:20:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754214AbbDGRUd (ORCPT ); Tue, 7 Apr 2015 13:20:33 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:45879 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754002AbbDGRSv (ORCPT ); Tue, 7 Apr 2015 13:18:51 -0400 Received: from pps.filterd (m0004003 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t37HDDKx004350; Tue, 7 Apr 2015 10:18:47 -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=cBu54kY//woWexlCYA1dT1kVjpyoA2Cak+TQYQPUGYE=; b=WkqhCs1cwhTtQHycHFZ66yJ0eH3kIqWp8Y/2HkUxt3/N0EiydvkFI9X8oImny34OZYse KPdgq4E+v12NsiM3DL50fQcU9hvpm9ELLOK9JNAA0BspMj17MmyPnQvK3Nv8AwFnzNgb 29n2wDLEG6MsWl15EhxCj0zhpXgo5j46zVA= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1tmjvy04vq-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Tue, 07 Apr 2015 10:18:47 -0700 Received: from localhost.localdomain (192.168.54.13) by mail.TheFacebook.com (192.168.16.18) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 7 Apr 2015 10:18:45 -0700 From: Jens Axboe To: , , CC: , Jens Axboe Subject: [PATCH 2/6] scsi: ensure that a request is valid when returning it from scsi_find_tag() Date: Tue, 7 Apr 2015 11:18:36 -0600 Message-ID: <1428427120-20971-3-git-send-email-axboe@fb.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428427120-20971-1-git-send-email-axboe@fb.com> References: <1428427120-20971-1-git-send-email-axboe@fb.com> MIME-Version: 1.0 X-Originating-IP: [192.168.54.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-07_04:2015-04-07, 2015-04-07, 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 For the scsi-mq case, ensure that the request has been started before returning it from scsi_find_tag(). This is akin to the ->special check for the non-mq case, it ensures that the request has been setup and issued. Signed-off-by: Jens Axboe --- include/scsi/scsi_tcq.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h index b27977e8aaed..8634cab61aeb 100644 --- a/include/scsi/scsi_tcq.h +++ b/include/scsi/scsi_tcq.h @@ -35,8 +35,15 @@ static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag) struct request *req; if (tag != SCSI_NO_TAG) { - if (shost_use_blk_mq(sdev->host)) - return scsi_mq_find_tag(sdev->host, tag); + if (shost_use_blk_mq(sdev->host)) { + struct scsi_cmnd *scmd; + + scmd = scsi_mq_find_tag(sdev->host, tag); + if (blk_mq_request_started(scmd->request)) + return scmd; + + return NULL; + } req = blk_queue_find_tag(sdev->request_queue, tag); return req ? (struct scsi_cmnd *)req->special : NULL;