how inodes work

31
inodes explained Tutorial 3 - CSCI212 by: Roman Tarnavski

Upload: roman-tarnavski

Post on 02-Jun-2015

6.117 views

Category:

Education


2 download

DESCRIPTION

One of the tutorials I gave at University of Wollongong on inodes. Describes direct, single, double and triple linking, and how that all ties together with addressable space.

TRANSCRIPT

Page 2: How inodes Work

Data Blocks

A file system contains ‘blocks’ which hold data called inodes. A inode describes a single file in the file system. Typical information described includes, ownership, modification times, size and permissions. We call this information meta-data.

Source: CSCI212 Lecture Notesby: Daniel Saffioti

Page 3: How inodes Work

Data Blocks

Data Blocks

The remainder of the file system (larger proportion) contains data blocks. These store the contents of files.

Source: CSCI212 Lecture Notesby: Daniel Saffioti

Page 4: How inodes Work

Source: CSCI212 Lecture Notesby: Daniel Saffioti

Page 5: How inodes Work

Your typical inode

Direct Blocks

Single

Double

Triple

Mode

Permissions

Size

Timestamps

Page 6: How inodes Work

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Single

Double

Triple

Data Block 1

Data Block 2

Data Block 3

.

.

.

Page 7: How inodes Work

SingleDirect

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Single

Double

Triple

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Page 8: How inodes Work

Double

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Single

Double

Triple

Page 9: How inodes Work

TripleAddress 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Single

Double

Triple

Page 10: How inodes Work

All Together?

Page 11: How inodes Work

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Direct

Single

Double

Triple

Data Block 1

Data Block 2

Data Block 3

.

.

.

Address 1

Address 2

Address 2048

.

.

.

Data Block 1

Data Block 2

Data Block 2048

Page 12: How inodes Work

Maximum Size of Direct Blocks

Page 13: How inodes Work

Maximum Size of Direct Blocks

Where did the 2048 Addresses come from?

Page 14: How inodes Work

Maximum Size of Direct Blocks

Where did the 2048 Addresses come from?

Assuming 32-bit architectures

Page 15: How inodes Work

Maximum Size of Direct Blocks

Where did the 2048 Addresses come from?

Assuming 32-bit architectures

32-bit = 4 bytes (32 / 8)

Page 16: How inodes Work

Maximum Size of Direct Blocks

Where did the 2048 Addresses come from?

Assuming 32-bit architectures

32-bit = 4 bytes (32 / 8)

Thus 8192 [block size] / 4 [bytes per addressable block]

Page 17: How inodes Work

Maximum Size of Direct Blocks

Where did the 2048 Addresses come from?

Assuming 32-bit architectures

32-bit = 4 bytes (32 / 8)

Thus 8192 [block size] / 4 [bytes per addressable block]

= 2048 Addressable Blocks

Page 18: How inodes Work

Questions

What is the maximum possible file size that can be represented via direct data blocks?

Page 19: How inodes Work

Maximum Size of Direct Blocks

= 8192 x 12 = 98,304 bytes = 96Kb

block sizeblocks

Page 20: How inodes Work

Maximum FileSize using First-Indirect Linking

Page 21: How inodes Work

Maximum FileSize using First-Indirect Linking

Direct: 12 blocks @ 8192 bytes (12 x 8192)

Page 22: How inodes Work

Maximum FileSize using First-Indirect Linking

Direct: 12 blocks @ 8192 bytes (12 x 8192)

=96Kb

Page 23: How inodes Work

Maximum FileSize using First-Indirect Linking

Direct: 12 blocks @ 8192 bytes (12 x 8192)

=96Kb

Indirect: 2048 @ 8192 (2048 x 8192) = 16,384 Kb = 16,480 [Inclusive of Direct] = 16.09Mb

Page 24: How inodes Work

Maximum using Double Indirect

16,875,520 x 2048 addressable blocks

= 34,561,064,960 bytes

= 32,960 Mbytes

Page 25: How inodes Work

Maximum Filesize[direct + single + double + triple]

2048 x 32.1875Gb

= 64.375 Tb

Page 26: How inodes Work

Overhead

Page 27: How inodes Work

Overhead

Wish to store: 8,437,760 bytes

Page 28: How inodes Work

Overhead

Wish to store: 8,437,760 bytes

8437760 / 8192 [bytes per block]

= 1030 blocks x 4 bytes [per address]

BUT

Page 29: How inodes Work

Overhead

Wish to store: 8,437,760 bytes

8437760 / 8192 [bytes per block]

= 1030 blocks x 4 bytes [per address]

BUT

12 Blocks are stored directly

Page 30: How inodes Work

Overhead

Wish to store: 8,437,760 bytes

8437760 / 8192 [bytes per block]

= 1030 blocks x 4 bytes [per address]

BUT

12 Blocks are stored directly

Hence we only have 1018 blocks

Page 31: How inodes Work

Overhead

Wish to store: 8,437,760 bytes

8437760 / 8192 [bytes per block]

= 1030 blocks x 4 bytes [per address]

BUT

12 Blocks are stored directly

Hence we only have 1018 blocks

1018 x 4 bytes = 4072 bytes = 3.98Kbytes