Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp299075iog; Mon, 13 Jun 2022 03:01:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPGPe+30pf6ED1Yx+HIRXnyXwBLtWrVFxK3Q7KdliTRsNhQURSHO9++17ljp/imz4yr4K1 X-Received: by 2002:a05:6402:b25:b0:42d:d14b:6399 with SMTP id bo5-20020a0564020b2500b0042dd14b6399mr63766997edb.38.1655114492485; Mon, 13 Jun 2022 03:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655114492; cv=none; d=google.com; s=arc-20160816; b=tYhquTqp+LLQdF54W5igzJJA/XZNfiHOrTMtpQEZoydWC5UVg7N3Q4/nGwtM2lFs39 QfU2VBM/OHolnpiAT1j1drbrFCxQjER4YLFRgg6cWVPngUtoIVVcqCemG+kiHWoH6mQK pmDHD4RR0830uzPqlyqDPKuKm+J7PggvF/tis8iLqS/xqtkp1jxtO1AftF2tu7DSm7w0 TqmRQeWWHn9M/vOxzgtR2eAbGM5nGPzE1L6jFKb3N24j78ZAFhkG14Mm+Fdlkk9N3zFm X9ruuoQaQWrV7khqF3muihiEdLUGcSXVvhkOay32e3jE9iX95yAuN5CE8OFGn+SUSRhh g80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=GqJE62AFqWNqRbO5N7h9UB8tNgo51hNZpcgIC54MI+o=; b=GBABBHoxyEdzR85iPFvcZ/WDl8SJWLW65TphbpyuVDVyHvmnRgWp2p5rutlkZguh9X UbFgpXbE8xlvCYyP7RWyhxuzRH8E5G07n9PvPqttlHh+cDM45dGGpiZ9lvk3v1d4R392 ZtIHm+1+97Nt4FLWv3bm/WAS2rZSyGmrG7DzsHMoRadk+wEGJ+TH0goSggaLsF/UqO5b mn1J6M7H0t08yhbaFlh+LTBXHU9K/FfaTVYL3N76+NgpMbgS2r+Y7cD/8edyxhH12zpi ugvhnUNjPUwCnjQnYM+SYsFwsweEJR3hk71/hvUzD97iNjMbydyuvMV0ZCSnU/x/WgUv rCMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r8-20020a05640251c800b0042abf683338si8986141edd.212.2022.06.13.03.01.05; Mon, 13 Jun 2022 03:01:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240848AbiFMJho (ORCPT + 99 others); Mon, 13 Jun 2022 05:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240304AbiFMJhm (ORCPT ); Mon, 13 Jun 2022 05:37:42 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A52C1275F; Mon, 13 Jun 2022 02:37:41 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LM5vX2ft9z67PMv; Mon, 13 Jun 2022 17:32:40 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Mon, 13 Jun 2022 11:37:39 +0200 Received: from [10.195.33.253] (10.195.33.253) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 13 Jun 2022 10:37:38 +0100 Message-ID: <04540488-ec07-3bc2-a997-b7f64b0ba606@huawei.com> Date: Mon, 13 Jun 2022 10:40:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH RFC v2 04/18] scsi: core: Add support to send reserved commands To: Damien Le Moal , , , , , , CC: , , , , References: <1654770559-101375-1-git-send-email-john.garry@huawei.com> <1654770559-101375-5-git-send-email-john.garry@huawei.com> <3f519a72-bb43-b1f0-c85d-a2ea4596f2f2@opensource.wdc.com> From: John Garry In-Reply-To: <3f519a72-bb43-b1f0-c85d-a2ea4596f2f2@opensource.wdc.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.195.33.253] X-ClientProxiedBy: lhreml746-chm.china.huawei.com (10.201.108.196) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/2022 08:03, Damien Le Moal wrote: >> + if (shost->nr_reserved_cmds && !sht->reserved_queuecommand) { >> + shost_printk(KERN_ERR, shost, >> + "nr_reserved_cmds set but no method to queue\n"); >> + goto fail; > This would be a driver implementation bug. It would be a driver bug, but it probably makes the driver utterly useless and there is no point in continuing (to try to add). If the driver supports reserved commands then they are prob essential to make the driver function. > So what about a WARN() here ? Maybe but I really do not see a point in continuing > >> + } >> + >> /* Use min_t(int, ...) in case shost->can_queue exceeds SHRT_MAX */ >> shost->cmd_per_lun = min_t(int, shost->cmd_per_lun, >> shost->can_queue); >> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >> index f6e53c6d913c..8c8b4c6767d9 100644 >> --- a/drivers/scsi/scsi_lib.c >> +++ b/drivers/scsi/scsi_lib.c >> @@ -1422,6 +1422,16 @@ static void scsi_complete(struct request *rq) >> struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); >> enum scsi_disposition disposition; >> >> + if (scsi_is_reserved_cmd(cmd)) { >> + struct scsi_device *sdev = cmd->device; >> + >> + scsi_mq_uninit_cmd(cmd); >> + scsi_device_unbusy(sdev, cmd); >> + __blk_mq_end_request(rq, 0); >> + >> + return; >> + } >> + >> INIT_LIST_HEAD(&cmd->eh_entry); >> >> atomic_inc(&cmd->device->iodone_cnt); >> @@ -1706,6 +1716,28 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, >> >> WARN_ON_ONCE(cmd->budget_token < 0); >> >> + if (scsi_is_reserved_cmd(cmd)) { >> + unsigned char *host_scribble = cmd->host_scribble; >> + >> + if (!(req->rq_flags & RQF_DONTPREP)) { >> + ret = scsi_prepare_cmd(req); >> + if (ret != BLK_STS_OK) { >> + > Stray blank line. ok > >> + goto out_dec_host_busy; >> + } > No need for the curly brackets here. ok > >> + >> + req->rq_flags |= RQF_DONTPREP; >> + } else { >> + clear_bit(SCMD_STATE_COMPLETE, &cmd->state); >> + } Thanks, John