Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
You can see info about the current state of the file system with
df -g
• XFS: A 64-bit high performance journaling filesystem used by IRIX for disks.
IRIX is Silicon Graphics' version of UNIX.
• FAT: DOS standard file system, also available on OS/2 and Windows
• FAT32: newer version of FAT with 32 bit block numbers (can address up to 4+
billion blocks)
• NTFS: Windows NT file system, also available on Windows 2000
• High Sierra: CD-ROM file system, standardized on most CD-ROMs.
• NFS: Network file system: makes file systems available to other machines on
UNIX. Not a file system in the same sense as the others.
Disk
• model the physical disk addresses with block numbers (usually each block
number corresponds to one sector id, but sometimes a block corresponds to
multiple sector ids)
• I/O layer of the OS translates disk addresses, expressed as a combination of a
drive #, a cyclinder #, a track #, and a sector #, into sector ids (and if necessary
block numbers).
• use disk for:
o file system
o swap space (managed as part of the file system on UNIX)
• general problem: how do we organize the space on disk?
Disk Allocation Methods
a)
contiguous allocation
b)
linked allocation
• each data block contains the block address of the next block in the
file
• each directory entry contains:
o file name
o block address: pointer to the first block
o sometimes, also have a pointer to the last block (adding to
the end of the file is much faster using this pointer)
c)
indexed allocation
i)
all files in one index
The index has one entry for
each block on disk.
ii)
separate index for each file
a)
one index block per file (assumes index is contiguous)
b)
linked list of index blocks for each file
c)
multilevel index
d)
combined scheme (i-node scheme) used in UNIX
• described later
Consider a file currently consisting of 150 blocks. Assume that the file control block
(and the index block, in the case of indexed allocation) is already in memory.
Calculate how many disk I/O operations are requried for continguous, linked, and
indexed (single--level) allocation strategies, if, for one block, the following conditions
hold. In the contiguous--allocation case, assume that there is no room to grow in the
beginning, but there is room to grow in the end. Assume that the block information to
be added is stored in memory.
Assumptions:
a)
The block is added in the middle:
Contiguous: Assume that in the middle means after block 75 and before block
76. We move the last 75 blocks down one position and then write in the new
block.
I/O operations
Linked: We cannot find block 75 without traversing the linked list stored in the
first 74 data blocks. So, we first read through these 74 blocks. Then we read
block 75, copy its link into the new block (in main memory), update block 75's
link to point to the new block, write out block 75, write new block.
Indexed: Update the index in main memory. Write the new block.
1w = 1 I/O operation
b)
The block is removed from the beginning.
0 I/O operations
Linked: Read in block 1 and change the starting address to the link stored in
this block.
1r = 1 I/O operation
Indexed: Simply remove the block's address from the linked list in the index
block.
0 I/O operations
Question:
Consider a file system on a disk that has both logical and physical block sizes of 512
bytes. Assume that the information about each file is already in memory. For the
contiguous strategy, answer these questions:
a)
How is the logical-to-physical address mapping accomplished in this system?
(For the indexed allocation, assume that a file is always less than 512 blocks
long.)
b)
If we are currently at logical block 10 (the last block accessed was block 10)
and want to access logical block 4, how many physical blocks must be read
from the disk?
Answer:
Assumptions: 1. Let L be the logical address and let P be the physical address. 2. The
assumption in part (a) is poorly given. It's more reasonable to simply assume that the
index is small enough to fit into a single block. In fact, a 512 block file will probably
require more than a single 512 byte block because block addresses typically require 3-
4 bytes each.
(a) Overview The CPU generates a logical address L (a relative offset in a file) and
the file system has to convert it to a physical address P (a disk address represented by
a block number PB and an offset in this block). For convenience of calculation, we
assume that blocks are numbered from 0. In any approach, we can determine the
logical block number LB by dividing the logical address L by the logical block size
(here 512). Similarly, the offset, which will be the same for logical and physical
addresses since the block sizes are identical, is determined by applying modulus. The
offset is the same in all approaches.
LB := L div 512
offset := L mod 512
(b) If we are currently at logical block 10 and we want to access logical block 4 ...
Contiguous: We simply move the disk head back by 6 blocks (from physical block 10
to physical block 4) because the space allocated to the file is contiguous. Then we
read block 4, for a total of one read.
• Bit Vector:
o Each block is represented by 1 bit.
o If a block is free, then the bit is 1, but if the block is in use, then the bit is
0.
o For example, if the disk had 10 blocks, and blocks 2, 4, 5, and 8 were
free, while blocks 0, 1, 3, 6, 7, and 9 were in use, the bit vector would be
represented as: 0010110010
• Correction to 5th edition of S\&G.
• Free List (Linked List of Free Blocks)
o The address (block number) of the first free block is kept in a designated
place in memory.
o The first free block contains a pointer to the next free block, it contains a
pointer to the next free block, and so forth.
o Can add a free block to the beginning of the free list in O(1) time.
o Can remove a free block from the beginning of the free list in O(1) time.
o number of i-nodes
o number of data blocks
o start of the list of free blocks
first few hundred entries
the rest of the free list is stored in a block that is otherwise free
Example on UNIX:
df = disk free
df -i /u
/u is the directory on hercules is where student files are stored
Filesystem Type blocks use avail %use iuse ifree
%iuse Mounted
/dev/dsk/dks efs 7654152 2790059 4864093 36% 158252 647230
20% /u
4864093 Kb = free
Each i-node:
• Assume that there are 10 direct pointers to data blocks, 1 indirect pointer, 1
double indirect pointer, and 1 triple indirect pointer
• Assume that the size of the data blocks is 1024 bytes = 1Kb, i.e., BlockSize =
1Kb
• Assume that the block numbers are represented as 4 byte unsigned integers, i.e.,
BlockNumberSize = 4b
• Some data blocks are used as index blocks. They store 1024 bytes / 4
bytes/entry = 256 entries
• Maximum number of bytes addressed by 10 direct pointers is
• = Number of direct pointers * Blocksize
• = 10 * 1Kb
• = 10Kb
I-Node Organization
Return to Contents