git: sbin/newfs_hammer: Fail with "less than 10GB" without formatting half way through
Tomohiro Kusumi
tkusumi at crater.dragonflybsd.org
Tue Jun 16 10:49:05 PDT 2015
commit 92d0a1c8c4617bf28a52a7086aefeb03ff638ad4
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date: Tue Jun 16 04:55:01 2015 +0900
sbin/newfs_hammer: Fail with "less than 10GB" without formatting half way through
- This commit enables newfs_hammer to fail with "less than 10GB"
error without formatting half way through, by using a new function
count_freemap() which only counts potentially available bigblocks
with no ondisk modification to layer1/2 bigblocks.
- It's simply better to fail with a sanity check without messing
up disks whenever users have invalid inputs (which in this case
is users specifying not large enough volumes). The formatting
should start only after all sanity checks are done.
- Example1 - using existing /sbin/newfs_hammer
# dd if=/dev/zero of=/dev/da9 bs=8M count=10 >/dev/null 2>&1; sync
*** unplug /dev/da9 -> plug /dev/da9
# dd if=/dev/da9 of=/tmp/out1 bs=8M count=10 >/dev/null 2>&1; sync
# /sbin/newfs_hammer -L TEST /dev/da9; sync
Volume 0 DEVICE /dev/da9 size 7.22GB
initialize freemap volume 0
newfs_hammer: Cannot create a HAMMER filesystem less than 10GB unless you use -f
(for the size of Volume 0). HAMMER filesystems less than 50GB are not recommended.
*** unplug /dev/da9 -> plug /dev/da9
# dd if=/dev/da9 of=/tmp/out2 bs=8M count=10 >/dev/null 2>&1; sync
# cmp /tmp/out1 /tmp/out2
/tmp/out1 /tmp/out2 differ: char 35913737, line 1
# od -tx1 -Ad -N 838860800 /tmp/out1
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
83886080
# od -tx1 -Ad -N 838860800 /tmp/out2 | head -10
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
35913728 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff
35913744 00 00 00 00 00 00 00 00 00 00 00 00 31 a7 1e 63
35913760 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff
35913776 00 00 00 00 00 00 00 00 00 00 00 00 31 a7 1e 63
35913792 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff
35913808 00 00 00 00 00 00 00 00 00 00 00 00 31 a7 1e 63
35913824 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff
-----layer1.blocks_free=0----- --layer1.phys_offset=UNAVAIL--
35913840 00 00 00 00 00 00 00 00 00 00 00 00 31 a7 1e 63
-----layer1.reserved---------- --layer2.crc-- --layer1.crc--
(see sbin/hammer/ondisk.c:format_freemap())
# /sbin/mount_hammer /dev/da9 /mnt
/dev/da9: Not a valid HAMMER filesystem
mount_hammer: mount /dev/da9 on /mnt: Inappropriate file type or format
(it's only half way through done, so the device isn't mountable yet,
but the layer1/2 structure still does overwrite the original content)
- Example2 - using this commit
# dd if=/dev/zero of=/dev/da9 bs=8M count=10 >/dev/null 2>&1; sync
*** unplug /dev/da9 -> plug /dev/da9
# dd if=/dev/da9 of=/tmp/out1 bs=8M count=10 >/dev/null 2>&1; sync
# /sbin/newfs_hammer -L TEST /dev/da9; sync
Volume 0 DEVICE /dev/da9 size 7.22GB
newfs_hammer: Cannot create a HAMMER filesystem less than 10GB unless you use -f
(for the size of Volume 0). HAMMER filesystems less than 50GB are not recommended.
*** unplug /dev/da9 -> plug /dev/da9
# dd if=/dev/da9 of=/tmp/out2 bs=8M count=10 >/dev/null 2>&1; sync
# cmp /tmp/out1 /tmp/out2
#
Summary of changes:
sbin/hammer/hammer_util.h | 1 +
sbin/hammer/ondisk.c | 38 ++++++++++++++++++++++++++++++++++++++
sbin/newfs_hammer/newfs_hammer.c | 20 +++++++++++---------
3 files changed, 50 insertions(+), 9 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/92d0a1c8c4617bf28a52a7086aefeb03ff638ad4
--
DragonFly BSD source repository
More information about the Commits
mailing list