From patchwork Tue Jul 14 11:59:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 6786691 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 2F7F49F2F0 for ; Tue, 14 Jul 2015 12:00:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 294E1206D4 for ; Tue, 14 Jul 2015 12:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EFAAA206D9 for ; Tue, 14 Jul 2015 11:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbbGNL75 (ORCPT ); Tue, 14 Jul 2015 07:59:57 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35513 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbbGNL75 (ORCPT ); Tue, 14 Jul 2015 07:59:57 -0400 Received: by wiga1 with SMTP id a1so97226807wig.0 for ; Tue, 14 Jul 2015 04:59:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=uSYafMqMXZJF2pGKOJzMzWgcaCxrhneUiV3Txql66iE=; b=Vxt3jmxoSTXXHQDpUBtBInfrPN4kAgOwL3WINZkT9rPGo8QlWqA8obfFDfUPqoZSJU 0HqKyO6cCJ+y07k9XNJw2u16zBegV4sFO4TEaOQ9o9hWn6LpZXHFrg3wMJ61nuyK2f0B hH1omWDT8jhEmzdLr0hhg9Sn31PxG42/2bpwxSFnU/Iq1o4LauVtcmAKl2xerfAD4zKu /sjZtCI6RkKIWfufWhMJnlzR738HaHX5QQCJORdSJPExse7O9uuRFUzriL3hBOJMhqNu Jkda3A35ZgDghTYvI0TipNydKM/5+VS20bf7qtIKEib+fd7pViemrILcrY0sKaaaziMb T9hg== X-Gm-Message-State: ALoCoQnMLS+1X3PQ7yoOXdBTzGjg8Y+7ou0POCpIFHXQ2KanIkmPVg07DpZ6xBPfOtJXqugfoeXf X-Received: by 10.194.85.130 with SMTP id h2mr73366167wjz.2.1436875195569; Tue, 14 Jul 2015 04:59:55 -0700 (PDT) Received: from [10.223.0.123] ([193.47.165.251]) by smtp.googlemail.com with ESMTPSA id bg6sm1642232wjc.13.2015.07.14.04.59.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jul 2015 04:59:54 -0700 (PDT) Subject: Re: [PATCH 3/3] target: Return descriptor format sense data To: "Martin K. Petersen" , Christoph Hellwig References: <1436697423-20611-1-git-send-email-sagig@mellanox.com> <1436697423-20611-4-git-send-email-sagig@mellanox.com> <20150714071703.GC31117@infradead.org> Cc: Sagi Grimberg , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Hannes Reinecke , Bart Van Assche , "Nicholas A. Bellinger" , James Bottomley From: Sagi Grimberg Message-ID: <55A4F9B7.905@dev.mellanox.co.il> Date: Tue, 14 Jul 2015 14:59:51 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: 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 On 7/14/2015 11:21 AM, Martin K. Petersen wrote: >>>>>> "Christoph" == Christoph Hellwig writes: > > Christoph> I think this needs to be a tunable as old initiators might > Christoph> not be able to cope with descriptor sense data. My idea was > Christoph> to only turn it own if the LU is large enough to need it. > > We could make it conditional and only use the descriptor format if the > LBA is big enough to warrant it. > So would this be acceptable? target: Return descriptor format sense data in case the LU spans 64bit sectors In case a LU spans 64bit sectors, fixed size sense data information field is only 32 bits which means the sector information will be truncated. Thus, if the LU spans 64bit sectors, use descriptor format sense data to correctly report sector information. Reported-by: Christoph Hellwig Signed-off-by: Sagi Grimberg --- drivers/target/target_core_spc.c | 12 +++++++++--- drivers/target/target_core_transport.c | 3 ++- include/target/target_core_backend.h | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) -- -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index c43dcbf..f66abc1 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 */ + p[2] = (1 << 1); + if (TARGET_SENSE_DESC_FORMAT(dev)) + /* D_SENSE: Descriptor format sense data for 64bit sectors */ + p[2] |= (1 << 2); + /* * From spc4r23, 7.4.7 Control mode page * @@ -1144,6 +1149,7 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd) unsigned char *rbuf; u8 ua_asc = 0, ua_ascq = 0; unsigned char buf[SE_SENSE_BUF]; + bool desc_format = TARGET_SENSE_DESC_FORMAT(cmd->se_dev); memset(buf, 0, SE_SENSE_BUF); @@ -1158,10 +1164,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(desc_format, buf, UNIT_ATTENTION, ua_asc, ua_ascq); else - scsi_build_sense_buffer(0, buf, NO_SENSE, 0x0, 0x0); + scsi_build_sense_buffer(desc_format, 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..238c778 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2735,6 +2735,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) u8 *buffer = cmd->sense_buffer; int r = (__force int)reason; u8 asc, ascq; + bool desc_format = TARGET_SENSE_DESC_FORMAT(cmd->se_dev); if (r < ARRAY_SIZE(sense_info_table) && sense_info_table[r].key) si = &sense_info_table[r]; @@ -2754,7 +2755,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(desc_format, buffer, si->key, asc, ascq); if (si->add_sector_info) return scsi_set_sense_information(buffer, cmd->scsi_sense_length, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 1e5c8f9..6ce370f 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -3,6 +3,9 @@ #define TRANSPORT_FLAG_PASSTHROUGH 1 +#define TARGET_SENSE_DESC_FORMAT(dev) \ + dev->transport->get_blocks(dev) >= 0xffffffffULL + struct target_backend_ops { char name[16]; char inquiry_prod[16];