]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/doc/smm/05.fastfs/2.t
MFV: r329072
[FreeBSD/FreeBSD.git] / share / doc / smm / 05.fastfs / 2.t
1 .\" Copyright (c) 1986, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)2.t 8.1 (Berkeley) 6/8/93
29 .\"
30 .ds RH Old file system
31 .NH
32 Old File System
33 .PP
34 In the file system developed at Bell Laboratories
35 (the ``traditional'' file system),
36 each disk drive is divided into one or more
37 partitions.  Each of these disk partitions may contain
38 one file system.  A file system never spans multiple
39 partitions.\(dg
40 .FS
41 \(dg By ``partition'' here we refer to the subdivision of
42 physical space on a disk drive.  In the traditional file
43 system, as in the new file system, file systems are really
44 located in logical disk partitions that may overlap.  This
45 overlapping is made available, for example,
46 to allow programs to copy entire disk drives containing multiple
47 file systems.
48 .FE
49 A file system is described by its super-block,
50 which contains the basic parameters of the file system.
51 These include the number of data blocks in the file system,
52 a count of the maximum number of files,
53 and a pointer to the \fIfree list\fP, a linked
54 list of all the free blocks in the file system.
55 .PP
56 Within the file system are files.
57 Certain files are distinguished as directories and contain
58 pointers to files that may themselves be directories.
59 Every file has a descriptor associated with it called an
60 .I "inode".
61 An inode contains information describing ownership of the file,
62 time stamps marking last modification and access times for the file,
63 and an array of indices that point to the data blocks for the file.
64 For the purposes of this section, we assume that the first 8 blocks
65 of the file are directly referenced by values stored
66 in an inode itself*.
67 .FS
68 * The actual number may vary from system to system, but is usually in
69 the range 5-13.
70 .FE
71 An inode may also contain references to indirect blocks
72 containing further data block indices.
73 In a file system with a 512 byte block size, a singly indirect
74 block contains 128 further block addresses,
75 a doubly indirect block contains 128 addresses of further singly indirect
76 blocks,
77 and a triply indirect block contains 128 addresses of further doubly indirect
78 blocks.
79 .PP
80 A 150 megabyte traditional UNIX file system consists
81 of 4 megabytes of inodes followed by 146 megabytes of data.
82 This organization segregates the inode information from the data;
83 thus accessing a file normally incurs a long seek from the
84 file's inode to its data.
85 Files in a single directory are not typically allocated
86 consecutive slots in the 4 megabytes of inodes,
87 causing many non-consecutive blocks of inodes
88 to be accessed when executing
89 operations on the inodes of several files in a directory.
90 .PP
91 The allocation of data blocks to files is also suboptimum.
92 The traditional
93 file system never transfers more than 512 bytes per disk transaction
94 and often finds that the next sequential data block is not on the same
95 cylinder, forcing seeks between 512 byte transfers.
96 The combination of the small block size,
97 limited read-ahead in the system,
98 and many seeks severely limits file system throughput.
99 .PP
100 The first work at Berkeley on the UNIX file system attempted to improve both
101 reliability and throughput.
102 The reliability was improved by staging modifications
103 to critical file system information so that they could
104 either be completed or repaired cleanly by a program
105 after a crash [Kowalski78].
106 The file system performance was improved by a factor of more than two by
107 changing the basic block size from 512 to 1024 bytes.
108 The increase was because of two factors:
109 each disk transfer accessed twice as much data, 
110 and most files could be described without need to access
111 indirect blocks since the direct blocks contained twice as much data.
112 The file system with these changes will henceforth be referred to as the
113 .I "old file system."
114 .PP
115 This performance improvement gave a strong indication that
116 increasing the block size was a good method for improving
117 throughput.
118 Although the throughput had doubled, 
119 the old file system was still using only about
120 four percent of the disk bandwidth.
121 The main problem was that although the free list was initially
122 ordered for optimal access,
123 it quickly became scrambled as files were created and removed.
124 Eventually the free list became entirely random,
125 causing files to have their blocks allocated randomly over the disk.
126 This forced a seek before every block access.
127 Although old file systems provided transfer rates of up
128 to 175 kilobytes per second when they were first created,
129 this rate deteriorated to 30 kilobytes per second after a
130 few weeks of moderate use because of this
131 randomization of data block placement.
132 There was no way of restoring the performance of an old file system
133 except to dump, rebuild, and restore the file system.
134 Another possibility, as suggested by [Maruyama76],
135 would be to have a process that periodically
136 reorganized the data on the disk to restore locality.
137 .ds RH New file system
138 .sp 2
139 .ne 1i