From owner-freebsd-geom@FreeBSD.ORG Sat Feb 15 21:27:19 2014 Return-Path: Delivered-To: freebsd-geom@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 57AA41000; Sat, 15 Feb 2014 21:27:19 +0000 (UTC) Received: from wonkity.com (wonkity.com [67.158.26.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 162461AAE; Sat, 15 Feb 2014 21:27:18 +0000 (UTC) Received: from wonkity.com (localhost [127.0.0.1]) by wonkity.com (8.14.8/8.14.8) with ESMTP id s1FLRFFj046241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 15 Feb 2014 14:27:16 -0700 (MST) (envelope-from wblock@wonkity.com) Received: from localhost (wblock@localhost) by wonkity.com (8.14.8/8.14.8/Submit) with ESMTP id s1FLRF2I046238; Sat, 15 Feb 2014 14:27:15 -0700 (MST) (envelope-from wblock@wonkity.com) Date: Sat, 15 Feb 2014 14:27:15 -0700 (MST) From: Warren Block To: Marcel Moolenaar Subject: Re: Allowing arbitrary MBR slice alignment In-Reply-To: <29DD155A-790F-4D28-8FFF-FED5466BC336@xcllnt.net> Message-ID: References: <29DD155A-790F-4D28-8FFF-FED5466BC336@xcllnt.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (wonkity.com [127.0.0.1]); Sat, 15 Feb 2014 14:27:16 -0700 (MST) Cc: "Andrey V. Elsukov" , Marcel Moolenaar , freebsd-geom@FreeBSD.org X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2014 21:27:19 -0000 On Sat, 15 Feb 2014, Marcel Moolenaar wrote: > On Feb 14, 2014, at 8:24 AM, Warren Block wrote: > >> The Problem >> >> More and more disk devices have native 4K blocks. The ability to align MBR slices to arbitrary values is consequently becoming more important. Misaligned filesystems might read or write at less than half the speed of aligned filesystems on the same disk. >> >> Microsoft recognized this problem, and at least since the release of Vista in 2007, MBR-formatted disks created by Microsoft operating systems have started the first or main filesystem slice at block 2048 (1M). Despite the official standard for MBR alignment to CHS values, this second non-CHS but 4K-aligned de facto standard has become extremely common. > > Aligning to 4K *and* CHS is possible. If there are 63 sectors > per track, then a 4K aligned partition that starts at a track > boundary starts in track 8 (LBA 504). Sure, 4K * 63. But that only works if the user is not concerned about precise location or size of slices. It's okay if dealing with FreeBSD, but restricts interoperability with MBRs created on or for use with other systems. > Are you absolutely sure that 4K alignment resulted in non-CHS > alignment? gpart has never managed to create a slice starting at block 2048 for me, either with -a4k or -b2048 or both. It always becomes block 2079, the next multiple of 63. In effect, the value of -a is forced to 63 when creating MBR slices, even when the user asks for something else. Block 2079 is one block short of being 4K-aligned. >> When MBR slices are created with gpart(8) on FreeBSD, their starting block and size are silently rounded to multiples of CHS values. This happens even when specific values for -a (alignment) or -b (starting block) are given. This silent rounding violates POLA. > > That's argumentative. Sorry, not intentional. Arguable? Using '-a4k -b1m' and getting '-a63 -b2079' was pretty surprising the first time I saw it. "Astonishing" is not too strong a word. :) >> At present, the only way to create an MBR with 4K-aligned slices on FreeBSD is with fdisk(8), a legacy tool. > > False. With some math, you can do the same thing with gpart. You're right, the wording was imprecise. How about: At present, the only way to create MBR slices with arbitrary 4K-aligned starting positions and sizes is with fdisk(8), a legacy tool. > What is missing is good behaviour when -a 4K is specified. Yes, keeping in mind that other systems with which FreeBSD must interact operate under different alignment rules, or no rules at all. >> Suggested Solution >> >> gpart(8) should be allowed to override the CHS rounding with -a and -b values when creating MBR slices. If CHS rounding occurs when the options are not given, gpart(8) should give a warning that default values were used to avoid surprising the user. >> >> The warning is really secondary. Primarily and pragmatically, gpart(8) needs the ability to create MBR slices with arbitrary alignment so FreeBSD can deal gracefully with modern storage hardware. >> > > There are alternatives to consider: > 1. Don't change anything > 2. Align to both CHS and the specified alignment (-a). > 3. Add an option to allow precise control over the behaviour > and thus avoid causing POLA violations when the MBR scheme > suddenly behaves differently and creates incompatible > slices. #2 is only a partial solution. If an original MBR is not CHS-aligned, 'gpart recover' would still create a new MBR that differs. And it would not be possible to create a partition at a non-CHS-aligned location. Is #3 what I suggested, or another method? Thanks!