chapter 11

19
Chapter 11 Chapter 11 File System Implementation

Upload: sherougm

Post on 11-Jun-2015

4.075 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Chapter 11

Chapter 11Chapter 11File System Implementation

Page 2: Chapter 11

Exercise 11.1Exercise 11.1

Consider a file system that uses a modified contiguous-allocation scheme with support for extents. A file is a collection of extents, with each extent corresponding to a contiguous set of blocks. A key issue in such systems is the degree of variability in the size of extents. What are the advantages and disadvantages of the following schemes?

Page 3: Chapter 11

Exercise 11.1.aExercise 11.1.a

a. All extents are of the same size, and the size is predetermined.

Page 4: Chapter 11

Answer 11.1.aAnswer 11.1.a

If all extents are of the same size, and the size is predetermined, then it simplifies the block allocation scheme. A simple bit map for extents would suffice.

Simple

Page 5: Chapter 11

Exercise 11.1.bExercise 11.1.b

b. Extents can be of any size and are allocated dynamically.

Page 6: Chapter 11

Answer 11.1.bAnswer 11.1.b

If extents can be of any size and dynamically allocated, then more complex allocation schemes are required.

It might be difficult to find an extent of the appropriate size external fragmentation.

Very complex

Page 7: Chapter 11

Exercise 11.1.cExercise 11.1.c

c. Extents can be a few fixed sizes, and these are predetermined.

Page 8: Chapter 11

Answer 11.1.cAnswer 11.1.c

If the extents can be of a few fixed sizes, and these sizes are predetermined, the we would need to maintain a separate bit map for each possible size.

This scheme is of intermediate difficulty and flexibility

Page 9: Chapter 11

Exercise 11.4Exercise 11.4

Some file systems allow disk storage to be allocated at different levels of granularity. For instance, a file system could allocate 4 KB of disk space as a single 4-KB block or as eight 512-byte blocks. ◦How could we take advantage of this flexibility

to improve performance? ◦What modifications would have to be made to

the free-space management scheme in order to support this feature?

Page 10: Chapter 11

Answer 11.4Answer 11.4

For example, if a file is 5 KB then it would be allocated a 4-KB block and two contiguous 512-byte blocks.

What will this block allocation scheme help decrease?

Page 11: Chapter 11

Answer 11.4 cont.Answer 11.4 cont.

Modification are required. We should maintain:◦a bitmap of free blocks◦an extra state regarding which of the sub

blocks are currently being used inside a block. Therefore, the allocator would have to

examine that extra state to allocate sub blocks and coalesce the sub blocks to obtain the larger block when all of the sub blocks are free.

Page 12: Chapter 11

Exercise 11.6Exercise 11.6

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 each of the three allocation strategies (contiguous, linked, and indexed), answer these question:

Page 13: Chapter 11

Exercise 11.6.aExercise 11.6.a

a. How is the logical-to-physical address mapping accomplished in this system?For indexed allocation, assume that a file is always less than 512 blocks long.

Page 14: Chapter 11

Answer 11.6.aAnswer 11.6.a

The CPU will generate a logical address L and we need to convert it to a physical address P

P is a disk address represented by a block number and an offset

Assume the following◦S is the starting block◦B is the block◦O is the offset

Page 15: Chapter 11

Answer 11.6.a (Contiguous)Answer 11.6.a (Contiguous)

Contiguous allocation:◦B = L / 512◦O = L modulus 512◦Physical block number = S + B

O is the offset into that block◦So: S + B + O = physical address

Page 16: Chapter 11

Answer 11.6.a (Linked)Answer 11.6.a (Linked)

Linked allocation:◦B = L / 511◦O = L modulus 511◦Follow the linked list for (B+1) blocks◦(O+1) should be the offset into the last physical

block

Page 17: Chapter 11

Answer 11.6.a (Indexed)Answer 11.6.a (Indexed)

Indexed allocation:◦B = L / 512◦O = L modulus 512◦At the beginning, we need to load the index

block from disk◦The physical address is stored at in the index

block B.◦O is the offset into the physical block pointed to

by index block B.

Page 18: Chapter 11

Exercise 11.6.bExercise 11.6.b

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?

Page 19: Chapter 11

Answer 11.6.bAnswer 11.6.b

Contiguous:◦1 physical block

Linked:◦4 physical blocks

Indexed:◦2 physical blocks