Broken gmirror: why /dev/ufs is empty when geom_mirror is not loaded?

Ivan Voras ivoras at freebsd.org
Tue Jan 18 17:14:25 UTC 2011


On 17 January 2011 15:09, Lev Serebryakov <lev at serebryakov.spb.ru> wrote:

>   Let imagine /dev/ad0s1a and /dev/ad1s1a both have, say, 1024
>  sectors. They are mirrored as "mirror/rootfs". It should have size
>  1023 sectors, am I right? 1 sector is spent on metadata and can not be
>  accessed via /dev/mirror/gm0.
>
>   UFS2 is created on /dev/mirror/gm0, with volume label "rootfs"
>  so it records file system size as "1023 sectors", Ok?

Well... it depends. As I see it, the UFS file system size is
calculated based on block size, so the actual size would not be 1024,
but 1024-32 or something like that, which brings me to the next
point...

>   When geom_mirror is loaded and "win" tasting of ad?s1a, geom_label
>  reads label from /dev/mirror/gm0 and shows proper
>  "/dev/ufs/rootfs" and "/dev/ufsid/whatever" with proper sizes "1023
>  sectors".
>
>   When geom_mirror is not loaded, but geom_label is, now it will not
>  show "/dev/ufs/rootfs" because ad?s1a.size != rootf.size, am I right?
>
>   If change geom_label to create labels in such cases (simply remove
>  sizes check in current code), there will be problem with geom_mirror
>  loaded AFTER geom_label -- it could pickup mirror component via
>  label, not via device itself.
>
>   But if we remove this check AND change geom_label in such way, as
>  it will create provider based on UFS size (not underlying provider
>  size), it will work always. When there is no geom_mirror labels will
>  be created but it will be impossible to pickup such label as
>  component of mirror, because label-provider will not contain mirror
>  metadata.

I don't think this is a general enough solution. Other file systems
than UFS may not record file system size at all, or maybe record it
even more inprecisely than UFS. Additionally, glabel would have to be
restructured a bit to support that.

>   And there is one more problem: it is almost always possible to
>  create mirror AFTER file system (add mirror to existing installation
>  without re-creating FSes), but it will have incorrect FS size in
>  metadata and here is no way to "shrink" FS even with one sector. And,
>  yes, it such case current geom_label implementation will create
>  labels from mirror components (size check will be passed), and allows
>  geom_mirror to use labels as components. Complete mess :( And
>  creation mirror on live system looks like useful feature.

I think this would be solved by my other proposal :)


More information about the freebsd-geom mailing list