• No results found

Main Points. File layout Directory layout

N/A
N/A
Protected

Academic year: 2021

Share "Main Points. File layout Directory layout"

Copied!
35
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

Main Points

• File layout

(3)

File System Design Constraints

• For small files:

– Small blocks for storage efficiency

– Files used together should be stored together

• For large files:

– Contiguous allocation for sequential access – Efficient lookup for random access

• May not know at file creation

(4)

File System Design

• Data structures

– Directories: file name -> file metadata

• Store directories as files

– File metadata: how to find file data blocks – Free map: list of free disk blocks

• How do we organize these data structures?

(5)

Design Challenges

• Index structure

– How do we locate the blocks of a file?

• Index granularity

– What block size do we use?

• Free space

– How do we find unused blocks on disk?

• Locality

– How do we preserve spatial locality?

• Reliability

(6)

File System Design Options

FAT FFS NTFS

Index structure

Linked list Tree

(fixed, assym)

Tree (dynamic)

granularity block block extent

free space allocation

FAT array Bitmap

(fixed location)

Bitmap (file) Locality defragmentation Block groups

+ reserve space

Extents Best fit

(7)
(8)

Microsoft File Allocation Table (FAT)

• Linked list index structure

– Simple, easy to implement

– Still widely used (e.g., thumb drives)

• File table:

– Linear map of all blocks on disk – Each file a linked list of blocks

(9)
(10)

FAT

• Pros:

– Easy to find free block – Easy to append to a file – Easy to delete a file • Cons:

– FAT size

• Should be uploaded in main memory • Limitation to file system size

– Limited metadata and no protection – Fragmentation

• File blocks for a given file may be scattered • Files in the same directory may be scattered • Problem becomes worse as disk fills

(11)

Limitazioni dei file systems FAT

Posto:

- L lunghezza (in bit) degli elementi della FAT

- B la lunghezza (in byte) dei blocchi del disco,

il numero di blocchi indirizzabili è 2L (= capacità del disco, o partizione)

--> la massima estensione del file system è 2L blocchi, ovvero a B* 2L byte.

se ogni elemento occupa N byte (solitamente L è multipla del byte), la FAT occupa complessivamente N*2L byte

Esempio: con N=2 (--> FAT 16): B= 210:

La massima estensione del file system è 216 blocchi, ovvero 226 byte (= 64 Mbyte)

la FAT occupa complessivamente 2* 216 byte= 128 Kbyte

con una memoria paginata e pagine di 1Kbyte, la FAT occupa 128 pagine

dato che gli elementi che descrivono un file possono essere distribuiti su molte pagine diverse, possono verificarsi frequenti errori di pagina quando si percorre un file.

--> Per realizzare file systems più estesi: gli elementi della FAT indirizzano blocchi logici, multipli del blocco fisico del disco.

(12)

• Massima dimensione del File System per diverse ampiezze dei blocchi

Limitazioni dei file systems FAT

(13)

Berkeley UNIX FFS (Fast File System)

• inode table

– Analogous to FAT table

• inode

– Metadata

• File owner, access permissions, access times, …

– Set of 12 data pointers

(14)
(15)

FFS inode

• Metadata

– File owner, access permissions, access times, …

• Set of 12 data pointers

– With 4KB blocks => max size of 48KB files

• Indirect block pointer

– pointer to disk block of data pointers

(16)

FFS inode

• Metadata

– File owner, access permissions, access times, …

• Set of 12 data pointers

– With 4KB blocks => max size of 48KB

• Indirect block pointer

– pointer to disk block of data pointers

– 4KB block size => 1K data blocks => 4MB

• Doubly indirect block pointer

– Doubly indirect block => 1K indirect blocks – 4GB (+ 4MB + 48KB)

(17)

FFS inode

• Metadata

– File owner, access permissions, access times, …

• Set of 12 data pointers

– With 4KB blocks => max size of 48KB

• Indirect block pointer

– pointer to disk block of data pointers – 4KB block size => 1K data blocks => 4MB

• Doubly indirect block pointer

– Doubly indirect block => 1K indirect blocks – 4GB (+ 4MB + 48KB)

• Triply indirect block pointer

– Triply indirect block => 1K doubly indirect blocks – 4TB (+ 4GB + 4MB + 48KB)

(18)
(19)

FFS Asymmetric Tree

• Small files: shallow tree

– Efficient storage for small files

• Large files: deep tree

(20)

FFS Locality

• Block group allocation

– Block group is a set of nearby cylinders

– Files in same directory located in same group – Subdirectories located in different block groups

• inode table spread throughout disk

– inodes, bitmap near file blocks

• First fit allocation

(21)
(22)
(23)
(24)
(25)

FFS

• Pros

– Efficient storage for both small and large files – Locality for both small and large files

– Locality for metadata and data

• Cons

– Inefficient for tiny files (a 1 byte file requires both an inode and a data block)

– Inefficient encoding when file is mostly contiguous on disk (no equivalent to superpages)

– Need to reserve 10-20% of free space to prevent fragmentation

(26)

NTFS

• Master File Table

– Flexible 1KB storage for metadata and data

• Extents

– Block pointers cover runs of blocks – Similar approach in linux (ext4)

– File create can provide hint as to size of file

• Journalling for reliability

(27)
(28)
(29)
(30)
(31)
(32)
(33)
(34)

Directories

• Directories can be files

– Map file name to file number (MFT #, inode num)

• Table of file name -> file number

(35)

References

Related documents

The remainder of the volume - disk blocks allocated to (resource or data forks of) files or available for new files or file extensions.. Category 1 information 1s

Intra-file security uses additional metadata to maintain information about secure segments, allowing blocks of a file to be encrypted and decrypted individually on the client. A

of blocks Link counter Gid Time of deletion Time of modification Time of creation Access time File size Uid Mode Access Control List 10. Linux procfs - process file system • Not a

 Space is allocated to a file as one or more portions (contiguous set of allocated disk blocks). A portion is the logical

• Store the blocks of data, plus local informatin about block location and file identity. • Report back to the name node to list the blocks they

Figure 40.4: File Creation Timeline (Time Increasing Downward) which block to allocate to the file and thus update other structures of the disk accordingly (e.g., the data bitmap

 Volume control block (superblock, master file table) contains volume details..  Total # of blocks, # of free blocks, block size, free block pointers

–  metadata for mapping files to tables –  complex data types (e.g., list, map) –  direct file access, different data formats. •  HiveQL queries are executed