Date: Sat, 5 Jan 2013 20:03:04 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Andreas Longwitz <longwitz@incore.de> Cc: freebsd-fs@freebsd.org Subject: Re: g_journal_ufs_using_last_sector() needs minor correction (patch included) Message-ID: <20130105180304.GT82219@kib.kiev.ua> In-Reply-To: <50E4AF9C.9060404@incore.de> References: <50E4AF9C.9060404@incore.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--d3DVaulSu5qtnQB/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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); > } 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. Pawel, do you have any comments ? --d3DVaulSu5qtnQB/ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJQ6GrYAAoJEJDCuSvBvK1BSD4P+QF8SHo1K3uu2JFheR6qL506 qhInGQtsX8YCVFjOqDCAfujg8DwSHGX8l04dOcPc60bCZbX0cHHqMNR8eecPVKFE FX4/JTWvqdAmU0bwFrGSm+IoL/aEgGs8uo6oFs1r4IUAejYE+1GSAWpO06GlO8Cg ieOaXO5aHe4j42CVBPDeBkgo3aWB8iUxChQOcw6VDwTPFITYlOQ0KwOpkHwVoIPy 1rQMp5NZENCKmJz1kU9I8Ikf0pEvIUB9y8cXRiFuP1booe5lEL9cC/kvin+V0IAC ZXg7jW8sMfk0K742E21kQaHSrrLBWbIxuqDbLjgPsg6Eqxui4r+lzEnlMGgdUu4c XnE1JgMkzXE50oyYTw8uEbTN5N+PoWUkjOkTSpa8CMQgKMGVRCF64hbj0xt26jSE a9IjsZF492adwOyJhtLfNpXh6BvXDJGC1HG+pcbUQOz1IrZ+Qjd+gwfLN85a1jBY 8f6MP7T54qsuXW1JqmwcB/D6mIblqd+tT4oXVQJoZ7UA/cHHVPUIpRvNUdd7bglc /jhEa+1mJvhkTUeF7avTbi7ypYoQp3Bg4FX0EiiOdDTSh+QhUTUD6KLCFEZ1bogz j5rw2hLmTG2FfCS9jNGVRz0jrix69RrscUJ5p/cvCnkEtP20xslTuBBKHAOGyv3J +OANjv5kyn7FUK7kKXGK =zOtl -----END PGP SIGNATURE----- --d3DVaulSu5qtnQB/--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130105180304.GT82219>