summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/fsutil.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid segment fault when attempting to clean up cylinder groupmckusick2014-03-121-6/+8
| | | | | | | | | buffer cache. PR: 187221 Submitted by: Petr Lampa <lampa@fit.vutbr.cz> Obtained from: Petr Lampa <lampa@fit.vutbr.cz> MFC after: 1 week
* Arguments for malloc and calloc should be size_t, not int.mckusick2014-02-251-1/+3
| | | | | | | | Use proper bounds check when trying to free cached memory. Spotted by: Xin Li Tested by: Dmitry Sivachenko MFC after: 2 weeks
* Add the -R option to allow fsck_ffs to restart itself when too many criticalscottl2013-12-301-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | errors have been detected in a particular run. Clean up the global state variables so that a restart can happen correctly. Separate the global variables in fsck_ffs and fsdb to their own file. This fixes header sharing with fscd. Correctly initialize, static-ize, and remove global variables as needed in dir.c. This fixes a problem with lost+found directories that was causing a segfault. Correctly initialize, static-ize, and remove global variables as needed in suj.c. Initialize the suj globals before allocating the disk object, not after. Also ensure that 'preen' mode doesn't conflict with 'restart' mode Submitted by: scottl, max Reviewed by: max, mckusick (earlier version) Obtained from: Netflix MFC after: 3 days
* Fix the zeroing loop. I must have been drunk when I wrote this...des2013-08-201-6/+6
| | | | MFC after: 3 days
* Add a 'surrender' mode to fsck_ffs. With the -S flag, once hard read errorsscottl2013-07-301-1/+12
| | | | | | | | are encountered, the fsck will stop instead of wasting time chewing through possibly other errors. Obtained from: Netflix MFC after: 3 days
* Add a -Z option which zeroes unused blocks. It can be combined with -E,des2013-04-291-0/+29
| | | | | | | in which case unused blocks are first zeroed and then erased. Reviewed by: mckusick MFC after: 3 weeks
* Note that output is in seconds, not msec.mckusick2013-03-241-2/+3
| | | | | | | | | KNF indentation. No functional change. No change to printf strings. No change to casting of printf arguments. Reported by: Bruce Evans
* Resolve clang compile errors on amd64/i386 for certain by casting.sbruno2013-03-241-4/+4
| | | | | | | compile tested with clang on i386, amd64 compile tested with gcc on i386, amd64, sparc64 Submitted by: delphij
* Minor formatting fix for printf() to fix clang builds.sbruno2013-03-241-2/+2
| | | | | Submitted by: db Reviewed by: gjb
* Revert 248634 and 248643 (e.g., restoring 248625 and 248639).mckusick2013-03-231-13/+76
| | | | Build verified by: Glen Barber (gjb@)
* Revert svn r248625sbruno2013-03-231-76/+13
| | | | | | | | Clang errors around printf could be trivially fixed, but the breakage in sbin/fsdb were to significant for this type of change. Submitter of this changeset has been notified and hopefully this can be restored soon.
* Speed up fsck by caching the cylinder group maps in pass1 somckusick2013-03-221-13/+76
| | | | | | | | | | | | | | | | | | | | that they do not need to be read again in pass5. As this nearly doubles the memory requirement for fsck, the cache is thrown away if other memory needs in fsck would otherwise fail. Thus, the memory footprint of fsck remains unchanged in memory constrained environments. This work was inspired by a paper presented at Usenix's FAST '13: www.usenix.org/conference/fast13/ffsck-fast-file-system-checker Details of this implementation appears in the April 2013 of ;login: www.usenix.org/publications/login/april-2013-volume-38-number-2. A copy of the April 2013 ;login: paper can also be downloaded from: www.mckusick.com/publications/faster_fsck.pdf. Reviewed by: kib Tested by: Peter Holm MFC after: 4 weeks
* Fix ARM build by assigning the computed time here tokientzle2013-02-251-2/+2
| | | | a variable of the right type for printf.
* When running with the -d option, instrument fsck_ffs to track the number,mckusick2013-02-241-9/+132
| | | | | | data type, and running time of its I/O operations. No functional changes.
* Update fsck_ffs buffer cache manager to use TAILQ macros.mckusick2013-02-151-24/+21
| | | | No functional changes.
* Fix fsck_ffs build with a 64-bit ino_t.mdf2012-09-271-1/+2
| | | | Original code by: Gleb Kurtsou
* Remove needless (int) casts of write(2)'s 3rd argument.obrien2012-09-121-4/+4
| | | | | Also change blwrite() 'size' parameter to a ssize_t to better match write(2).
* Spelling fixes for sbin/uqs2012-01-071-1/+1
|
* Add an -E option to mirror newfs's. The idea is that if you have a systemdes2011-04-291-1/+16
| | | | | | | | | | | | | | | | | | | that was built before ffs grew support for TRIM, your filesystem will have plenty of free blocks that the flash chip doesn't know are free, so it can't take advantage of them for wear leveling. Once you've upgraded your kernel, you enable TRIM on the filesystem (tunefs -t enable), then run fsck_ffs -E on it before mounting it. I tested this patch by half-filling an mdconfig'ed filesystem image, running fsck_ffs -E on it, then verifying that the contents were not damaged by comparing them to a pristine copy using rsync's checksum functionality. There is no reliable way to test it on real hardware. Many thanks to mckusick@, who provided the tricky parts of this patch and reviewed the final version. Reviewed by: mckusick@ MFC after: 3 weeks
* This corrects a bug that manifested itself as identifying the lastmckusick2010-01-071-1/+1
| | | | | | | | | | cylinder group of a UFS1 filesystem as bad. The error was in the check and not in the cylinder group itself. So even though fsck fixed the cylinder group correctly, it was still endlessly reported as bad. PR: 141992 MFC after: 2 weeks Reported by: Dan Strick
* Update the actions previously attempted by the -D option to make themmckusick2009-02-041-25/+71
| | | | | | | | | | | | | | | | | | robust. With these changes fsck is now able to detect and reliably rebuild corrupted cylinder group maps. The -D option is no longer necessary as it has been replaced by a prompt asking whether the corrupted cylinder group should be rebuilt and doing so when requested. These actions are only offered and taken when running fsck in manual mode. Corrupted cylinder groups found during preen mode cause the fsck to fail. Add the -r option to free up excess unused inodes. Decreasing the number of preallocated inodes reduces the running time of future runs of fsck and frees up space that can allocated to files. The -r option is ignored when running in preen mode. Reviewed by: Xin LI <delphij@> Sponsored by: Rsync.net
* Follow up with previous commit: mention -D, not -C when cg checkdelphij2009-01-271-1/+1
| | | | | | failed. Submitted by: obrien
* Rename option 'C' to 'D' (damaged) in order to avoid a conflict with upcomingdelphij2009-01-201-1/+1
| | | | | | | Juniper 'C' (clean) flag. Requested by: obrien MFC after: 1 week
* Add a new flag, '-C' which enables a special mode that is intended fordelphij2008-04-101-2/+30
| | | | | | | | | | catastrophic recovery. Currently, this mode only validates whether a cylindergroup has good signature data, and prompts the user to decide whether to clear it as a whole. This mode is useful when there is data damage on a disk and you are working on copy of the original disk, as fsck_ffs(8) tends to abnormally exit in such case, as a last resort to recover data from the disk.
* Implements gjournal support. If file system has gjournal support enabledpjd2006-10-311-5/+5
| | | | | | | | | | and -p flag was given perform fast file system checking (bascially only garbage collecting of orphaned objects). Rename bread() to blread() and bwrite() to blwrite() as we now link to the libufs library, which also implement functions with that names. Sponsored by: home.pl
* Eliminate linked list used to track inodes with an initial linktruckman2004-10-081-3/+1
| | | | | | | | | count of zero and instead encode this information in the inode state. Pass 4 performed a linear search of this list for each inode in the file system, which performs poorly if the list is long. Reviewed by: sam & keramida (an earlier version of the patch), mckusick MFC after: 1 month
* Improve the delay algorithm used in bgfsck. From the author:scottl2004-05-181-4/+6
| | | | | | | | | | | | | | | shuffles the timing and sleep calls in bgfsck from: sleep timer_on io timer_off io io io io io io io to sleep io io io io io io io timer_on io timer_off The original method basically guaranteed that the timed I/O included a disk seek every time, which made bgfsck sleep for much longer than necessary. Submitted by: Dan Nelson Reviewed by: kirk
* Remove advertising clause from University of California Regent's license,markm2004-04-091-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core, imp
* Spell "file system" correctly.ru2003-08-011-1/+1
|
* Use __FBSDID() to quiet GCC 3.3 warnings.obrien2003-05-031-4/+4
|
* Slow down the operation of background fsck so as to leave some diskiedowse2002-12-071-1/+46
| | | | | | | | | | | | | | | bandwidth for other processes. Since the sleeping is done from userland, this avoids the locking issues that affected the kernel version. The algorithm used here is to measure a moving average of the times taken by a sample of read operations and then delay 1 in 8 reads by 16 times the measured average. This should correspond to a factor of 3 slowdown, but in practice the factor is larger (3.5 to 4) due to hz rounding effects. Reviewed by: mckusick Approved by: re
* Create a new 32-bit fs_flags word in the superblock. Add code to movemckusick2002-11-271-2/+2
| | | | | | | | | | | | | | | | | 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.
* Clear the pending counts in the superblock after a successful runmckusick2002-10-191-1/+4
| | | | | | | of fsck so that the kernel does not complain about them being non-zero when the filesystem is mounted. Sponsored by: DARPA & NAI Labs.
* s/filesystem/file system/g as discussed on -developerstrhodes2002-08-211-3/+3
|
* Fix a bunch of format string warnings which brokemux2002-07-311-5/+6
| | | | | | the sparc64 build. Tested on: sparc64, i386
* Warning cleanup.phk2002-07-301-14/+14
| | | | Format changes by peter
* This commit adds basic support for the UFS2 filesystem. The UFS2mckusick2002-06-211-13/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* UFS2 preparation commit:phk2002-05-121-2/+2
| | | | | | | Remove support for converting old FFS formats to newer. Submitted by: mckusick Sponspored by: DARPA & NAI Labs.
* Retire the bogus uses of the disklabel field d_sbsize and begin tophk2002-05-121-0/+1
| | | | | | | initialize it to zero so we don't have to have everbody and their aunt including FFS specific header files. Sponsored by: DARPA & NAI Labs.
* Minor bug fixes uncovered while working on UFS2.mckusick2002-05-021-1/+1
| | | | They should have no effect on existing systems.
* o __P removedimp2002-03-201-81/+17
| | | | | | | o ansi function prototypes o unifdef -D__STDC__ o __dead2 on usage prototype o remove now-bogus main prototype
* Remove 'register' keyword.obrien2002-03-201-8/+8
| | | | | | 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?)
* Fix a large number of -Wall, -Wformat and -W compiler warnings.iedowse2001-11-171-15/+2
| | | | | | | | | These were mainly missing casts or wrong format strings in printf statements, but there were also missing includes, unused variables, functions and arguments. The choice of `long' vs `int' still seems almost random in a lot of places though.
* Silence non-constant format string warnings by marking functionskris2001-08-191-1/+1
| | | | | | | as __printflike()/__printf0like(), adding const, or adding missing "%s" format strings, as appropriate. MFC after: 2 weeks
* Add support for the -F flag which determines whether a specifiedmckusick2001-04-241-9/+11
| | | | | | | | | | | | filesystem needs foreground checking (usually at boot time) or can defer to background checking (after the system is up and running). See the manual page, fsck_ffs(8), for details on the -F and -B options. These options are primarily intended for use by the fsck front end. All output is directed to stdout so that the output is coherent when redirected to a file or a pipe. Unify the code with the fsck front end that allows either a device or a mount point to be specified as the argument to be checked.
* Minor background cleanups:mckusick2001-04-161-2/+26
| | | | | | | | | | | 1) Set the FS_NEEDSFSCK flag when unexpected problems are encountered. 2) Clear the FS_NEEDSFSCK flag after a successful foreground cleanup. 3) Refuse to run in background when the FS_NEEDSFSCK flag is set. 4) Avoid taking and removing a snapshot when the filesystem is already clean. 5) Properly implement the force cleaning (-f) flag when in preen mode. Note that you need to have revision 1.21 (date: 2001/04/14 05:26:28) of fs.h installed in <ufs/ffs/fs.h> defining FS_NEEDSFSCK for this to compile.
* Additions to run checks on live filesystems. This change will notmckusick2001-03-211-14/+35
| | | | | | | | | affect current systems until fsck is modified to use these new facilities. To try out this change, set the fsck passno to zero in /etc/fstab to cause the filesystem to be mounted without running fsck, then run `fsck_ffs -p -B <filesystem>' after the system has been brought up multiuser to run a background cleanup on <filesystem>. Note that the <filesystem> in question must have soft updates enabled.
* The ffs superblock includes a 128-byte region for use by temporaryiedowse2001-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | in-core pointers to summary information. An array in this region (fs_csp) could overflow on filesystems with a very large number of cylinder groups (~16000 on i386 with 8k blocks). When this happens, other fields in the superblock get corrupted, and fsck refuses to check the filesystem. Solve this problem by replacing the fs_csp array in 'struct fs' with a single pointer, and add padding to keep the length of the 128-byte region fixed. Update the kernel and userland utilities to use just this single pointer. With this change, the kernel no longer makes use of the superblock fields 'fs_csshift' and 'fs_csmask'. Add a comment to newfs/mkfs.c to indicate that these fields must be calculated for compatibility with older kernels. Reviewed by: mckusick
* .. forgot a ; at the end of the $FreeBSD$ string. How did I actually forgetadrian2000-10-091-1/+1
| | | | | | this? :-) It builds again.
* Some missed magic in the fsck wrapper commit which is required by otheradrian2000-10-091-0/+691
utilities which use bits of fsck_ffs - namely quotacheck and fsdb. In depth, utilities.c contains blockcheck() which is needed by both, but also a slew of routines which require bits of the FFS code to be compiled in. This breaks the fs-specific and non-fs-specific code up into two files (well, blockcheck() is the only routine in utilities.c, that'll change later) which makes building fsck_ffs, quotacheck and fsdb work yet again. (You won't find commits to fsdb and quotacheck here before I haven't committed the post-fsck-wrappers version of them yet.)
OpenPOWER on IntegriCloud