michael
michael

Reputation: 61

File-system indexed allocation: inode

I was wondering if someone could double check my answers to the following question. I'm uncertain if I'm understanding single indirect blocks and double indirect blocks correctly.

A disk block is 2KB and indexed allocation is used. An inode for a file is 128 bytes long, 32 bytes are used for status info. The remaining 96 bytes are used for index entries - 4 bytes per entry.

What is the maximum amount of data that can be stored in a file if the following schemes are used?

a. each index entry is a pointer to a direct block

24 pointers x 2 KB = 48 KB

b. each index entry is a pointer to a single indirect block

2 KB / 4 pointers = 512 pointers = 2 MB x 24 = 48 MB

c. the first 22 entries are points to direct blocks, the 23rd entry is a pointer to a single indirect block, and the 24th entry is a pointer to a double indirect block

22 pointers x 2 KB = 44 KB + 2 MB + 2 GB

Upvotes: 1

Views: 2059

Answers (1)

dmeister
dmeister

Reputation: 35654

Homework?

a) Correct b) You have 24 pointers to first level indirect blocks. You can store 512 pointers in each indirect block. Each pointer points to a data block a 2KB.

24 x 512 x 2KB = 24MB

I don't understand where you get your 2MB from?

c) 22 pointers to 2KB blocks:

 22 x 2KB = 44 KB

1 pointer to 512 pointers to 2KB:

1 x 512 x 2KB = 1 MB

1 pointer to 512 pointers each pointing to a block with 512 pointers to 2KB:

1 x 512 x 512 x 2KB = 512 MB

For the development of real filesystems usually something like c) is used. For example ext3 has 12 direct, 1 indirect, 1 double-indirect, and 1 triple-indirect block entries.

Upvotes: 1

Related Questions