Commit Graph

48 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
deb35287b3 Fix offset calculation to actually rewrite the _last_ block. 2012-05-06 11:48:37 +00:00
Edward Tomasz Napierala
e35497f13b Improve growfs(8) in a few ways; unfortunately, it's somewhat hard to untangle
them and commit separately.

1. Rewrite the way growfs(8) finds the device and mount point.  This makes
   it possible to use e.g. "growfs /mnt"; it's also used to display more
   helpful messages.

2. Be more user-friendly, using descriptive messages, like this:

   OK to grow filesystem on /dev/md0, mounted on /mnt, from 9.8GB to 20GB? [Yes/No]"

3. Allow to specify the size (-s option) just like with mdconfig(8), i.e. with
   postfixes ("mdconfig -s 10g").

4. Reload read-only filesystem after growing.

Reviewed by:	kib, mckusick (earlier version)
Sponsored by:	The FreeBSD Foundation
2012-04-30 16:08:02 +00:00
Edward Tomasz Napierala
91ac147931 Style. 2012-04-18 13:50:17 +00:00
Edward Tomasz Napierala
f979d8ac99 Style. 2012-04-15 15:15:16 +00:00
Edward Tomasz Napierala
b408e19c58 Remove FSIRAND and FSMAXSWAP ifdefs, removing code unconditionally.
Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
2012-04-15 15:13:29 +00:00
Edward Tomasz Napierala
6ad07d53c2 Style. 2012-04-12 16:55:48 +00:00
Edward Tomasz Napierala
9f2d8a3834 Remove block reallocation used to make room for the cylinder group
summary structure.  From now on, when there is no room for it,
we simply allocate new one in a newly added cylinder group.

This patch removes a conditional in updcsloc(), reindents some code
there, and removes unused routines.  I decided to do it this way instead
of disabling reallocation when the filesystem is live and leaving it
as it is otherwise, because this allows for removal of lots of complicated
and hard to test code.  Also, conditionally disabling it would result
in a different layout in filesystems resized online and offline, which
would look somewhat weird.

Reviewed by:		mckusick
No objections from:	kib
Sponsored by:		The FreeBSD Foundation
2012-04-12 13:43:43 +00:00
Edward Tomasz Napierala
50c603c4ec Remove disklabel handling code from growfs. This should be done
via geom_part(4), and it doesn't belong in growfs anyway.

Reviewed by:	kib, mckusick
Sponsored by:	The FreeBSD Foundation
2012-03-29 11:20:19 +00:00
Dimitry Andric
8f061f61db After r232548, clang complains about the apparent '=-' operator (a
left-over from ancient C times, and a frequent typo) in growfs.c:

sbin/growfs/growfs.c:1550:8: error: use of unary operator that may be intended as compound assignment (-=) [-Werror]
        blkno =- 1;
              ^~

Use 'blkno = -1' instead, to silence the error.
2012-03-12 11:15:44 +00:00
Edward Tomasz Napierala
a1da07403e Make growfs(8) mostly style compliant. No functional changes,
verified with MD5.
2012-03-05 16:37:51 +00:00
Ed Schouten
11dc480601 Allow growfs to be built with GCC 4.7 and -Werror.
The dp1 variable is only used when FSIRAND is defined. Just place the
variable behind #ifdefs entirely.
2012-01-17 22:19:35 +00:00
Ed Schouten
1efe3c6b58 Add missing static keywords for global variables to tools in sbin/.
These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.
2011-11-04 13:36:02 +00:00
Edward Tomasz Napierala
8857bdbc59 Revert the mechanical change from 'file system' to 'filesystem', committed
in r223429.  As bde@ pointed out, it was mostly backwards.
2011-06-28 19:59:46 +00:00
Edward Tomasz Napierala
b2168df843 Cosmetic fixes; mostly s/file system/filesystem/g and removing weird indent
from messages.
2011-06-22 17:59:53 +00:00
Rebecca Cran
974206cf70 Fix typos - remove duplicate "is".
PR:		docs/154934
Submitted by:	Eitan Adler <lists at eitanadler.com>
MFC after:	3 days
2011-02-23 09:22:33 +00:00
Marcel Moolenaar
ea6de5ee49 s/utime/modtime/g -- utime shadows utime(3).
Submitted by:	Garrett Cooper
2011-01-22 21:27:17 +00:00
Marcel Moolenaar
e29560acd7 Unbreak the build on strong-aligned architectures (arm, ia64).
Casting from (char *) to (struct ufs1_dinode *) changes the
alignment requirement of the pointer and GCC does not know that
the pointer is adequately aligned (due to malloc(3)), and warns
about it. Cast to (void *) first to by-pass the check.
2010-09-20 04:20:55 +00:00
Brian Somers
1ad5f80fac Revise r197763 which fixes filesystem corruption when extending
into un-zeroed storage.

The original patch was questioned by Kirk as it forces the filesystem
to do excessive work initialising inodes on first use, and was never
MFC'd.  This change mimics the newfs(8) approach of zeroing two
blocks of inodes for each new cylinder group.

Reviewed by:	mckusick
MFC after:	3 weeks
2010-09-19 08:18:56 +00:00
Gavin Atkinson
08f353ebe3 When growing a UFS1 filesystem, we need to initialise all inodes in any new
cylinder groups that are created.  When the filesystem is first created,
newfs always initialises the first two blocks of inodes, and then in the
UFS1 case will also initialise the remaining inode blocks.  The changes in
growfs.c 1.23 broke the initialisation of all inodes, seemingly based on
this implementation detail in newfs(8).  The result was that instead of
initialising all inodes, we would actually end up initialising all but the
first two blocks of inodes.  If the filesystem was grown into empty
(all-zeros) space then the resulting filesystem was fine, however when
grown onto non-zeroed space the filesystem produced would appear to have
massive corruption on the first fsck after growing.
A test case for this problem can be found in the PR audit trail.

Fix this by once again initialising all inodes in the UFS1 case.

PR:		bin/115174
Submitted by:	Nate Eldredgei  nge cs.hmc.edu
Reviewed by:	mjacob
MFC after:	1 month
2010-02-13 16:22:08 +00:00
Kirk McKusick
14a176a0e2 Quiet spurious warnings. 2010-02-11 06:42:08 +00:00
Gavin Atkinson
eb747250e6 Remove dead code. This section of code is only run in the
(sblock.fs_magic == FS_UFS1_MAGIC) case, so the check within the
loop is redundant.

Submitted by:	Nate Eldredge  nge cs.hmc.edu
Reviewed by:	mjacob
Approved by:	ed (mentor)
MFC after:	1 month
2010-01-02 20:18:10 +00:00
Matt Jacob
4bdcc9c7d7 The cylinder group tag cg_initediblk needs to match the number of inodes
actually initialized. In the growfs case for UFS2, no inodes were actually
being initialized and the number of inodes noted as initialized was the
number of inodes per group. This created a filesystem that was deemed
corrupted because the inodes thus added were full of garbage.

MFC after:	1 month
2009-10-05 01:31:16 +00:00
David Schultz
baa15be0ea Fix an int overflow on very large file systems.
PR:		bin/113399
Submitted by:	Staffan Ulfberg <staffan@ulfberg.se>
2007-12-17 08:03:18 +00:00
Stefan Farfeleder
42e355872b Remove duplicated assignment. 2006-07-17 20:48:36 +00:00
Philippe Charnier
e3ec673e97 Remove \n at the end of err(3) strings 2005-01-16 14:37:30 +00:00
Scott Long
e7c4605481 3 important fixes for growfs:
1) ginode() is passed a cylinder group number and inode number.  The inode
number is relative to the cg.  Use this relative number rather than the
absolute inode number when searching the cg inode bitmap to see if the inode
is allocated.  Using the absolute number quickly runs the check off the end
of the array and causes invalid inodes to be referenced.

2) ginode() checks the absolute indoe number to make sure that it is greater
than ROOTINO.  However, the caller loops through all of the possible inode
numbers and directly passes in values that are < ROOTINO.  Instead of halting
the program with an error, just return NULL.

3) When allocating new cylinder groups, growfs was initializing all of the
inodes in the group regardless of this only being required for UFS1.  Not
doing this for UFS2 provides a significant performance increase.

These fixes allow growing a filesystem beyond a trivial amount and have
been tested to grow an 8GB filesystem to 1.9TB.  Much more testing would
be appreciated.

Obtained from: Sandvine, Inc.
2004-10-09 02:53:47 +00:00
Lukas Ertl
691ae40438 Catch up with recent gcc changes and introduce a DIP_SET macro
to use when setting values that depend on the UFS version.
Raise WARNS again.
2004-07-29 11:28:24 +00:00
Bruce Evans
35cf80de36 Include <time.h> instead of depending on namespace pollution in <sys/stat.h>
for the declaration of time().
2004-04-04 04:17:07 +00:00
Maxime Henrion
b1fddb236f Fix the remaining warnings of growfs(8) on my sparc64 box with
WARNS=6.  I don't change the WARNS level in the Makefile because I
didn't tested this on other archs.

The fs.h fix was suggested by:	marcel
Reviewed by:	md5(1)
2004-04-03 23:30:59 +00:00
Maxime Henrion
760ea1fa63 - Don't abuse caddr_t when what we really want is a void *.
- Use the %jd format and a cast to intmax_t to print an int64_t.
- The return type of getopt() is an int, not a char.

This fixes some warnings but there's still much more work to do here.
2004-04-03 22:56:54 +00:00
Lukas Ertl
75d1ec91df Make growfs WARNS=6 clean.
Approved by:	grog (mentor)
2004-04-03 17:40:19 +00:00
Lukas Ertl
f055f9f2b2 Don't read an inode which isn't used to avoid problems on UFS2 where not
all inodes are initialized when running newfs.

Approved by:    grog (mentor)
2004-03-26 23:42:32 +00:00
Tom Rhodes
654c287479 Remove a few unused variables. 2003-10-30 05:43:56 +00:00
Greg Lehey
4b9748d477 Understand GEOM. This makes growfs work again, but it really needs rewriting.
Submitted by: 	Lukas Ertl <l.ertl@univie.ac.at>
Approved by:	re (scottl)
2003-05-12 05:37:16 +00:00
Jens Schweikhardt
6ded053322 Fix typos in comments; some style(9) fixes; no code changes.
PR:	misc/50979
Submitted by:	Lukas Ertl <l.ertl@univie.ac.at>
2003-04-26 15:22:29 +00:00
Jens Schweikhardt
d64ada501a Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.
2002-12-30 21:18:15 +00:00
Kirk McKusick
ada981b228 Create a new 32-bit fs_flags word in the superblock. Add code to move
the old 8-bit fs_old_flags to the new location the first time that the
filesystem is mounted by a new kernel. One of the unused flags in
fs_old_flags is used to indicate that the flags have been moved.
Leave the fs_old_flags word intact so that it will work properly if
used on an old kernel.

Change the fs_sblockloc superblock location field to be in units
of bytes instead of in units of filesystem fragments. The old units
did not work properly when the fragment size exceeeded the superblock
size (8192). Update old fs_sblockloc values at the same time that
the flags are moved.

Suggested by:	BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk>
Sponsored by:   DARPA & NAI Labs.
2002-11-27 02:18:58 +00:00
Mike Barcroft
89fdc4e117 Use the standardized CHAR_BIT constant instead of NBBY in userland. 2002-09-25 04:06:37 +00:00
Tom Rhodes
ce66ddb763 s/filesystem/file system/g as discussed on -developers 2002-08-21 18:11:48 +00:00
Kirk McKusick
1c85e6a35d This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by:	Poul-Henning Kamp <phk@freebsd.org>
2002-06-21 06:18:05 +00:00
Tom Rhodes
3468b317cb more file system > filesystem 2002-05-16 04:10:46 +00:00
David E. O'Brien
3d438ad61f Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
 "register" -- just how many free registers do people think machines have?)
2002-03-20 17:55:10 +00:00
Ruslan Ermilov
8af1452cf8 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
Christoph Herrmann
5455cc1ae9 fixing a bug in test mode (growfs -N)
Submitted by: 	Chris Boltwood <chris@hiendmedia.com>
Reviewed by:	tomsoft
MFC after:	5 days
2001-08-08 21:45:42 +00:00
Thomas-Henning von Kamptz
adcaff07f8 cleanup to get rid of most warnings on alpha
and yes now it also works on alpha

Reviewed by:	chm
MFC after:	3 weeks
2001-06-07 20:43:00 +00:00
Thomas-Henning von Kamptz
25e3465064 fix a bug of a only partitally initialization which could result
in an unclean filesystem after growing by a large amount of cylinder
groups

Reviewed by:	chm
2001-06-05 18:39:57 +00:00
Thomas-Henning von Kamptz
4020c5bc54 corrected spelling mistakes in comments
check a couple of mallocs
usage of errx
linebreaks of DBG_ macros,
correcting the usage of nroff macros

Submitted by:	grog, charnier
Reviewed by:	chm
2000-12-12 20:03:17 +00:00
Thomas-Henning von Kamptz
3d5000784d added growfs(8) including ffsinfo(8) to the freebsd base system
Reviewed by:	 grog
2000-12-09 15:27:35 +00:00