From patchwork Sat Apr 25 14:33:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6274701 Return-Path: X-Original-To: patchwork-linux-scsi@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 839839F313 for ; Sat, 25 Apr 2015 14:34:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98A812022A for ; Sat, 25 Apr 2015 14:34:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96EA4201CD for ; Sat, 25 Apr 2015 14:34:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932542AbbDYOeQ (ORCPT ); Sat, 25 Apr 2015 10:34:16 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35730 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964988AbbDYOeN (ORCPT ); Sat, 25 Apr 2015 10:34:13 -0400 Received: by pabtp1 with SMTP id tp1so77784799pab.2; Sat, 25 Apr 2015 07:34:12 -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=Ggayj/4iJVfGcK0W63n/q8q8WX5MJiB2MXnKYg+nYls=; b=yeXlnt4R6m2XfPyKwIdfwCZMpuoIsXb/cAXCXwn/V1X4+Wx1LkbetqUkNJLcuCwg4A J3bncYqOlu+pVj9QaaWb8TW0Kaf081/Q4xjPU/kOoeFwCHC4UyBnHZz9KpK+zaAZJI7J Hz+92d1QKZmUbGqrPTg49seSbYtLnWyjqFQj1tTDVEsr2+SG/S0g3VFYql1JVokEwoMP VpeaOBaxUie6kXzRMqWfg8M/4s/H9JVRU9EC9SYnnJ3+kggOrl5UZUQgCS59JW6QXqFV XipOYcXQPBWVEbZgAFFBvl9NqQB2JrztpT1cUuJh1HSOXfMT1LYTFNY4+s43+3lhWTu4 BOCg== X-Received: by 10.68.222.167 with SMTP id qn7mr6525612pbc.136.1429972452662; Sat, 25 Apr 2015 07:34:12 -0700 (PDT) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id ts4sm14156224pbc.41.2015.04.25.07.34.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Apr 2015 07:34:11 -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 v3 5/5] target/file: enable WRITE SAME when protection info is enabled Date: Sat, 25 Apr 2015 23:33:30 +0900 Message-Id: <1429972410-7146-6-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429972410-7146-1-git-send-email-akinobu.mita@gmail.com> References: <1429972410-7146-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 --- * No change from v2 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; }