Allowing arbitrary MBR slice alignment

Marcel Moolenaar marcel at xcllnt.net
Mon Feb 17 19:08:39 UTC 2014


On Feb 17, 2014, at 9:40 AM, Warren Block <wblock at wonkity.com> wrote:
> 
>>>> 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.
>> 
>> The problem with recovery of a scheme that has ill-defined
>> characteristics is that you'll have to make guesses and you
>> can never guarantee that the recovered partition is identical
>> to the original.
>> 
>> One can argue that recovery without redundancy is something
>> that should not even be attempted.
> 
> Sorry, s/recover/restore/.  Let me try again:
> 'gpart restore' should recreate the partitioning as shown in the input,
> or give an error if it is not possible.  Either of these is preferable
> to creating partitioning which has been silently adjusted.

Agreed.

> 
>>> Is #3 what I suggested, or another method?
>> 
>> I would expect that if the MBR scheme forces CHS alignment,
>> that -a 4K would result in alignment for both. This is not
>> the same as a specific option that tells the MBR scheme to
>> not align to CHS at all. This would be a clear indication
>> that 1) the user/operator takes responsibility for the end
>> result and 2) that a change in default behaviour is asked
>> for.
>> 
>> gpart does allow for that with the -f option. It's for
>> passing operational flags.
>> 
>> For example ``gpart add -t freebsd -a 4K -f A ${dev}''
>> could be used to tell gpart that that alignment is to be
>> taken from the user without enforcing other alignment.
> 
> That would be better than the current situation, although the second flag ends up saying "and this time, really do what I said to do".
> 
> When the user supplies -a or -b values, I suggest it implicitly means "...and override any default assumptions".  The current behavior could be retained by supplying -a63, although admittedly that might not work all the time.  Maybe a special value of '-a chs'?  Or actually, just the default when -a or -b are not supplied.

This is where things get tricky...

First there's architecture and layering. The whole point gpart
is to abstract the details of the actual implementation and
present is simple, be it low-level, and common user interface.
Things like '-a chs' are meaningless to non-MBR schemes and as
such become warts in the interface and usage. That's ugly.

It's for this reason that gpart uses aliases for partition
types and not the "raw" and scheme-specific encoding. It is
still possible to use the scheme-specific encoding, but it's
done in a way that makes it clear that the interpretation of
the partition type is scheme-specific.

Any scheme implementation can impose whatever is necessary to
create a valid partitioning. For MBR this means that partitions
are always aligned to CHS. In combination with "-a 4K" is would
assume that this means both CHS *and* 4K alignment because the
user may not be aware (and should not have to worry) about any
implied alignment or rounding. Having "-a 4K" imply that the
scheme implementation is to trust that the user knows what she
is doing and knows about scheme-specific constraints is counter
to the design and in practice absolutely false. It's for this
reason that it's better to introduce a special flag (just like
the common "force" flag) that serves as the unambiguous signal
that the user takes full responsibility for the results.

I don't think therefore that a special flag will say "and this
time do what I say". It'll will say "Set the usage mode from
'cooked', to 'raw' and take everything I say literally". That's
a good way to keep both sides of the interface from having to
guess.

In short: Don't revert the design and intent of gpart. Let it
be the common interface to all partitioning schemes. This means
that you want be be able to say "-a 4K" or "-b 2000" without
regard for the scheme and know that the scheme will round or
adjust accordingly. The gpart utility will lose its power if
that is being meddled with, because it's power comes from the
fact that you do not have to know the particulars of the scheme
in use, nor even the scheme being used in order to work with it.
This is key in having it be scriptable.

You want a way to let gpart (and the kernel) know that you are
aware of the scheme and are going to do things that should not
be interpreted as coming from behind a "veil of ignorance" so
to speak.

-- 
Marcel Moolenaar
marcel at xcllnt.net


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-geom/attachments/20140217/3b7e6ce4/attachment.sig>


More information about the freebsd-geom mailing list