From patchwork Tue Apr 21 23:46:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6254361 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A456ABF4A6 for ; Tue, 21 Apr 2015 23:46:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B537E2034E for ; Tue, 21 Apr 2015 23:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC9A920328 for ; Tue, 21 Apr 2015 23:46:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965286AbbDUXqv (ORCPT ); Tue, 21 Apr 2015 19:46:51 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:34266 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965273AbbDUXqu (ORCPT ); Tue, 21 Apr 2015 19:46:50 -0400 Received: by pacyx8 with SMTP id yx8so255317473pac.1; Tue, 21 Apr 2015 16:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vetfjZCeGY/H8LNQrTcobx3T5s0QYmWP3U1KtmDghxY=; b=X599ekS0b6UFqhBcxQSjks7C30HraAnYfbHN2UwpV042uEWhJnQXkCZIxFr3HHi6Oo XXar60Lp0rLEABc39LXDH3x4pvQCEvDLCRRDsEuwvXpSr1TpeI2d5ZHvLqgQSZ4LkhmI 314NxVEcwoeXQiWuFGhgotVB1XV/pdRNf90qY/J+8S9JdVkReW7P4jI3oX0xP3VOBbrB NbyH2Zq9YC8fjBz0Yu6hr8CmqtwCXXtQoPlDVHEpGv1wcsyrqMPnNxn3IIWbJLxHFZDz Jhb8LweiVoSiNtdP/PFYRp/9Rne7SPwzptWWgiL+1yI124cp/grzl5noxCNI0EpoiKis 3hpw== X-Received: by 10.67.24.65 with SMTP id ig1mr41509105pad.61.1429660009847; Tue, 21 Apr 2015 16:46:49 -0700 (PDT) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id wh6sm3060643pbc.96.2015.04.21.16.46.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Apr 2015 16:46:48 -0700 (PDT) From: Akinobu Mita To: target-devel@vger.kernel.org Cc: Akinobu Mita , Nicholas Bellinger , Sagi Grimberg , "Martin K. Petersen" , Christoph Hellwig , "James E.J. Bottomley" , linux-scsi@vger.kernel.org Subject: [PATCH v2 4/4] target/file: enable WRITE SAME when protection info is enabled Date: Wed, 22 Apr 2015 08:46:17 +0900 Message-Id: <1429659977-7156-5-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429659977-7156-1-git-send-email-akinobu.mita@gmail.com> References: <1429659977-7156-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Now we can generate correct PI for WRITE SAME command, so it is unnecessary to disallow WRITE SAME when protection info is enabled. Signed-off-by: Akinobu Mita Cc: Nicholas Bellinger Cc: Sagi Grimberg Cc: "Martin K. Petersen" Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: target-devel@vger.kernel.org Cc: linux-scsi@vger.kernel.org --- * Changes from v1: - Fix inverted rw argument for fd_do_rw() - Perform DIF verify before write for WRITE_SAME drivers/target/target_core_file.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 829817a..fe98f58 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -376,16 +376,12 @@ fd_execute_write_same(struct se_cmd *cmd) struct bio_vec *bvec; unsigned int len = 0, i; ssize_t ret; + sense_reason_t rc; if (!nolb) { target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; } - if (cmd->prot_op) { - pr_err("WRITE_SAME: Protection information with FILEIO" - " backends not supported\n"); - return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - } if (cmd->t_data_nents > 1 || cmd->t_data_sg[0].length != cmd->se_dev->dev_attrib.block_size) { @@ -397,6 +393,10 @@ fd_execute_write_same(struct se_cmd *cmd) return TCM_INVALID_CDB_FIELD; } + rc = sbc_dif_verify(cmd, cmd->t_task_lba, nolb, 0, cmd->t_prot_sg, 0); + if (rc) + return rc; + bvec = kcalloc(nolb, sizeof(struct bio_vec), GFP_KERNEL); if (!bvec) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; @@ -418,6 +418,14 @@ fd_execute_write_same(struct se_cmd *cmd) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; } + if (cmd->prot_op) { + ret = fd_do_rw(cmd, fd_dev->fd_prot_file, se_dev->prot_length, + cmd->t_prot_sg, cmd->t_prot_nents, + cmd->prot_length, 1); + if (ret < 0) + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + } + target_complete_cmd(cmd, SAM_STAT_GOOD); return 0; }