From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boaz Harrosh Subject: [PATCH 8/9] SQUASHME: pmem: Fixs to getgeo Date: Tue, 09 Sep 2014 18:49:43 +0300 Message-ID: <540F2197.2000803@plexistor.com> References: <1409173922-7484-1-git-send-email-ross.zwisler@linux.intel.com> <540F1EC6.4000504@plexistor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Andrew Morton To: Ross Zwisler , Jens Axboe , Matthew Wilcox , linux-fsdevel , linux-nvdimm@lists.01.org Return-path: Received: from mail-we0-f174.google.com ([74.125.82.174]:33885 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756836AbaIIPtp (ORCPT ); Tue, 9 Sep 2014 11:49:45 -0400 Received: by mail-we0-f174.google.com with SMTP id t60so2834853wes.5 for ; Tue, 09 Sep 2014 08:49:44 -0700 (PDT) In-Reply-To: <540F1EC6.4000504@plexistor.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Boaz Harrosh With current values fdisk does the wrong thing. On small disks it will offer 40 (20K) as first possible sector. With this patch fdisk will offer 8 (4k) as possible first sector, which is what we want. Note that current code had a BUG with anything bigger than 64G because hd_geometry->cylinders is ushort and it would overflow at this value. Anyway capacity is not calculated through getgeo so it does not matter what we set for cylinders. I have tested with cfdisk parted/gparted and they behave the same after this patch, with fdisk I have better expected behavior after this patch. Is there any other test I need to perform that might be affected by this? Signed-off-by: Boaz Harrosh --- drivers/block/pmem.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c index b415b61..600d225 100644 --- a/drivers/block/pmem.c +++ b/drivers/block/pmem.c @@ -40,10 +40,16 @@ struct pmem_device { static int pmem_getgeo(struct block_device *bd, struct hd_geometry *geo) { - /* some standard values */ - geo->heads = 1 << 6; - geo->sectors = 1 << 5; - geo->cylinders = get_capacity(bd->bd_disk) >> 11; + /* Just tell fdisk to get out of the way. The CHS math here is so + * convoluted and does not make any sense at all. With all 1s + * The math just gets out of the way. + * When doing the usual lying to fdisk with the (64,32,X) common at the + * rest of the Kernel, fdisk will offer 34 as first sector, with this + * here plus the 4K physical_block_size it will offer 8 (4K) + */ + geo->heads = 1; + geo->sectors = 1; + geo->cylinders = 1; return 0; } -- 1.9.3