- toc {:toc}
File System Structure
-
Disk๋ ๋ฎ์ด์ฐ๊ธฐ, ๋๋ค ์ ๊ทผ์ ์ ๊ณตํ๋ค.
- I/O ์ ์ก์ ํ๋ ์ด์์ sector๋ก ์ด๋ฃจ์ด์ง block๋จ์๋ก ์ด๋ฃจ์ด์ง๋ค. (512bytes or 4KB)
- ์ผ๋ฐ์ ์ผ๋ก 4KB
-
File system โ secondary storage์ ์์นํ๋ค.
-
Mapping Logical to physical
-
Logical file system ์ metadata ์ ๋ณด๋ฅผ ๋ค๋ฃฌ๋ค.
-
Metadata : ๊ตฌ์กฐ ์ ์ง๋ฅผ ์ํ ์ ๋ณด. ์ค์ ๋ฐ์ดํฐ๊ฐ ์๋ ํ์ผ ์์คํ ๊ตฌ์กฐ๋ฅผ ํฌํจํ๋ค.
-
File Control Block (FCB)๋ ํ์ผ์ ๋ํ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
-
File organization module โ logical block๊ณผ ํ์ผ์ ๋ํ ์ ๋ณด๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
- ๊ฐ ํ์ผ์ logical block โ 0~N ์ผ๋ก ๋ฒํธ ๋งค๊ฒจ์ง๋ค.
- Free-space manager๋ฅผ ํตํด ํ ๋น๋์ง ์์ block์ ์ถ์ ํ๋ค.
-
Basic file system
- logical block ์ฃผ์๋ค์ ๋ํด ๋๋ผ์ด๋ธ์ ๋ช ๋ น์ ๋ด๋ฆฐ๋ค.
- ๋ฉ๋ชจ๋ฆฌ ๋ฒํผ์ ์บ์ฌ๋ฅผ ๊ด๋ฆฌํ๋ค.
- Block I/O subsystem์ด๋ผ ๋ถ๋ฆฐ๋ค.
-
Device driver
- I/O device๋ฅผ ๋ค๋ฃฌ๋ค.
- ๋ฉ์ธ ๋ฉ๋ชจ๋ฆฌ์ ๋์คํฌ ์ฌ์ด ์ ๋ณด๋ฅผ ์ ์กํ๋ค.
- High level ๋ช ๋ น์ด ์ฃผ์ด์ง๊ณ low level instruction์ ์ถ๋ ฅํ๋ค.
Disk Structure
-
Partition : ๋์คํฌ์ ๋ ผ๋ฆฌ์ ๋ถํ ์ ๋ปํ๋ค. โ ๋์คํฌ๋ฅผ ๋ถํ ํ ๊ฒ์ ๋งํจ.
- Raw(w/o file system), Formatted(w/ file system)์ผ๋ก ์ฌ์ฉ๋ ์ ์๋ค.
-
Volumn : ํ๋์ file system์ logical area
- Device directory ๋๋ volume table of contents๋ฅผ ์ด์ฉํด file system ์ ๋ณด๋ฅผ ๊ธฐ๋กํ๋ค.
File System Operation
- Boot control block (per volumn) : OS๋ฅผ bootํ๊ธฐ ์ํ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
- OS๋ฅผ ํฌํจํ volumn์ ๊ฒฝ์ฐ ์ฃผ๋ก volumn์ ์ฒซ block์ boot control block์ด ์ฐจ์งํ๋ค.
- Volumn control block (per volumn) : volumn์ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
- ์ด block ์, free block ์, ํฌ๊ธฐ, ๋ฑ
- Directory structure (per file system) : file์ ๊ด๋ฆฌํ๋ค.
- File control block (per file) : file์ ์ธ๋ถ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
- Mount table : file system mount, mount point ๋ฑ์ ์ ์ฅํ๋ค.
- Directory structure cache : ์ต๊ทผ ์ ๊ทผํ directory ์ ๋ณด๋ฅผ ์ ์ฅํ๋ค.
- System-wide open-file table : ์์คํ ์ ์ฒด์ ์ด๋ฆฐ file์ ์ ๋ณด๋ฅผ ํฌํจํ๋ค.
- Per-process open-file table : system-wide open-file table์์ ํ๋ก์ธ์ค๊ฐ ์ฐ pointer๋ฅผ ํฌํจํ๋ค.
- ํ์ผ open ๊ณผ์
- Open
- ๋์คํฌ์์ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ ธ์จ๋ค.
- ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ์์ ํ์ผ์ ์ ํํ๋ค.
- FCB๋ฅผ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆฐ๋ค.
- ์ฒ์ ์ฌ๋ฆฌ๋ ๊ฒฝ์ฐ system-wide open-file table์ entry๋ฅผ ์ถ๊ฐํ๋ค.
- Per-process open-file table์ ํด๋น ํ์ผ์ system-wide open-file table entry๋ฅผ ๊ฐ๋ฆฌํค๋ pointer๋ฅผ ์ถ๊ฐํ๋ค.
Directory Implementation
- Linear List : Data block์ ๋ํด (file name / pointer) ์ ์ฅ
- ํ๋ก๊ทธ๋๋ฐ ํ๊ธฐ ์ฝ๋ค.
- ์๊ฐ ์์๊ฐ ์๋ค. (์ ํ ๋ณต์ก๋)
- linked list ๋๋ B+ tree ์ด์ฉํด ์ํ๋ฒณ์์ผ๋ก ์ ๋ ฌ ๊ฐ๋ฅ
- Hash Table : hash ๋ฐ์ดํฐ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ง linear list
- Search time์ ๊ฐ์์ํจ๋ค.
- Collision : ํด์ฌ ํจ์์ ์ํด ๋ณํ๋์ ๋ ๊ฐ์ ์์น์ 2๊ฐ์ ํ์ผ์ด ์์นํ๋ ์ํฉ
- ํด๊ฒฐํ๊ธฐ ์ํด ํ๋์ file๋ง ์ ์ฅํ ์ ์๋๋ก ๊ตฌํ โ Collision ๋ฐ์ X
- ๊ฐ์ ๊ฐ์ ๊ฐ์ง๋ฉด linked list๋ก ํ์ผ ์ฐ๊ฒฐ
Contiguous Allocation Method
-
๊ฐ file์ด contiguous block์ ์งํฉ์ผ๋ก ์ ์ ํ๋ค.
-
๊ฐ๋จํ๋ค.
-
(file, Start, Length) ๊ตฌ์กฐ
-
๋ฌธ์ ์
- ๋น์ด์๋ ๊ณต๊ฐ์ ์ฐพ๋ ๊ณผ์ (Free frame ์ฐพ๋ ๊ฒ๊ณผ ๋น์ทํ๋ค. Free disk block ์ฐพ๊ธฐ)
- ๋์ ์ ์ฅ์ ํ ๋น
- External fragmentation
-
โ ๋ณํ
-
์ฒ์์๋ contiguousํ๊ฒ ์ ์ฅ
-
Hole์ด ์๊ฒผ์ ๋ contiguousํ๊ฒ ์ ์ฅํ ํ ์ ์ฅํ์ง ๋ชปํ์ ๋ ๋ค์ hole์์ contiguousํ๊ฒ ์ ์ฅ
Linked Allocation Method
-
๊ฐ file์ด block์ linked list๋ก ๊ตฌ์ฑ๋์ด ์๋ค.
-
Block ์์ ๋ค์ block์ ๋ฒํธ๊ฐ ํฌํจ๋๋ค.
-
(file, Start, End) ๊ตฌ์กฐ
-
์์ถ, External fragmentation ์๋ค.
-
๋ฌธ์ ์
- ์ ๋ขฐ์ฑ์ด ๋ฎ๋ค. ---โ ์ค๊ฐ ์ ๋ณด๊ฐ ์ ์ค๋๋ฉด ๋ค์ block์ ์ ๋ถ ์ ๊ทผ ๋ถ๊ฐ
- Block์ ์ค๊ฐ ์์น๋ฅผ ์๊ธฐ ์ํด์๋ disk seek ์๊ฐ์ด ์ค๋ ๊ฑธ๋ฆฐ๋ค.
-
File Allocation Table (FAT)
- File๋ค์ด ์ฐ๊ฒฐ๋ ๋ฒํธ๋ค์ ์ ์ฅํ๊ณ ์๋ table์ด๋ค.
- Table์ด ๊ฐ block์ ๋ํด ์ฐ๊ฒฐ๋ block number๋ก ์ธ๋ฑ์ฑ๋ ํ๋์ entry๋ง ๊ฐ๋๋ค.
- MS Dos ์์ ์ฌ์ฉ๋๋ค.
Indexed Allocation Method
- ๊ฐ block์ pointer๋ฅผ ์ ์ฅํ๊ณ ์๋ index block๋ฅผ ์ง๋๋ค.
- (file, index block)
Performance of Allocation Methods
-
File access type์ ๋ฐ๋ผ ์ข์ ๋ฐฉ๋ฒ ๋ค๋ฅด๋ค.
- Contiguous โ sequential / random
- Linked โ sequential / not random
-
๋ง๋ค ๋ contiguous or linked๋ฅผ ์ ํํ๋ค.
-
Indexed๊ฐ ๋ ๋ณต์กํ๋ค.
- ํ๋์ block์ ์ฝ์ผ๋ คํด๋ index block์ ์ฝ์ด์ผ ํ๋ฏ๋ก ์ถ๊ฐ ์ฐ์ฐ ๋ฐ์
- โ ์ฌ๋ฌ ๊ฐ ์ฐ์๋ ๋ฌถ์์ผ๋ก ํ ๋นํ๋ค. โ throughput ํฅ์, CPU overhead ๊ฐ์
-
NVM โ disk head ์๊ธฐ ๋๋ฌธ์ ๋ค๋ฅธ ์๊ณ ๋ฆฌ์ฆ ํ์
Free-Space Management
-
์ด์ฉ ๊ฐ๋ฅํ block, cluster๋ฅผ ์ถ์ ํ๋ free-space list๋ฅผ ์ฌ์ฉํ๋ค.
-
Bit vector or bit map (n blocks)
-
block free : 1
-
block occupied : 0
-
word โ bit๋ฅผ ์ผ์ ํ ํฌ๊ธฐ๋ก ๋๋ ๊ฒ
-
(0์ผ๋ก ๊ตฌ์ฑ๋ word) X (word ์์ bit์ ์) + (1์ด ๋์ฌ ๋ ๊น์ง์ bit ์) โ free block
-
Contiguous file์ ์ป๊ธฐ ์ฝ๋ค.
-
Linked List (Free List) : free block์ด linked list๋ก ์ฐ๊ฒฐ๋์ด ์๋ค.
-
Grouping : n ๊ฐ์ free block์ ์ฃผ์๋ฅผ ์ ์ฅํ๋๋ก linked list ๊ตฌ์ฑ
-
Counting : (start addr, length)๋ก countingํด ์ ์ฅ [(0, 2), (6, 2), (14, 3) โฆ]
-
Space Maps
Efficiency and Performance
- Efficiency
- Fragmentation ๋ฐ์ํ๋ฉด ํจ์จ ๊ฐ์
- Metadata ์ฆ๊ฐ โ ์ค์ ๋ฐ์ดํฐ ์ ์ฅ๊ณต๊ฐ ๊ฐ์ โ ํจ์จ ๊ฐ์
- Metadata ํ์์ ์ถ๊ฐ โ ๋น๊ณต๊ฐ ์ฐพ๋ overhead โ ํจ์จ ๊ฐ์
- FCB ๊ณต๊ฐ ๋ฏธ๋ฆฌ ํ ๋น โ ์ ์ฐ๋ฉด ํจ์จ ๊ฐ์
- Performance
- data์ metadata๊ฐ ๊ฐ์ด ์์นํ๋๋ก ์ ์งํด disk๊ฐ ๋ ์์ง์ด๊ฒ ํ๋ค.
- Buffer cache : ์์ฃผ ์ฌ์ฉ๋๋ block์ ๋ํ ๋ฉ์ธ ๋ฉ๋ชจ๋ฆฌ ๊ตฌ์ญ์ ๋ถ๋ฆฌํ๋ค.
- Synchronous : ๋ฐ๋ก disk์ ์์ฑ
- Asynchronous : buffer์ ๋๋๊ณ ๋์ค์ disk์ ์์ฑ (๋ ํํ ๋ฐฉ์)
- ๋ชจ์๋ค๊ฐ ์์ฑํด์ ๋ ๋น ๋ฅด๋ค. ๊ณ์ ์ ๊ทผํ ์๊ฐ์ ์ค์ด๊ธฐ ๋๋ฌธ.
- Free-behind / read-ahead : sequential access์ ์ต์ ํ
- Read๊ฐ ์ฃผ๋ก write๋ณด๋ค ๋๋ฆฌ๋ค.
- read โ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์์ ์ฝ์ด์ผ ํ๋ค.
- write โ ๋ฐ์ดํฐ buffer์ ์ ์ฅํด๋๋ค๊ฐ ๋ฎ์ด์์ฐ๋ฉด ๋๋ค.
Page Cache
- Virtual memory, address๋ฅผ ์ด๋ํด page๋ฅผ ์ ์ฅํ๋ค.
- ๋์คํฌ๋ก์ ์ ๊ทผ๋ณด๋ค cache ์ ๊ทผ์ด ๋ ๋น ๋ฅด๊ธฐ ๋๋ฌธ์ ์ฌ์ฉํ๋ค.
- ํ ๋ฒ ์ฝ์ ํ์ผ์ ๋ด์ฉ์ page cache ์์ญ์ ์ ์ฅ์์ผ ๋๊ณ ์ฌ์ฉํ๋ ๋ฐฉ์ โ ๋์คํฌ ์ ๊ทผ ๊ฐ์
- Memory-mapped I/O์ด page cache ์ด์ฉ
- File system์ routine I/O๋ buffer cache ์ด์ฉ
Unified Buffer Cache
- ๋๋ถ๋ถ์ block์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ณ ์๋ block์ด๋ค.
- โ ํ์ผ์ ๋ด์ฉ์ด buffer cache์ ์กด์ฌ
- โ ๋ฐ๋ผ์ buffer cache์๋ ์กด์ฌํ๊ณ page cache์๋ ์กด์ฌํ๋ ์ด์ค cache๋ฌธ์ ๋ฐ์
- โ ํด๊ฒฐํ๊ธฐ ์ํด ๊ฐ์ page cache๋ฅผ ์ฌ์ฉํ๋ค.
Recovery
- Consistency checking : ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ์์ ๋ฐ์ดํฐ๊ฐ ๋์ผํ์ง ํ์ธ / ๋์ผํ์ง ์์ผ๋ฉด ๋ณต๊ตฌ
- Back up ํด ๋๊ณ ๋ณต๊ตฌํ๋ค.
Log Structured File Systems
-
Log structured(or journaling) : ํ์ผ์ ๋ฉํ๋ฐ์ดํฐ ์ ๋ฐ์ดํธ๋ฅผ ๊ธฐ๋กํ๋ค.
-
๋ชจ๋ ๊ฑฐ๋๋ ์์ฐจ์ ์ผ๋ก log์ ์จ์ง๋ค.
-
๊ฑฐ๋๊ฐ ๊ฐ๋ device๋ disk section์ ์จ์ง๋ ๊ฒฝ์ฐ ์๋ค.
-
log๋ asynchronousํ๊ฒ ํ์ผ ์์คํ ๊ตฌ์กฐ์ ๋ฐ์๋๋ค.
- log๊ธฐ๋ก๋ง ๋๊ณ disk์ ๋ฐ์๋์ง ์๋ ๊ฒฝ์ฐ๊ฐ ์๊ธธ ์ ์๋ค.
-
ํ์ผ ์์คํ ์ด ์ถฉ๋์ด ๋๋ฉด log์์ ๋จ์์๋ ๋ชจ๋ ๊ฑฐ๋๋ ์ฒ๋ฆฌ๋์ด์ผ ํ๋ค.