From patchwork Fri Jun 2 03:45:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Yi X-Patchwork-Id: 9761527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 651AA60365 for ; Fri, 2 Jun 2017 03:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51C772853A for ; Fri, 2 Jun 2017 03:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4544228567; Fri, 2 Jun 2017 03:45:14 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 D9DE12853A for ; Fri, 2 Jun 2017 03:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751142AbdFBDpN (ORCPT ); Thu, 1 Jun 2017 23:45:13 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36521 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbdFBDpM (ORCPT ); Thu, 1 Jun 2017 23:45:12 -0400 Received: by mail-pf0-f196.google.com with SMTP id n23so10746377pfb.3 for ; Thu, 01 Jun 2017 20:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=ZoUcyW07QouKJkhwMXag49rVqWMi2I8JVIkhvY3CXLQ=; b=TDfBC9AxCPHXIuwgvgkB3AMa+TodEBRkNoVvOeEr1dxz0Hq/wxJDV98avyY1hpMgYc pduAMFK5RMv7EnEurdWjXk8cVoNR9G3zilIIIP54UyAd++SzAg+Ybs5Iii3prTjEsmfl vK86PwjI0dY3Xxr3XfWC4sf9aO4jWD32yz4ysJB6FEhGDgUqAAd9g7zPdodXKGGjAo4l 9V4KLgORFY0mMvyWGADUnSNj36nuUG7Ldqks1pMdh05FBv9YqVu9XJSZCfKg99ZK4PHk w6X4AiiDhGXrtc9kzxtWlpysfRFm+JGDQdy86ROTXjmCq7NNm+9usPVLqZzczMz4xAHf R4/A== 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-transfer-encoding:content-language; bh=ZoUcyW07QouKJkhwMXag49rVqWMi2I8JVIkhvY3CXLQ=; b=QZMe2JCtS0Q6gHbXN9FkuskxWyWKdaGbs8hUodg+tQD3i3PScQG/+YLd8AYWYL4jx/ c4KfCAqPU7hNSNmy2YWbRZde+CgrbvJy+EiaS6JJVtCpcV2NjZiTYiaLEVKimpcNaduG kD9ZP46YHh4cu76uQa81v1sNbAddJ4Xr5ZXBZi/Yo6tQpqgXpvaXq7NUCSlG/JlowSxR m4k8DQHk6s1m84L0pRGzSLXekMJmSJ0ZS1WeBqWhYywWuZJgq3jUrEHjyv91yWVI3Pc6 vLhZAfYoBgrQlBt6semRx8oRldmRGCxeuZ+P8olvIkQ2RFGvT0TXAvz6eKV4CW+jXQlv AE9A== X-Gm-Message-State: AODbwcC5FF8jnZoXgi5/LyNBZgpjeD5kY/d+erFCVXdLaK14ntj1xzyR sogAQUIvnoUgVzBqarQ= X-Received: by 10.98.31.155 with SMTP id l27mr4631487pfj.179.1496375112005; Thu, 01 Jun 2017 20:45:12 -0700 (PDT) Received: from [10.12.12.133] (125-227-147-112.HINET-IP.hinet.net. [125.227.147.112]) by smtp.gmail.com with ESMTPSA id q5sm34943681pfi.129.2017.06.01.20.45.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 20:45:11 -0700 (PDT) To: nab@linux-iscsi.org Cc: target-devel@vger.kernel.org From: Jiang Yi Subject: [PATCH] target: reject COMPARE_AND_WRITE if emulate_caw is not set Message-ID: <50b7c908-05f3-f90c-87a6-efbdc0a10956@gmail.com> Date: Fri, 2 Jun 2017 11:45:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 Content-Language: en-US Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Nic, in struct se_dev_attrib, there is a field emulate_caw. If this field is set zero, does it mean that the corresponding struct se_device does not support the scsi cmd COMPARE_AND_WRITE? Do fields like emulate_tpws, emulate_tpu, emulate_tas... imply "enable support for thin provision write same", "enable support for thin provision unmap", "enable support for task aborted status"? In function sbc_parse_cdb(), it rejects scsi cmd UNMAP if emulate_tpu is not set. So I think we should also reject COMPARE_AND_WRITE if emulate_caw is not set. I propose a patch: Signed-off-by: Jiang Yi --- drivers/target/target_core_sbc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 4316f7b..bdea345 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1005,6 +1005,12 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) break; } case COMPARE_AND_WRITE: + if (!dev->dev_attrib.emulate_caw) { + pr_err("se_device %s/%s (vpd_unit_serial %s) reject COMPARE_AND_WRITE\n", + dev->se_hba->backend->ops->name, dev->dev_group.cg_item.ci_name, + dev->t10_wwn.unit_serial); + return TCM_UNSUPPORTED_SCSI_OPCODE; + } sectors = cdb[13]; /* * Currently enforce COMPARE_AND_WRITE for a single sector