From patchwork Thu Oct 16 05:37:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 5088041 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1E1AC11AC for ; Thu, 16 Oct 2014 05:37:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C814620176 for ; Thu, 16 Oct 2014 05:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1C7D2016C for ; Thu, 16 Oct 2014 05:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbaJPFhn (ORCPT ); Thu, 16 Oct 2014 01:37:43 -0400 Received: from sabe.cs.wisc.edu ([128.105.6.20]:39644 "EHLO sabe.cs.wisc.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751001AbaJPFhb (ORCPT ); Thu, 16 Oct 2014 01:37:31 -0400 Received: from localhost.localdomain (c-24-245-27-162.hsd1.mn.comcast.net [24.245.27.162]) (authenticated bits=0) by sabe.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id s9G5bMxF012139 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 16 Oct 2014 00:37:29 -0500 From: michaelc@cs.wisc.edu To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, ceph-devel@vger.kernel.org, axboe@kernel.dk Subject: [PATCH 4/5] lio: use REQ_COMPARE_AND_WRITE if supported Date: Thu, 16 Oct 2014 00:37:14 -0500 Message-Id: <1413437835-13778-5-git-send-email-michaelc@cs.wisc.edu> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1413437835-13778-1-git-send-email-michaelc@cs.wisc.edu> References: <1413437835-13778-1-git-send-email-michaelc@cs.wisc.edu> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Mike Christie This has lio callout to the backing store module if it supports using REQ_COMPARE_AND_WRITE. The backing store would set the device attribute max_compare_and_write_len if it supports using the new request type. If it is not supported then we do the read/cmp/write emulation in the sbc layer like before. Signed-off-by: Mike Christie --- drivers/target/target_core_sbc.c | 21 ++++++++++++++++----- drivers/target/target_core_spc.c | 12 ++++++++++-- drivers/target/target_core_transport.c | 1 + include/target/target_core_backend.h | 1 + include/target/target_core_base.h | 1 + 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index ebe62af..fe0c16a 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -555,6 +555,21 @@ sbc_compare_and_write(struct se_cmd *cmd) return TCM_NO_SENSE; } +static void sbc_setup_compare_and_write(struct se_cmd *cmd, struct sbc_ops *ops, + u32 sectors) +{ + cmd->t_task_nolb = sectors; + cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB | SCF_COMPARE_AND_WRITE; + + if (cmd->se_dev->dev_attrib.max_compare_and_write_len) { + cmd->execute_cmd = ops->execute_compare_and_write; + } else { + cmd->execute_rw = ops->execute_rw; + cmd->execute_cmd = sbc_compare_and_write; + cmd->transport_complete_callback = compare_and_write_callback; + } +} + static int sbc_set_prot_op_checks(u8 protect, enum target_prot_type prot_type, bool is_write, struct se_cmd *cmd) @@ -842,11 +857,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) */ size = 2 * sbc_get_size(cmd, sectors); cmd->t_task_lba = get_unaligned_be64(&cdb[2]); - cmd->t_task_nolb = sectors; - cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB | SCF_COMPARE_AND_WRITE; - cmd->execute_rw = ops->execute_rw; - cmd->execute_cmd = sbc_compare_and_write; - cmd->transport_complete_callback = compare_and_write_callback; + sbc_setup_compare_and_write(cmd, ops, sectors); break; case READ_CAPACITY: size = READ_CAP_LEN; diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 6cd7222..7db8c22 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -525,8 +525,16 @@ spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf) /* * Set MAXIMUM COMPARE AND WRITE LENGTH */ - if (dev->dev_attrib.emulate_caw) - buf[5] = 0x01; + if (dev->dev_attrib.emulate_caw) { + if (!dev->dev_attrib.max_compare_and_write_len) + /* + * if backing device does not have special handling + * then sbc will support up to 1 block. + */ + buf[5] = 0x01; + else + buf[5] = dev->dev_attrib.max_compare_and_write_len; + } /* * Set OPTIMAL TRANSFER LENGTH GRANULARITY diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 9ea0d5f..e7706f9 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1637,6 +1637,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED: case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED: case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED: + case TCM_MISCOMPARE_VERIFY: break; case TCM_OUT_OF_RESOURCES: sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 9adc1bc..06924b1 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -53,6 +53,7 @@ struct sbc_ops { sense_reason_t (*execute_write_same)(struct se_cmd *cmd); sense_reason_t (*execute_write_same_unmap)(struct se_cmd *cmd); sense_reason_t (*execute_unmap)(struct se_cmd *cmd); + sense_reason_t (*execute_compare_and_write)(struct se_cmd *cmd); }; int transport_subsystem_register(struct se_subsystem_api *); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 23c518a..bc0a26e 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -697,6 +697,7 @@ struct se_dev_attrib { u32 unmap_granularity; u32 unmap_granularity_alignment; u32 max_write_same_len; + u32 max_compare_and_write_len; u32 max_bytes_per_io; struct se_device *da_dev; struct config_group da_group;