11
SISTIM OPERASI (Operating System) IKI-20230 Johny Moningka (moningka@cs.ui.ac.id)
Fakultas Ilmu Komputer Universitas Indonesia Semester 2000/2001
File-System Implementation
n n n
Review
n
Capacity management:
Strategi untuk mendukung memori hirarkis: kapan data harus di migrasi dari storage cost/byte mahal ke storage cost/byte lebih murah => Backup dan pengarsipan. Quota dan alokasi disk high speed untuk aplikasi penting.
Availability:
Termasuk solusi RAID, network restore etc. Bad blocks (disk)? Hardware or software recovery.
File System JM -2000/v1.1/3
File-System Structure
n
File structure
n
Isi file: kumpulan byte yang berhubungan dengan informasi. Logical storage unit: urutan byte, dengan akses address secara logical (offset:1 s/d sizeof file). Data file disimpan dalam blok (kelipatan besarnya sector).
Logical address disk: urutan blok data.
Implementasi:
Mengurangi overhead mendapatkan data (seek, rotation). Manajemen blok yang bebas (free list).
File System JM -2000/v1.1/4
Disk Management
n
n n
Manajemen free list dari blok storage. Manajemen volume, partisi disk.
Workloads
n
Sequential access: data besar dan berurut. Random access: data kecil dan lokasi blok tidak berurut. Umumnya file ukurannya kecil (pengamatan). Sebagian dari blok disk digunakan oleh file yang besar (porsi terbesar). Jadi perlu dukungan untuk kedua model akses : akses random (file kecil yang banyak) dan sequential (file yang besar dan aktifitas tinggi) => trade off yang sulit dipenuhi.
File System JM -2000/v1.1/6
Contiguous Allocation
n n n
Setiap file menempati sekumpulan blok yang contiguous (sinambung) pada disk. Umumnya max. besar file telah tetap (user menentukan). Pros:
n n
Manajemen blok yang dialokasikan sederhana. Informasi awal lokasi nomor blok dan panjang blok yang dialokasikan. Space terbuang percuma, belum tentu sebesar data/isi file (dynamic storage-allocation problem). Sulit memperbesar (demand, grow) dari file.
Cons:
n n
Simple mechanism
n
When creating a file, make the user specify pre-specify its length and allocate all space at once File descriptor contents: location and size Pro: simple, fast access, both sequential and random. Masalah: fragementasi => perlu penggabungan blok yang kecil menjadi contiguous blok besar what happens if file c needs 2 blok???
n n
file a (base=1,len=3)
file b (base=5,len=2)
File System JM -2000/v1.1/8
Simple mechanism
n
file a (base=1,len=3)
Linked files
n
how do you find the last block in a? file a (base=1) file b (base=5) n pro: easy dynamic growth & sequential access, no fragmentation n con? n Examples (sort-of): Alto, TOPS-10, DOS FAT
Linked Allocation
n
Mekanisme pengurutan blok yang dialokasikan untuk suatu file. Blok yang dialokasikan dapat tersebar (scattered):
Tidak perlu fixed allocation => menjawab dynamic allocation problem.
n n
File descriptor: a pointer to files first block Setiap blok menyimpan pointer yang menunjuk ke blok yang berikut.
pointer ke alokasi blok berikutnya block =
Data
Linked List
Allocate as needed, link together; e.g., file starts at block 9 Bagaimana melakukan random access? Follow the link, overhead besar (read blok disk; linked list) => banyak seek)
FAT cukup kecil dapat disimpan cache disk => akses tanpa melakukan seek.
File System JM -2000/v1.1/13
FAT discussion
n
Berapa maksimum ukuran FAT? Jika 512 byte per blok, whats the maximum size of FS yang dapat dikenal? Solusi sederhana: memperbesar ukuran blok.
FAT menempati satu area tertentu (contiguous sector) => what happen if corrupt? Buat duplikat FAT on disk. Fixed location on disk: FAT (opt) FAT root dir
Indexed files
n
Implementasi: array pointer => max. ukuran file yang dapat ditampung oleh array tersebut. Create file: alokasikan blok pertama untuk menyimpan array pointer, blok akan diberikan on demand oleh user (dynamic).
file a
n
file b
Pro: mendukung sequential access dan random (read the first block, and scan the array pointer).
File System JM -2000/v1.1/15
Indexed files
n
idle
2^32 file size
n n
4K blocks
Ukuran file kecil = lots of unused entries Mendukung file besar? table array menempati banyak blok yang contiguous.
Multi-leve indexed
Pembagian struktur index hirarkis: region dengan index array (1 st level), menunjuk ke index array (2 nd level) dst. Masalah: akses ke index array => overhead
idle
outer- index
index table
file
10
UNIX: inodes
n
Besarnya array inode ditentuk saat disk di format (initialized) dan menempati lokasi tertentu (awal atau tersebar). Array inode tidak dapat diubah (kecuali melakuk reformat).
File system menyimpan (direktori) index yang menunjuk ke i-node (OS Unix menyebut i-number). Saat file dibuka, maka I-number diambil dari direktori dan i-node disimpan ke memori (bagian dari referensi PCB proses tsb).
File System JM -2000/v1.1/22
11
n n n
read root directory (blk 10) refcnt=1 14 0 0 lookup a (blk 12); read lookup inode for b.c (13); read int main() {
Gunakan inode mencari byte 4 (blksize = 4KB, so File System JM -2000/v1.1/23 offset = 0 gives blk 14); read
Block: OS view
n
Sistim lama (disk kecil): 512 Bytes => saat ini 4 KB. Contoh: Unix (V7) => Unix 4.2 BSD (Berkeley)
Analisa performance response time FS, meningkat 4 x lebih cepat (sequential access). Why? Makin kecil ukuran block => makin banyak blok yang yang harus ditransfer atau makin banyak I/O operation yang harus dilakukan. Setiap I/O operation: faktor waktu latency sampai data dapat ditransfer.
12
Free-Space Management
n
678
0 1
bit[ i] =
Free list: model pembagian daftar blok yang bebas dalam linked list. n Pointer (next) disimpan pada blok yang bebas. n Umumnya tidak satu linked list tunggal, tapi di pilah dalam sekumpulan linked list.
File System JM -2000/v1.1/25
Need to protect:
n n
13