Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2013 21:25:50 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-fs@freebsd.org, Andreas Longwitz <longwitz@incore.de>
Subject:   Re: g_journal_ufs_using_last_sector() needs minor correction (patch included)
Message-ID:  <20130105202550.GE1390@garage.freebsd.pl>
In-Reply-To: <20130105180304.GT82219@kib.kiev.ua>
References:  <50E4AF9C.9060404@incore.de> <20130105180304.GT82219@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--IdQYvU5iz1n5pUC3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Jan 05, 2013 at 08:03:04PM +0200, Konstantin Belousov wrote:
> On Wed, Jan 02, 2013 at 11:07:24PM +0100, Andreas Longwitz wrote:
> > On a testdisk created with
> >=20
> >   dd if=3D/dev/zero of=3Ddiskfile count=3D5000 bs=3D1m
> >   mdconfig -a -t vnode -f diskfile -u 1
> >=20
> > let us create a mirrored and gjournaled filesystem:
> >=20
> > gmirror label -b prefer -F gmX md1
> > gpart create -s GPT mirror/gmX
> > gpart add -t freebsd-swap -s 4194304 -i 1 mirror/gmX
> > gpart add -t freebsd-ufs -i 2 mirror/gmX
> > gjournal label mirror/gmXp2 mirror/gmXp1
> > newfs -J /dev/mirror/gmXp2.journal
> > mount /dev/mirror/gmXp2.journal /mnt
> > ...  put some data to /mnt
> > umount /mnt
> >=20
> > The mediasizes in sectors for gjournal consumer and provider:
> >=20
> > diskinfo /dev/mirror/gmXp2.journal -->
> > /dev/mirror/gmXp2.journal     512     3095361024      6045627 0    0
> >=20
> > dumpfs -m /dev/mirror/gmXp2.journal -->
> > # newfs command for /dev/mirror/gmXp2.journal
> > newfs -O 2 -J -a 8 -b 16384 -d 16384 -e 2048 -f 2048 -g 16384 -h 64
> > -m 8 -o time -s 6045624 /dev/mirror/gmXp2.journal
> >=20
> > The size of the created filesystem is 6045624 and three blocks less than
> > the size gjournal provides.
> >=20
> > Now I had the need to rename gmX to gmY without loosing my data:
> >=20
> > gjournal stop mirror/gmXp2.journal
> > gjournal clear mirror/gmXp2
> > gjournal clear mirror/gmXp1
> > gpart delete -i 1 mirror/gmX
> > gpart delete -i 2 mirror/gmX
> > gpart destroy mirror/gmX
> > gmirror stop gmX
> > gmirror clear /dev/md1
> > gmirror label -b prefer -F gmY md1
> > gpart create -s GPT mirror/gmY
> > gpart add -t freebsd-swap -s 4194304 -i 1 mirror/gmY
> > gpart add -t freebsd-ufs -i 2 mirror/gmY
> > gjournal label mirror/gmYp2 mirror/gmYp1
> >=20
> > At this point gjournal gives the unjustified error message
> > "File system on mirror/gmYp2 is using the last
> > sector and this operation is going to overwrite
> > it. Use -f if you really want to do it."
> >=20
> > the reason for this is an improper size check in the function
> > g_journal_ufs_using_last_sector() which can be corrected by the
> > following patch:
> >=20
> > --- geom_journal_ufs.c.orig     2009-08-03 10:13:06.000000000 +0200
> > +++ geom_journal_ufs.c  2013-01-02 23:01:37.000000000 +0100
> > @@ -73,6 +73,6 @@
> >         /* Provider size in 512 bytes blocks. */
> >         psize =3D g_get_mediasize(prov) / DEV_BSIZE;
> >         /* File system size in 512 bytes blocks. */
> > -       fssize =3D fsbtodb(fs, dbtofsb(fs, psize));
> > -       return (psize =3D=3D fssize);
> > +       fssize =3D fsbtodb(fs, fs->fs_size);
> > +       return (psize <=3D fssize);
> >  }
>=20
> I agree with your analysis, the patch looks right.
> Existing code rounded the filesystem size up to the fragment size,
> which is typically 8 disk blocks. But, in fact, only the last disk
> block matters.
>=20
> Pawel, do you have any comments ?

No, patch looks good to me.

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl

--IdQYvU5iz1n5pUC3
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iEYEARECAAYFAlDojE4ACgkQForvXbEpPzSINACgk6KfQRfeuNzSQzH7tYKlhlMZ
gjYAn0WgSeytjLMwJAjYNIbOF/1G/OoE
=T6Yv
-----END PGP SIGNATURE-----

--IdQYvU5iz1n5pUC3--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130105202550.GE1390>