From patchwork Wed Jul 29 09:23:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 6891401 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C912F9F358 for ; Wed, 29 Jul 2015 09:24:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF3C6207B9 for ; Wed, 29 Jul 2015 09:24:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 016BE2079C for ; Wed, 29 Jul 2015 09:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751101AbbG2JYp (ORCPT ); Wed, 29 Jul 2015 05:24:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47492 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752540AbbG2JYE (ORCPT ); Wed, 29 Jul 2015 05:24:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 50686B5E85; Wed, 29 Jul 2015 09:24:04 +0000 (UTC) Received: from rh2.redhat.com (vpn-60-109.rdu2.redhat.com [10.10.60.109]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6T9Ntmo011149; Wed, 29 Jul 2015 05:24:03 -0400 From: mchristi@redhat.com To: ceph-devel@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 11/18] target: add compare and write callback Date: Wed, 29 Jul 2015 04:23:48 -0500 Message-Id: <1438161835-27960-11-git-send-email-mchristi@redhat.com> In-Reply-To: <1438161835-27960-1-git-send-email-mchristi@redhat.com> References: <1438161835-27960-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Add a sbc ops callout for compare and write commands, so backends like rbd which support that commmand can execute it natively. Signed-off-by: Mike Christie --- drivers/target/target_core_sbc.c | 9 +++++++-- include/target/target_core_backend.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index e318ddb..9a001e6 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -968,8 +968,13 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) 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_cmd = sbc_compare_and_write; - cmd->transport_complete_callback = compare_and_write_callback; + if (ops->execute_compare_and_write) { + cmd->execute_cmd = ops->execute_compare_and_write; + } else { + cmd->execute_cmd = sbc_compare_and_write; + cmd->transport_complete_callback = + compare_and_write_callback; + } break; case READ_CAPACITY: size = READ_CAP_LEN; diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 1e5c8f9..ec5a09f 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -51,6 +51,7 @@ struct sbc_ops { sense_reason_t (*execute_write_same)(struct se_cmd *cmd); sense_reason_t (*execute_unmap)(struct se_cmd *cmd, sector_t lba, sector_t nolb); + sense_reason_t (*execute_compare_and_write)(struct se_cmd *cmd); }; int transport_backend_register(const struct target_backend_ops *);