Commit Graph

113 Commits

Author SHA1 Message Date
Poul-Henning Kamp
1851342297 Failure to rewrite the disklabel should not be fatal.
Sponsored by:	DARPA & NAI Labs.
2002-09-22 09:41:41 +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
Poul-Henning Kamp
4ab9c1d126 Remove the -v option, it is now default behaviour.
Sponsored by:	DARPA & NAI Labs
2002-04-24 12:27:03 +00:00
Poul-Henning Kamp
9aba332745 Continue the cleanup preparations for UFS2 (& GEOM):
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.
2002-04-24 11:44:02 +00:00
Poul-Henning Kamp
ebdb43a2f8 bbsize and sbsize cannot ever be trusted from the disklabel, in
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
2002-04-07 14:57:57 +00:00
Bruce Evans
73c36e3672 Fixed some style bugs in axings. Whitespace before __P was not axed when
__P was axed.  The ordering of several things was bogotified by axing
ifdefs.
2002-04-04 09:56:51 +00:00
Poul-Henning Kamp
fa8d75e0a1 Unifdef -DCOMPAT 2002-04-03 19:53:09 +00:00
Poul-Henning Kamp
5dccd5c649 Swing the axe and remove some archaic features from newfs which modern
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
2002-03-20 07:16:15 +00:00
Poul-Henning Kamp
89fb8ee796 Add the undocumented -R option to disable randomness for regression-testing.
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.
2002-03-19 21:05:29 +00:00
Poul-Henning Kamp
8409849dd0 Further cleanups. 2002-03-19 20:01:38 +00:00
Ian Dowse
bf57cced53 Complete the ANSIfication of newfs by converting function declarations
to C89 style.
2002-03-19 17:20:02 +00:00
Ian Dowse
9710700cb1 Remove the ancient STANDALONE code.
Approved by:	phk
2002-03-19 16:47:20 +00:00
Ian Dowse
af53d6d86e Remove yet more vestiges of mount_mfs. 2002-03-18 15:31:44 +00:00
Bruce Evans
0c08079e26 Fixed some style bugs (mainly ones not fixed or made worse by rev.1.44).
Don't use ISO string concatentation to obfuscate long single-line
messages...
2002-03-18 03:04:58 +00:00
Bruce Evans
3ac7f11229 Removed vestiges of mount_mfs. Sorted the Makefile a bit. 2002-03-18 02:23:43 +00:00
Poul-Henning Kamp
345b78a301 Remove __P() and register.
Set WARNS=2

This is the beginning of a pre-UFS2 cleanup of newfs.

Sponsored by:	DARPA, NAI Labs
2002-03-17 09:01:41 +00:00
Sheldon Hearn
3626f83327 Update the default newfs block and fragment sizes from 8192/1024 to
16384/2048.

Following recent discussions on the -arch mailing list, involving dillon
and mckusick, this change parallels the one made over a decade ago when
the default was bumped up from 4096/512.

This should provide significant performance improvements for most
folks, less significant performance losses for a few folks and
wasted space lost to large fragments for many folks.

For discussion, please see the following thread in the -arch archive:

Subject: Using a larger block size on large filesystems

The discussion ceases to be relevant when the issue of partitioning
schemes is raised.
2001-12-11 16:21:40 +00:00
Peter Wemm
1165817956 Remove support for FreeBSD/tahoe
Submitted by:	phk
2001-11-03 08:35:11 +00:00
Poul-Henning Kamp
bfd1f63d44 style(9) cleanup.
Submitted by:	j mckitrick <jcm@freebsd-uk.eu.org>
Reviewed by:	phk, /sbin/md5
2001-11-02 09:23:34 +00:00
Ollivier Robert
4f63c70a2b Fix diskless clients by removing the code for calculating the minimum
value for cpg. The change was bogus.

Submitted by:	bde
MFC after:	2 days
2001-10-18 09:48:28 +00:00
Ollivier Robert
08870345f5 Following the discussion in -arch and the submission of a patch by bde, here
it is. I added the manpage change.

Submitted by:	bde
MFC after:	1 week
2001-10-04 12:15:50 +00:00
Kris Kennaway
5979df34a6 Silence non-constant format string warnings by marking functions
as __printflike()/__printf0like(), adding const, or adding missing "%s"
format strings, as appropriate.

MFC after:	2 weeks
2001-08-19 08:19:37 +00:00
Poul-Henning Kamp
80f86e526b A more complete removal of MFS related code.
XXX: This program badly needs a style(9) + BDECFLAGS treatment.
2001-05-29 19:40:39 +00:00
Poul-Henning Kamp
a383ba34c2 Initial cleanout of MFS from newfs. More complete wash needed. 2001-05-29 18:52:39 +00:00
Kris Kennaway
1fef4cc97d sprintf() -> snprintf()
Partially submitted by:	"Andrew R. Reiter" <arr@watson.org>
Obtained from:	OpenBSD
2001-04-24 10:26:00 +00:00
Kris Kennaway
c3b1df1293 Add a missing argument to an error message format string. 2001-04-17 07:21:48 +00:00
Kirk McKusick
a61ab64ac4 Directory layout preference improvements from Grigoriy Orlov <gluk@ptci.ru>.
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>
2001-04-10 08:38:59 +00:00
David E. O'Brien
b2cd1ce8ee Allow enabling soft updates (with -U) on a new filesystem.
[I first added this functionality, and thought to check prior art.  Seeing
OpenBSD had already done this, I changed my addition to reduce the diffs
between the two and went with their option letter.]
Obtained from:	OpenBSD
2001-04-02 01:25:55 +00:00
David E. O'Brien
094ab93715 The common wisdom is to use the largest number of cylinders per group.
So bump the default from `16' to `22', which is the largest value allowed
with the current default block size.  This change increases the the
group size from 32MB/g to 44MB/g on a 4GB SCSI disk.
2001-03-27 01:34:58 +00:00
Poul-Henning Kamp
7cf109c1b4 Make mount_mfs annoy users for 15 seconds and point them at mdconfig(8). 2001-01-30 10:21:20 +00:00
Mike Smith
6801d96c70 Don't try to do anything with the /dev/rXXX device. 2000-05-31 01:00:51 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Nick Hibma
de4a801355 Add again the ':' after the x option in th eargument list to getopt.
It disappeared in rev. 1.23 newfs.c

PR: 12292
Submitted by: Cy Schubert <cy@cschuber.net.gov.bc.ca>
1999-06-19 13:32:27 +00:00
Matthew Dillon
cb84cdb1c4 Fix bug in mount_mfs whereby mount_mfs would sometimes return before
the mount is completely active, causing the next few commands attempting
    to manipulate data on the mount to fail.  mount_mfs's parent now tries
    to wait for the mount point st_dev to change before returning, indicating
    that the mount has gone active.
1999-02-09 17:19:19 +00:00
Bruce Evans
8116455e9d Backed out previous commit. It broke fsck again. See rev.1.22 and the
references there, and rev.1.38 of sys/ufs/ufs/ufs_disksubr.c.
1998-10-17 08:03:52 +00:00
Jordan K. Hubbard
7b955a8e5d Don't rewrite the disk label. The type field is already set correctly
and we don't use the frags info, so why bother?  More to the point, it
seems to result in an EXDEV error when the label is written out and we
lose because of it (don't know why though).  This is a work-around and
is marked as such.
1998-10-17 04:19:29 +00:00
Greg Lehey
e34129e8ba Correct source file corruption in last checkin
Observed by:  jkh
1998-09-30 07:53:52 +00:00
Greg Lehey
11ee80a991 Don't require an argument for -v flag
Correct checks for null special file names
Add Usage entry for -v flag
Get terminology straight in man page
Reviewed by:	bde
1998-09-29 23:20:04 +00:00
Greg Lehey
58343e4cc6 Reviewed by: bde,jkh
Add -v flag to newfs:

     -v      Specify that the partition does not contain any slices, and that
             newfs should treat the whole partition as the file system.  This
             option is useful for synthetic disks such as ccd and vinum.
1998-09-11 06:26:08 +00:00
Bruce Evans
519e76df7c Backed out rev.1.9 (except don't bring back the vax code deleted
in rev.1.9).  fsck uses the per-partition ffs-related information
in the label to find alternate superblocks when the main superblock
is hosed.  Rev.1.9 broke this by deleting the code that wrote the
label.

PR:		2537
xref:		fsck/setup.c rev.1.8
1998-07-20 12:04:42 +00:00
Philippe Charnier
16e80a4182 Make it compile again in the !__STDC__ case.
Found by: Bruce.
1998-07-16 12:04:52 +00:00
Philippe Charnier
27750b35a5 Add prototypes. Check malloc() return value. Use err(). Remove unused #includes
Do not \n nor dot terminate syslog()/err() messages. -Wall.
1998-07-15 06:28:05 +00:00
Bruce Evans
ca46ad5f48 Fixed printf format errors. 1998-06-28 20:11:23 +00:00
Bruce Evans
6e1a705dd4 Fixed some spelling errors. 1998-01-16 06:31:23 +00:00
Tor Egge
dc6f8d1bd5 Allow use of the name "swap" instead of an actual swap device.
This makes configuration of mfs /tmp on diskless clients more intuitive
for people like me, that have used this feature on NetBSD and SunOS.
Using the -T option and /dev/null, while already supported,
is neither intuitive nor documented in the handbook.
Obtained from: NetBSD
1997-06-23 22:44:51 +00:00
Warner Losh
8d64695c7c compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 03:33:12 +00:00
Peter Wemm
75e2941193 Merge from Lite2:
- use new getvfsbyname() and mount(2) interface (mount_mfs)
 - use new fs include files
 - updated inode / cg layout calculations (?)
1997-03-11 12:48:17 +00:00
Søren Schmidt
7cb29d3394 This update adds the support for != 512 byte sector SCSI devices to
the sd & od drivers. There is also slight changes to fdisk & newfs
in order to comply with different sectorsizes.
Currently sectors of size 512, 1024 & 2048 are supported, the only
restriction beeing in fdisk, which hunts for the sectorsize of
the device.
This is based on patches to od.c and the other system files by
John Gumb & Barry Scott, minor changes and the sd.c patches by
me.
There also exist some patches for the msdos filesys code, but I
havn't been able to test those (yet).

	John Gumb (john@talisker.demon.co.uk)
	Barry Scott (barry@scottb.demon.co.uk)
1996-12-01 11:25:38 +00:00
Peter Wemm
10dcae5806 Add hooks into the mount_mfs code in newfs to do the FreeBSD-style
LKM loading if it was not configured into the system.

Note that the LKM for MFS is not enabled by default, but I got it working on
my machine..  I'll see what I did..
1996-01-01 08:37:28 +00:00
David Greenman
70dded0aec Shorten a variable name. 1995-09-17 09:54:05 +00:00
Joerg Wunsch
ccf9a17c14 Avoid the "calculated sectors per cylinder disagrees with disklabel"
warning for the default case where the user hasn't specified either -t
or -u on the command line.  It's been confusing our users.
1995-09-09 13:03:09 +00:00
David Greenman
76b19b6b87 Fixed error in maxcontig calculation that caused it to default to "1". 1995-09-08 13:52:55 +00:00
Poul-Henning Kamp
e7bf085313 Yank out the rewriting of disklabels. This code can and will get confused
in a couple of cases, and it doesn't do much anyway.  It used to save only
the newfs params (block/frag/cgroup.. and nothing more.  Something that
don't belong in a disklabel in the first place.
1995-04-19 02:19:20 +00:00
Poul-Henning Kamp
4e93a5203c Allow zero as value for certain arguments to indicate "take from disklabel". 1995-02-05 18:03:37 +00:00
Poul-Henning Kamp
55abc5794a Change the defaults for newfs to disregard the geometry in the disklabel.
We pretend we have one head with two megabyte worth of sectors per cylinder.

The code try to access another head in what it belives to the same
physical cylinder, because it belives that it would be faster than
waiting for the next free sector under this head to come around.

Most modern drives doesn't have a "classical" geometry, and thus
we end up fooling ourselves doing the above optimization.  With this
change we will fill a cylinder sequentially if we can, and thus get
much more mileage from the track-buffer/cache built into the drives.

As a result a lot of seeks to the next or previous track should be
avoided by this.

(My disk is a lot less noisy actually...)

You can still get the old behaviour, by specifying zero for the
numbers.

This will also solve the problem with newfs barfing at really big
drives.

Obtained from:	adult advice from Kirk.
1995-02-05 08:42:31 +00:00
Garrett Wollman
3fa88dec7f Add support for filesystem-specific `-o' options, and re-implement the
most common cd9660 and nfs options like God intended them.  (It is now
possible to say

	mount -o ro,soft,bg,intr there:/foo/bar /foo/bar

again.)  This whole getmntopt() business is an incredible botch;
it never should have been anything more than a wrapper around
getsubopt(3).  Because if the way the current hackaround is implemented,
options which take arguments (like the old `rsize' and `wsize') are still
unavailable, and must be accessed the new, broken way.

(It's unimaginable how Berkeley managed to screw up one of the few things
about NFS that Sun actually got right to begin with!)
1994-11-01 23:51:53 +00:00
Jordan K. Hubbard
3270fb5ece Put back the `:' in the trinary ?: so this can actually compile again! :) 1994-10-13 08:46:44 +00:00
Poul-Henning Kamp
72ab19aeb7 Added '-F file' option of mount_mfs. This allows me to make floppy images
without waiting for my floppy-drive all the time :-)  Might have other
interesting uses too.
1994-10-12 22:04:36 +00:00
David Greenman
3156bbb2d1 Backed out part of the last change that prevents the rpos table from
being output if <= 1 rpos; there is a bug in the kernel which doesn't
quite get along with this. Changed default #rpos to 1, and fixed up
manual page. Converted nrpos to 1 if user specifies 0.
1994-10-09 20:10:56 +00:00
David Greenman
7ce005d7c1 1) If nrpos <= 1, don't output rpos table (and set fs_cpc to 0) - disabling
the use of the rotational position table.
2) Allow specification of 0 rotational positions (disables function).
3) Make rotdelay=0 and nrpos=0 by default.

   The purpose of the above is to optimize for modern SCSI (and IDE) drives
that do read-ahead/write-behind.
1994-10-01 16:56:22 +00:00
Rodney W. Grimes
8fae3551ec BSD 4.4 Lite sbin Sources
Note:  XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.
1994-05-26 06:35:07 +00:00