summaryrefslogtreecommitdiffstats
path: root/sbin/newfs/mkfs.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Add a "-l" flag to newfs, which sets the FS_MULTILABEL flag. Thisrwatson2004-02-261-0/+2
| | | | | | | | permits users of newfs to set the multilabel flag on UFS1 and UFS2 file systems from inception without using tunefs. Obtained from: TrustedBSD Project Sponsored by: DARPA, McAfee Research
* Fix whitespace error in previous commit.wes2003-11-271-1/+1
| | | | Approved by: RE@ (Robert Watson)
* Don't use UFS2_BAD_MAGIC on UFS (v1) filesystems; it is Not Readywes2003-11-231-1/+1
| | | | | | | for Prime Time there. Submitted by: Xin LI <delphij@frontfree.net> Approved by: RE@ (John, Scott)
* Add the -E command line option to force error conditions for testing.wes2003-11-161-1/+12
| | | | Sponsord by: St. Bernard Software
* Write the UFS2 superblock with a 'BAD' magic number at the beginningwes2003-11-161-1/+4
| | | | | | | | of newfs, to signify the newfs operation has not yet completed. Re- write the superblock with the correct magic number once all of the cylinder groups have been created to show the operation has finished. Sponsored by: St. Bernard Software
* Create a .snap directory mode 770 group operator in the root ofmckusick2003-11-041-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | a new filesystem. Dump and fsck will create snapshots in this directory rather than in the root for two reasons: 1) For terabyte-sized filesystems, the snapshot may require many minutes to build. Although the filesystem will not be suspended during most of the snapshot build, the snapshot file itself is locked during the entire snapshot build period. Thus, if it is accessed during the period that it is being built, the process trying to access it will block holding its containing directory locked. If the snapshot is in the root, the root will lock and the system will come to a halt until the snapshot finishes. By putting the snapshot in a subdirectory, it is out of the likely path of any process traversing through the root and hence much less likely to cause a lock race to the root. 2) The dump program is usually run by a non-root user running with operator group privilege. Such a user is typically not permitted to create files in the root of a filesystem. By having a directory in group operator with group write access available, such a user will be able to create a snapshot there. Having the dump program create its snapshot in a subdirectory below the root will benefit from point (1) as well. Sponsored by: DARPA & NAI Labs.
* Exit with a non-zero status upon a block allocation failure.yar2003-08-051-3/+3
| | | | | | | | | | The old way of just returning could result in a file system extremely likely to panic the kernel. The warning printed wouldn't help much since tools invoking newfs(8), e.g., mdmfs(8), couldn't detect the error. PR: bin/55078 MFC after: 1 week
* When newfs'ing a partition with UFS2 that had previously been newfs'eddougb2003-05-221-0/+24
| | | | | | | | | | | | | | | | | with UFS1, the UFS1 superblocks were not deleted. This allowed any RELENG_4 (or other non-UFS2-aware) fsck to think it knew how to "fix" the file system, resulting in severe data scrambling. This patch is a more advanced version than the one originally submitted. Lukas improved it based on feedback from Kirk, and testing by me. It blanks all UFS1 superblocks (if any) during a UFS2 newfs, thereby causing fsck's that are not UFS2 aware to generate the "SEARCH FOR ALTERNATE SUPER-BLOCK FAILED" message, and exit without damaging the fs. PR: bin/51619 Submitted by: Lukas Ertl <l.ertl@univie.ac.at> Reviewed by: kirk Approved by: re (scottl)
* Put back the error checking in wtfs() that was lost when newfs wasiedowse2003-05-101-1/+2
| | | | | | | | | | | | | | changed to use libufs in revision 1.71. Without this, any write failures in newfs were silently ignored. Note that this will display a meaningless errno string in the case of a short write as opposed to a write error, since bwrite()'s return value does not allow the caller to determine if errno is valid. Reported by: Lukas Ertl <l.ertl@univie.ac.at> Reviewed by: jmallett Approved by: re (bmah)
* Use __FBSDID() to quiet GCC 3.3 warnings.obrien2003-05-031-4/+4
|
* Fix the -R flag so that it provides sequential "random" numbersmckusick2003-02-221-9/+21
| | | | | | so that the regression test will succeed. Sponsored by: DARPA & NAI Labs.
* Replace use of random() with arc4random() to provide less guessablemckusick2003-02-141-5/+5
| | | | | | | | values for the initial inode generation numbers in newfs and for newly allocated inode generation numbers in the kernel. Submitted by: Theo de Raadt <deraadt@cvs.openbsd.org> Sponsored by: DARPA & NAI Labs.
* Correct lines incorrectly added to the copyright message. Add missing period.mckusick2003-02-141-4/+1
| | | | | Submitted by: Bruce Evans <bde@zeta.org.au> Sponsored by: DARPA & NAI Labs.
* Convert newfs to libufs (really). Solves one real issue with previousjmallett2003-02-111-98/+18
| | | | | | | version of such. Differences in filesystems generated were found to be from 1) sbwrite with the "all" parameter 2) removal of writecache. The sbwrite call was made to perform as the original version, and otherwise this was checked against a version of newfs with the write cache removed.
* Bring in support for volume labels to the filesystem utilities.gordon2003-02-011-0/+2
| | | | Reviewed by: mckusick
* Back out conversion to libufs, for now. It seems to cause problems.jmallett2003-01-291-20/+99
| | | | Reported by: phk
* Convert newfs to use libufs. I've tested this on md filesystems, as hasjmallett2003-01-271-99/+20
| | | | keramida, and all seems well.
* Correctly calculate the initial number of fragments in a filesystemmckusick2002-12-021-2/+2
| | | | | | | | so that fsck does not complain with `SUMMARY BLK COUNT(S) WRONG IN SUPERBLK' the first time it is run on a new filesystem. Reported by: Poul-Henning Kamp <phk@freebsd.org> Sponsored by: DARPA & NAI Labs.
* Add some more checks to newfs so that it will not build filesystemsmckusick2002-11-301-14/+24
| | | | | | | | | | that the kernel will refuse to mount. Specifically it now enforces the MAXBSIZE blocksize limit. This update also fixes a problem where newfs could segment fault if the selected fragment size was too large. PR: bin/30959 Submitted by: Ceri Davies <setantae@submonkey.net> Sponsored by: DARPA & NAI Labs.
* Create a new 32-bit fs_flags word in the superblock. Add code to movemckusick2002-11-271-6/+6
| | | | | | | | | | | | | | | | | 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.
* Properly calculate the initial number of fragments in a large filesystem.mckusick2002-11-151-1/+2
| | | | Sponsored by: DARPA & NAI Labs.
* Bound the size of the superblock to SBLOCKSIZE.mckusick2002-10-181-0/+2
| | | | | Submitted by: BOUWSMA Beery <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs.
* Use the standardized CHAR_BIT constant instead of NBBY in userland.mike2002-09-251-5/+6
|
* s/filesystem/file system/g as discussed on -developerstrhodes2002-08-211-10/+10
|
* di_createtime -> di_birthtime.roberto2002-07-171-1/+1
| | | | Submitted by: Udo Schweigert <Udo.Schweigert@siemens.com>
* Fixed 4 printf format errors that were fatal on alphas. %qd is not evenbde2002-07-111-7/+9
| | | | | suitable for printing quad_t's since it is equivalent to %lld but quad_t is unsigned long on alphas. quad_t shouldn't be used anyway.
* Get rid of paranoia that zeros the boot block area as this hasmckusick2002-06-221-7/+0
| | | | | | | bad effect on existing bootstraps. Submitted by: Jake Burkholder <jake@locore.ca> Sponsored by: DARPA & NAI Labs.
* This commit adds basic support for the UFS2 filesystem. The UFS2mckusick2002-06-211-432/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* more file system > filesystemtrhodes2002-05-161-11/+11
|
* Continue the cleanup preparations for UFS2 (& GEOM):phk2002-04-241-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use only one filedescriptor. Open in R/O or R/W based in the '-N' option. Make the filedescriptor a global variable instead of passing it around as semi-global variable(s). Remove the undocumented ability to specify type without '-T' option. Replace fatal() with straight err(3)/errx(3). Save calls to strerror() where applicable. Loose the progname variable. Get the sense of the cpgflag test correct so we only issue warnings if people specify cpg and can't get that. It can be argued that this should be an error. Remove the check to see if the disk is mounted: Open for writing would fail if it were mounted. Attempt to get the sectorsize and mediasize with the generic disk ioctls, fall back to disklabel and /etc/disktab as we can. Notice that on-disk labels still take precedence over /etc/disktab, this is probably wrong, but not as wrong as the entire concept of /etc/disktab is. Sponsored by: DARPA & NAI Labs.
* bbsize and sbsize cannot ever be trusted from the disklabel, inphk2002-04-071-45/+4
| | | | | | | | | particular as there may not be one. Remove #if 0'ed code which might mislead people to think otherwise. unifdef -ULOSTDIR, fsck can make lost+found on the fly. Sponsored by: DARPA & NAI Labs
* Fixed some English errors in previous commit.bde2002-04-041-14/+15
| | | | | Fixed some style bugs in the removal of __P(()). Whitespace before "__P((" was not removed.
* Add more DWIM/autoadjustment and less evil style(9) banned exit(2) codes.phk2002-04-031-15/+17
| | | | | | Add some missing statics. Sponsored by: DARPA & NAI Labs.
* Swing the axe and remove some archaic features from newfs which modernphk2002-03-201-104/+32
| | | | | | | | | | | | | | | | | | | diskdrives do neither need nor want: -O create a 4.3BSD format filesystem -d rotational delay between contiguous blocks -k sector 0 skew, per track -l hardware sector interleave -n number of distinguished rotational positions -p spare sectors per track -r revolutions/minute -t tracks/cylinder -x spare sectors per cylinder No change in the produced filesystem image unless one or more of these options were used. Approved by: mckusick
* Add the undocumented -R option to disable randomness for regression-testing.phk2002-03-191-2/+5
| | | | | | | | Add a couple of simple regression tests accessible with "make test", they depend on the md(4) driver. FYI I have also tried running the test against a week old newfs and it passed.
* Further cleanups.phk2002-03-191-52/+21
|
* Replace a number of similar `for' loops with a new `ilog2()' functioniedowse2002-03-191-10/+17
| | | | that computes the base-2 log of a power of 2.
* Complete the ANSIfication of newfs by converting function declarationsiedowse2002-03-191-44/+13
| | | | to C89 style.
* The FSIRAND code is always compiled in, and it is unlikely thatiedowse2002-03-191-19/+1
| | | | | | anyone needs a newfs without it. Remove the #ifdef's from around the code and the -DFSIRAND from the Makefile. Also remove redundant declarations of random() and srandomdev().
* Remove the ancient STANDALONE code.iedowse2002-03-191-118/+1
| | | | Approved by: phk
* Remove yet more vestiges of mount_mfs.iedowse2002-03-181-2/+0
|
* Fixed some style bugs (mainly ones not fixed or made worse by rev.1.41).bde2002-03-181-12/+16
| | | | | | Old code obfuscates long (but single-line) messages by printing them in pieces using %s. Rev.1.41 obfuscated some new long messages using ISO string concatenation. This commit only fixes the new obfuscations.
* Remove __P() and register.phk2002-03-171-24/+24
| | | | | | | | Set WARNS=2 This is the beginning of a pre-UFS2 cleanup of newfs. Sponsored by: DARPA, NAI Labs
* style(9) cleanup.phk2001-11-021-42/+40
| | | | | Submitted by: j mckitrick <jcm@freebsd-uk.eu.org> Reviewed by: phk, /sbin/md5
* Handle snprintf() returning < 0 (not just -1)brian2001-08-201-2/+2
| | | | MFC after: 2 weeks
* Handle snprintf() returning -1.brian2001-08-201-0/+2
| | | | MFC after: 2 weeks
* A more complete removal of MFS related code.phk2001-05-291-159/+15
| | | | XXX: This program badly needs a style(9) + BDECFLAGS treatment.
* sprintf() -> snprintf()kris2001-04-241-1/+1
| | | | | Partially submitted by: "Andrew R. Reiter" <arr@watson.org> Obtained from: OpenBSD
* Directory layout preference improvements from Grigoriy Orlov <gluk@ptci.ru>.mckusick2001-04-101-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | His description of the problem and solution follow. My own tests show speedups on typical filesystem intensive workloads of 5% to 12% which is very impressive considering the small amount of code change involved. ------ One day I noticed that some file operations run much faster on small file systems then on big ones. I've looked at the ffs algorithms, thought about them, and redesigned the dirpref algorithm. First I want to describe the results of my tests. These results are old and I have improved the algorithm after these tests were done. Nevertheless they show how big the perfomance speedup may be. I have done two file/directory intensive tests on a two OpenBSD systems with old and new dirpref algorithm. The first test is "tar -xzf ports.tar.gz", the second is "rm -rf ports". The ports.tar.gz file is the ports collection from the OpenBSD 2.8 release. It contains 6596 directories and 13868 files. The test systems are: 1. Celeron-450, 128Mb, two IDE drives, the system at wd0, file system for test is at wd1. Size of test file system is 8 Gb, number of cg=991, size of cg is 8m, block size = 8k, fragment size = 1k OpenBSD-current from Dec 2000 with BUFCACHEPERCENT=35 2. PIII-600, 128Mb, two IBM DTLA-307045 IDE drives at i815e, the system at wd0, file system for test is at wd1. Size of test file system is 40 Gb, number of cg=5324, size of cg is 8m, block size = 8k, fragment size = 1k OpenBSD-current from Dec 2000 with BUFCACHEPERCENT=50 You can get more info about the test systems and methods at: http://www.ptci.ru/gluk/dirpref/old/dirpref.html Test Results tar -xzf ports.tar.gz rm -rf ports mode old dirpref new dirpref speedup old dirprefnew dirpref speedup First system normal 667 472 1.41 477 331 1.44 async 285 144 1.98 130 14 9.29 sync 768 616 1.25 477 334 1.43 softdep 413 252 1.64 241 38 6.34 Second system normal 329 81 4.06 263.5 93.5 2.81 async 302 25.7 11.75 112 2.26 49.56 sync 281 57.0 4.93 263 90.5 2.9 softdep 341 40.6 8.4 284 4.76 59.66 "old dirpref" and "new dirpref" columns give a test time in seconds. speedup - speed increasement in times, ie. old dirpref / new dirpref. ------ Algorithm description The old dirpref algorithm is described in comments: /* * Find a cylinder to place a directory. * * The policy implemented by this algorithm is to select from * among those cylinder groups with above the average number of * free inodes, the one with the smallest number of directories. */ A new directory is allocated in a different cylinder groups than its parent directory resulting in a directory tree that is spreaded across all the cylinder groups. This spreading out results in a non-optimal access to the directories and files. When we have a small filesystem it is not a problem but when the filesystem is big then perfomance degradation becomes very apparent. What I mean by a big file system ? 1. A big filesystem is a filesystem which occupy 20-30 or more percent of total drive space, i.e. first and last cylinder are physically located relatively far from each other. 2. It has a relatively large number of cylinder groups, for example more cylinder groups than 50% of the buffers in the buffer cache. The first results in long access times, while the second results in many buffers being used by metadata operations. Such operations use cylinder group blocks and on-disk inode blocks. The cylinder group block (fs->fs_cblkno) contains struct cg, inode and block bit maps. It is 2k in size for the default filesystem parameters. If new and parent directories are located in different cylinder groups then the system performs more input/output operations and uses more buffers. On filesystems with many cylinder groups, lots of cache buffers are used for metadata operations. My solution for this problem is very simple. I allocate many directories in one cylinder group. I also do some things, so that the new allocation method does not cause excessive fragmentation and all directory inodes will not be located at a location far from its file's inodes and data. The algorithm is: /* * Find a cylinder group to place a directory. * * The policy implemented by this algorithm is to allocate a * directory inode in the same cylinder group as its parent * directory, but also to reserve space for its files inodes * and data. Restrict the number of directories which may be * allocated one after another in the same cylinder group * without intervening allocation of files. * * If we allocate a first level directory then force allocation * in another cylinder group. */ My early versions of dirpref give me a good results for a wide range of file operations and different filesystem capacities except one case: those applications that create their entire directory structure first and only later fill this structure with files. My solution for such and similar cases is to limit a number of directories which may be created one after another in the same cylinder group without intervening file creations. For this purpose, I allocate an array of counters at mount time. This array is linked to the superblock fs->fs_contigdirs[cg]. Each time a directory is created the counter increases and each time a file is created the counter decreases. A 60Gb filesystem with 8mb/cg requires 10kb of memory for the counters array. The maxcontigdirs is a maximum number of directories which may be created without an intervening file creation. I found in my tests that the best performance occurs when I restrict the number of directories in one cylinder group such that all its files may be located in the same cylinder group. There may be some deterioration in performance if all the file inodes are in the same cylinder group as its containing directory, but their data partially resides in a different cylinder group. The maxcontigdirs value is calculated to try to prevent this condition. Since there is no way to know how many files and directories will be allocated later I added two optimization parameters in superblock/tunefs. They are: int32_t fs_avgfilesize; /* expected average file size */ int32_t fs_avgfpdir; /* expected # of files per directory */ These parameters have reasonable defaults but may be tweeked for special uses of a filesystem. They are only necessary in rare cases like better tuning a filesystem being used to store a squid cache. I have been using this algorithm for about 3 months. I have done a lot of testing on filesystems with different capacities, average filesize, average number of files per directory, and so on. I think this algorithm has no negative impact on filesystem perfomance. It works better than the default one in all cases. The new dirpref will greatly improve untarring/removing/coping of big directories, decrease load on cvs servers and much more. The new dirpref doesn't speedup a compilation process, but also doesn't slow it down. Obtained from: Grigoriy Orlov <gluk@ptci.ru>
OpenPOWER on IntegriCloud