From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2on0099.outbound.protection.outlook.com ([207.46.100.99]:65472 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752413AbcEQSbV (ORCPT ); Tue, 17 May 2016 14:31:21 -0400 Subject: Re: [PATCH 2/2] target: fix max discard sectors calculation To: "Martin K. Petersen" References: <1463424410-17196-1-git-send-email-mchristi@redhat.com> <1463424410-17196-3-git-send-email-mchristi@redhat.com> <573A1826.3050007@sandisk.com> CC: , , , , From: Bart Van Assche Message-ID: <573B6006.8010206@sandisk.com> Date: Tue, 17 May 2016 11:16:38 -0700 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 05/16/2016 12:02 PM, Martin K. Petersen wrote: >>>>>> "Bart" == Bart Van Assche writes: > > Bart> That's a good catch. But seeing this patch makes me wonder whether > Bart> this patch introduces a 64-bit division? If so, I'm afraid this > Bart> patch will make 32-bit users unhappy. Have you considered to use > Bart> do_div() or >> (ilog2(block_size) - 9) instead? For the latter > Bart> alternative no 64-bit cast is needed. > > Please use logical_to_sectors(). Hello Martin, For SCSI initiator devices the logical block size is stored in struct scsi_device. logical_to_sectors() gets the logical block size from struct scsi_device. LIO however stores the logical block size in struct se_dev_attrib. If we want to keep SCSI initiator and SCSI target headers separate I think we will need two logical_to_sectors() functions - one for SCSI initiator devices and one for SCSI target devices. Bart.