From patchwork Fri Jun 15 18:23:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Lingshan X-Patchwork-Id: 10467323 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 5269060384 for ; Fri, 15 Jun 2018 18:25:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 430F628E3B for ; Fri, 15 Jun 2018 18:25:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37E8228E3D; Fri, 15 Jun 2018 18:25:34 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D5BF728E41 for ; Fri, 15 Jun 2018 18:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756311AbeFOSZd (ORCPT ); Fri, 15 Jun 2018 14:25:33 -0400 Received: from smtp2.provo.novell.com ([137.65.250.81]:47862 "EHLO smtp2.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756535AbeFOSZb (ORCPT ); Fri, 15 Jun 2018 14:25:31 -0400 Received: from vstart.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 15 Jun 2018 12:25:27 -0600 From: Zhu Lingshan To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org, nab@linux-iscsi.org, mchristi@redhat.com, martin.petersen@oracle.com Cc: hare@suse.de, lduncan@suse.com, ddiss@suse.de, lszhu@suse.de, Zhu Lingshan Subject: [PATCH 29/33] TCMU PR: enable PRO Reserve for TCMU devices Date: Sat, 16 Jun 2018 02:23:38 +0800 Message-Id: <20180615182342.6239-29-lszhu@suse.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615182342.6239-1-lszhu@suse.com> References: <20180615182342.6239-1-lszhu@suse.com> 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 This patch would enable the passthrough Persist Reservation Reserve operation routine for TCMU devices. If dev->passthrough_pr is 1, both dev->transport->pr_ops and dev->transport->pr_ops->pr_register are not NULL, core_scsi3_emulate_pro_reserve() will call dev->transport->pr_ops->pr_reserve to passthrough data to user space. Signed-off-by: Zhu Lingshan --- drivers/target/target_core_pr.c | 11 ++++++++++- drivers/target/target_core_user.c | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 0a06b8bb1134..d47ccbf05679 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -2450,6 +2450,8 @@ static sense_reason_t core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope, u64 res_key) { + struct se_device *dev = cmd->se_dev; + switch (type) { case PR_TYPE_WRITE_EXCLUSIVE: case PR_TYPE_EXCLUSIVE_ACCESS: @@ -2457,7 +2459,14 @@ core_scsi3_emulate_pro_reserve(struct se_cmd *cmd, int type, int scope, case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY: case PR_TYPE_WRITE_EXCLUSIVE_ALLREG: case PR_TYPE_EXCLUSIVE_ACCESS_ALLREG: - return core_scsi3_pro_reserve(cmd, type, scope, res_key); + if (dev->transport->pr_ops && + dev->transport->pr_ops->pr_register && + dev->passthrough_pr) + return dev->transport->pr_ops->pr_reserve(cmd, type, + res_key); + else + return core_scsi3_pro_reserve(cmd, type, scope, + res_key); default: pr_err("SPC-3 PR: Unknown Service Action RESERVE Type:" " 0x%02x\n", type); diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 8390b1d37873..e7daa76317bc 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -3011,6 +3011,7 @@ tcmu_execute_pr_reserve(struct se_cmd *cmd, int type, u64 key) sense_reason_t ret; int retries = 0; + mutex_lock(&udev->pr_info.pr_info_lock); udev->pr_info.pr_info_buf = kzalloc(TCMU_PR_INFO_XATTR_MAX_SIZE, GFP_KERNEL); if (!udev->pr_info.pr_info_buf) @@ -3127,6 +3128,7 @@ tcmu_execute_pr_reserve(struct se_cmd *cmd, int type, u64 key) tcmu_pr_info_free(pr_info); kfree(pr_xattr); kfree(udev->pr_info.pr_info_buf); + mutex_unlock(&udev->pr_info.pr_info_lock); return ret; }