From patchwork Sun Jul 12 10:37:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 6771901 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 339A2C05AC for ; Sun, 12 Jul 2015 10:37:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58D4D20651 for ; Sun, 12 Jul 2015 10:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EBFC20617 for ; Sun, 12 Jul 2015 10:37:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751853AbbGLKhr (ORCPT ); Sun, 12 Jul 2015 06:37:47 -0400 Received: from [193.47.165.129] ([193.47.165.129]:35845 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751887AbbGLKhq (ORCPT ); Sun, 12 Jul 2015 06:37:46 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from sagig@mellanox.com) with ESMTPS (AES256-SHA encrypted); 12 Jul 2015 13:37:10 +0300 Received: from r-vnc05.mtr.labs.mlnx (r-vnc05.mtr.labs.mlnx [10.208.0.115]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t6CAbAUr018465; Sun, 12 Jul 2015 13:37:10 +0300 Received: from r-vnc05.mtr.labs.mlnx (localhost [127.0.0.1]) by r-vnc05.mtr.labs.mlnx (8.14.4/8.14.4) with ESMTP id t6CAbAhc020691; Sun, 12 Jul 2015 13:37:10 +0300 Received: (from sagig@localhost) by r-vnc05.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id t6CAbAZc020690; Sun, 12 Jul 2015 13:37:10 +0300 From: Sagi Grimberg To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Christoph Hellwig , Hannes Reinecke , "Martin K. Petersen" , Bart Van Assche , "Nicholas A. Bellinger" , James Bottomley Subject: [PATCH 3/3] target: Return descriptor format sense data Date: Sun, 12 Jul 2015 13:37:03 +0300 Message-Id: <1436697423-20611-4-git-send-email-sagig@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1436697423-20611-1-git-send-email-sagig@mellanox.com> References: <1436697423-20611-1-git-send-email-sagig@mellanox.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=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Fixed size sense data information field is only 32 bits which means the sector (64 bits) information will be truncated. Move to descriptor format sense data to correctly report full sector information. Reported-by: Christoph Hellwig Signed-off-by: Sagi Grimberg Reviewed-by: Martin K. Petersen --- drivers/target/target_core_spc.c | 11 ++++++++--- drivers/target/target_core_transport.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index c43dcbf..2899675 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -761,7 +761,12 @@ static int spc_modesense_control(struct se_cmd *cmd, u8 pc, u8 *p) if (pc == 1) goto out; - p[2] = 2; + /* + * GLTSD: No implicit save of log parameters + * D_SENSE: Descriptor format sense data + */ + p[2] = (1 << 1 | 1 << 2); + /* * From spc4r23, 7.4.7 Control mode page * @@ -1158,10 +1163,10 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; if (!core_scsi3_ua_clear_for_request_sense(cmd, &ua_asc, &ua_ascq)) - scsi_build_sense_buffer(0, buf, UNIT_ATTENTION, + scsi_build_sense_buffer(1, buf, UNIT_ATTENTION, ua_asc, ua_ascq); else - scsi_build_sense_buffer(0, buf, NO_SENSE, 0x0, 0x0); + scsi_build_sense_buffer(1, buf, NO_SENSE, 0x0, 0x0); memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length)); transport_kunmap_data_sg(cmd); diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 7fb031b..935296c 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2754,7 +2754,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) ascq = si->ascq; } - scsi_build_sense_buffer(0, buffer, si->key, asc, ascq); + scsi_build_sense_buffer(1, buffer, si->key, asc, ascq); if (si->add_sector_info) return scsi_set_sense_information(buffer, cmd->scsi_sense_length,