Upload
krissapat
View
849
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
การใช้�งานระบบแฟ้ มการใช้�งานระบบแฟ้ มFile-System Implementation
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 2
Chapter 12: File System Implementation
File System Structure File System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance Recovery Log-Structured File Systems NFS
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 3
โครงสร�างระบบแฟ้ มFile-System Structure
File structure หน�วยของหน�วยเก�บเช้�งตรรกะ (Logical storage unit) หน�วยรวมของข�อม�ลที่��เก��ยวข�องก�น
ระบบแฟ้ มเก�บอย��บนหน�วยเก�บรอง-ดิ�สก# (secondary storage-disks)
ระบบแฟ้ มถู�กจั�ดิเก�บเป็'นเลเยอร# File control block – โครงสร�างของหน�วยเก�บป็ระกอบดิ�วย
ข�อม�ลเก��ยวก�บแฟ้ ม
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 4
Layered File System
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 5
A Typical File Control Block
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 6
โครงสร�างระบบแฟ้ มในหน"วิยควิามจำ$าIn-Memory File System
Structures ภาพต�อไป็น�-ใช้�แสดิงถู.งโครงสร�างที่��จั/าเป็'นของระบบแฟ้ มที่��จั�ดิ
เตร�ยมไว�โดิย OS
Figure 12-3(a) อ�างถู.งการเป็0ดิแฟ้ ม
Figure 12-3(b) อ�างถู.งการอ�านแฟ้ ม
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 7
In-Memory File System Structures
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 8
ระบบแฟ้ มเสม%อนVirtual File Systems
Virtual File Systems (VFS) เป็'นว�ธี�การใช้�งานระบบแฟ้ มเช้�งว�ตถู2
VFS อน2ญาตให�ระบบที่��เหม4อนก�นสามารถูเร�ยกส�วนต�อป็ระสาน (Application Program Interface-API) ที่��ใช้�ส/าหร�บระบบแฟ้ มป็ระเภที่ที่��แตกต�างก�นไดิ�
API ถู4อเป็'นส�วนต�อป็ระสานแบบระบบแฟ้ มเสม4อน (VFS interface), มากกว�าจัะระบ2ให�เป็'นระบบแฟ้ มช้น�ดิใดิๆ
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 9
Schematic View of Virtual File System
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 10
Directory Implementation
รายการแบบเส�นตรง (Linear list ) ของช้4�อแฟ้ มพร�อมพอยน#เตอร#ที่��ช้�-ไป็ย�งบล�อกข�อม�ล (data blocks) โป็รแกรมอย�างง�าย ใช้�เวลาในการ execute
ตารางแฮช้ (Hash Table) – รยการแบบเส�นตรงพร�อมโครงสร�างข�อม�ลแบบแฮช้ (hash data structure) ลดิเวลาค�นหา directory การช้นก�น (collisions) – สถูานการณ์#ที่�� 2 แฟ้ ม ม�ช้4�อแฮช้อย��
ต/าแหน�งเดิ�ยวก�น ขนาดิคงที่�� (fixed size)
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 11
วิ�ธี(การจำ�ดสรรAllocation Methods
ว�ธี�การจั�ดิสรร หมายถู.ง บล�อกของดิ�สก#จัะถู�กจั�ดิสรรส/าหร�บแฟ้ มต�างๆ ไดิ�อย�างไร
การจั�ดิสรรแบบต�อเน4�อง (Contiguous allocation)
การจั�ดิสรรแบบเช้4�อมโยง (Linked allocation)
การจั�ดิสรรแบบดิ�ช้น� (Indexed allocation)
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 12
การจำ�ดสรรแบบติ"อเน%*องContiguous Allocation
แต�ละแฟ้ มจัะอย��ก�นเป็'นช้2ดิของบล�อกที่��เร�ยงต�อเน4�องก�นบนดิ�สก#
ง�าย – ต�องการเพ�ยงบล�อกต/าแหน�งเร��มต�น (block #) และความยาวของบล�อก (number of blocks) เที่�าน�-น
การเข�าถู.งแบบส2�ม (Random access)
จัะม�พ4-นที่��ใช้�การไม�ไดิ�มาก เก�ดิป็8ญหาการจั�ดิสรรหน�วยเก�บแบบพลว�ต (dynamic storage-allocation problem)
แฟ้ มไม�สามารถูขยายไดิ� (Files cannot grow)
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 13
Contiguous Allocation of Disk Space
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 14
ระบบขยายExtent-Based Systems
ม�ระบบแฟ้ มใหม�ๆ จั/านวนมาก (I.e. Veritas File System) ใช้�โครงสร�างการจั�ดิสรรแบบต�อเน4�อง
Extent-based file systems จั�ดิสรรบล�อกของดิ�สก#แบบขยาย (extents)
ส�วนขยาย (extent) ค4อขยายบล�อกของดิ�สก#แบบต�อเน4�อง โดิยส�วนที่��ถู�กขยายค4อการจั�ดิสรรแฟ้ ม แฟ้ มจัะป็ระกอบดิ�วยส�วนขยาย (extents ) จั/านวนหน.�งหร4อมากกว�าหน.�ง
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 15
การจำ�ดสรรแบบเช้%*อมโยงLinked Allocation
แต�ละแฟ้ มจัะม�รายการเช้4�อมโยง (linked list) ของบล�อกดิ�สก# โดิยที่��บล�อกอาจัเป็'นการแบ�งส�วนใดิๆก�ไดิ�บนดิ�สก#
pointerblock =
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 16
Linked Allocation (Cont.)
ง�าย– ต�องการเพ�ยงที่��อย��เร��มต�น (starting address) ระบบการจั�ดิการพ4-นที่��ว�าง (Free-space management
system) – ไม�ม�พ4-นที่��ว�างโดิยเป็ล�าป็ระโยช้น# ไม�รองร�บการเข�าแบบส2�ม (random access) ต�องแป็ลงส�ง (Mapping)
บล�อกที่��เข�าถู.งค4อ Qth block ในสายโยงใยของบล�อกที่��แที่นแฟ้ มDisplacement into block = R + 1
File-allocation table (FAT) – การจั�ดิสรรพ4-นที่��ว�างดิ�สก# (disk-space allocation) ดิ�งกล�าวน�-ม�ใช้�โดิย MS-DOS และ OS/2.
LA/511Q
R
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 17
Linked Allocation
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 18
File-Allocation Table
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 19
การจำ�ดสรรแบบด�ช้น(Indexed Allocation
น/า pointers ที่�-งหมดิเข�าไป็เก�บไว�ดิ�วยก�นใน index block. ม2มมองเช้�งตรรกะ (Logical view)
index table
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 20
Example of Indexed Allocation
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 21
Indexed Allocation (Cont.)
ต�องม�ตารางดิ�ช้น� (index table) เข�าถู.งแบบส2�ม (Random access) การเข�าถู.งแบบพลว�ต (Dynamic access) โดิยไม�ม�การแตก
กระจัายแบบภายนอก (external fragmentation), แต�จัะม�overhead ของ index block
การ Mapping จัากเช้�งตรรกะเป็'นเช้�งกายภาพในแฟ้ มหน.�งๆ ส�งส2ดิขนาดิไม�เก�น 256K words และ block size of 512 words ต�องใช้�เพ�ยง 1 block ส/าหร�บ index table
LA/512Q
R
Q = displacement into index tableR = displacement into block
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 22
Indexed Allocation – Mapping (Cont.)
Mapping จัากเช้�งตรรกะเป็'นเช้�งกายภาพในแฟ้ มหน.�งๆ น�-นไม�ผู�กต�ดิก�บความยาว (block size of 512 words)
โครงสร�างแบบโยง (Linked scheme) – Link blocks ของ index table (ไม�จั/าก�ดิขนาดิ)
LA / (512 x 511)Q1
R1
Q1 = block of index tableR1 is used as follows:
R1 / 512Q2
R2
Q2 = displacement into block of index tableR2 displacement into block of file:
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 23
Indexed Allocation – Mapping (Cont.)
ดิ�ช้น�แบบ 2 ระดิ�บ (Two-level index) ขนาดิไฟ้ล#ส�งส2ดิค4อ 5123
LA / (512 x 512)Q1
R1
Q1 = displacement into outer-indexR1 is used as follows:
R1 / 512Q2
R2
Q2 = displacement into block of index tableR2 displacement into block of file:
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 24
Indexed Allocation – Mapping (Cont.)
outer-index
index table file
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 25
Combined Scheme: UNIX (4K bytes per block)
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 26
การจำ�ดการพ%,นที่(*วิ"างFree-Space Management
Bit vector (n blocks)
…
0 1 2 n-1
bit[i] = 0 block[i] free
1 block[i] occupied
Block number calculation
(number of bits per word) *(number of 0-value words) +offset of first 1 bit
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 27
Free-Space Management (Cont.)
Bit map ต�องการพ4-นที่��เพ��มเต�ม Example:block size = 212 bytesdisk size = 230 bytes (1 gigabyte)n = 230/212 = 218 bits (or 32K bytes)
ง�ายต�อแฟ้ มแบบต�อเน4�อง Linked list (free list)
หาพ4-นที่��ต�อเน4�องไดิ�ยาก ไม�ม�พ4-นที่��ไร�ป็ระโยช้น#
Grouping Counting
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 28
Free-Space Management (Cont.)
ต�องม�การป็ องก�น (protect) Pointer ไป็ย�งรายการที่��ว�าง (free list) Bit map
ต�องเก�บบนดิ�สก# ส/าเนาบนหน�วยความจั/าและบนดิ�สก#อาจัคนละช้2ดิ ไม�ย�นยอมให�เก�ดิสถูานการณ์#ส/าหร�บ block[i] โดิยที่�� bit[i] = 1
ในหน�วยความจั/า และ bit[i] = 0 บนดิ�สก# Solution:
Set bit[i] = 1 in disk. Allocate block[i] Set bit[i] = 1 in memory
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 29
Linked Free Space List on Disk
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 30
ควิามสะดวิกและประส�ที่ธี�ภาพEfficiency and Performance
ความสะดิวก (Efficiency) ข.-นอย��ก�บ: อ�ลกอร�ธี.มในการจั�ดิสรรดิ�สก#และไดิเรกที่อร� ช้น�ดิของข�อม�ลที่��เก�บในรายการไดิเรกที่อรของแฟ้ ม (file’s
directory entry)
ป็ระส�ที่ธี�ภาพ (Performance) ดิ�สก#แคช้ (disk cache) – แยกส�วนของหน�วยความจั/าส/าหร�บบล�อก
ที่��ถู�กใช้�งานบ�อย free-behind and read-ahead – เป็'นเที่คน�คในการเข�าแบบ
ล/าดิ�บไดิ�เหมาะที่��ส2ดิ (optimize sequential access) การป็ร�บป็ร2งป็ระส�ที่ธี�ภาพของพ�ซี�โดิยสร�าง dedicating section
ของหน�วยความจั/าเหม4อนก�บดิ�สก#เสม4อน หร4อแรมดิ�สก# (virtual disk, or RAM disk)
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 31
Various Disk-Caching Locations
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 32
Page Cache
เพจำแคช้ (page cache) ใช้�มากกว�าบล�อกดิ�สก#โดิยใช้�เที่คน�คvirtual memory
Memory-mapped I/O ใช้� page cache
Routine I/O ผู�าน file system ใช้� buffer (disk) cache
จัะน/าไป็ส��ภาพในหน�าถู�ดิไป็
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 33
I/O Without a Unified Buffer Cache
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 34
Unified Buffer Cache
A unified buffer cache ใช้�เพจัแคช้เดิ�ยวก�นส/าหร�บเป็'นแคช้ที่�-งหน�วยความจั/า memory-mapped pages และ ordinary file system I/O
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 35
I/O Using a Unified Buffer Cache
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 36
การก/�ค%นRecovery
การตรวจัสอบความสอดิคล�องก�น (Consistency checking) – เป็ร�ยบเที่�ยบข�อม�ลในโครงสร�างไดิเรกที่อร�ดิ�วยบล�อกข�อม�ลบนดิ�สก# และพยายามแก�ไขความไม�สอดิคล�องก�น
ใช้� system programs ในการ back up ส/ารองข�อม�ลจัากดิ�สก# ไป็ย�งอ2ป็กรณ์#หน�วยเก�บอ4�นๆ (floppy disk, magnetic tape).
ก��แฟ้ มหร4อดิ�สก#ที่��เส�ยหาย โดิยเร�ยกค4น restoring ข�อม�ลจัากระบบส/ารอง
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 37
Log Structured File Systems
Log structured (หร4อ journaling) ที่/าการบ�นที่.กระบบแฟ้ มที่��ถู�กป็ร�บป็ร2งแต�ละคร�-งไป็ย�งระบบแฟ้ มในล�กษณ์ะของธี0รกรรม (transaction)
ที่2กธี2รกรรมจัะถู�กเข�ยนลงบน log ธี2รกรรมหน.�งๆ จัะบ�นที่.กว�าส$าเร1จำ (committed) หล�งจัากที่��ถู�กเข�ยนบน log เสร�จัแล�ว อย�างไรก�ตาม file system อาจัป็ร�บป็ร2งย�งไม�แล�วเสร�จัก�ไดิ�
ธี2รกรรมใน log เป็'นถู�กเข�ยนแบบไม�พร�อมก�น (asynchronously written) บน file system เม4�อ file system ถู�กแก�ไข ธี2รกรรมก�จัะถู�กลบออกจัาก log
ถู�าระบบแฟ้ มล�ม (crashes ) ธี2รกรรมที่��ย�งเหล4ออย��ใน log จัต�องย�งคงใช้�การต�อไดิ�
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 38
The Sun Network File System (NFS)
An implementation and a specification of a software system for accessing remote files across LANs (or WANs).
The implementation is part of the Solaris and SunOS operating systems running on Sun workstations using an unreliable datagram protocol (UDP/IP protocol and Ethernet.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 39
NFS (Cont.)
Interconnected workstations viewed as a set of independent machines with independent file systems, which allows sharing among these file systems in a transparent manner. A remote directory is mounted over a local file system
directory. The mounted directory looks like an integral subtree of the local file system, replacing the subtree descending from the local directory.
Specification of the remote directory for the mount operation is nontransparent; the host name of the remote directory has to be provided. Files in the remote directory can then be accessed in a transparent manner.
Subject to access-rights accreditation, potentially any file system (or directory within a file system), can be mounted remotely on top of any local directory.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 40
NFS (Cont.)
NFS is designed to operate in a heterogeneous environment of different machines, operating systems, and network architectures; the NFS specifications independent of these media.
This independence is achieved through the use of RPC primitives built on top of an External Data Representation (XDR) protocol used between two implementation-independent interfaces.
The NFS specification distinguishes between the services provided by a mount mechanism and the actual remote-file-access services.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 41
Three Independent File Systems
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 42
Mounting in NFS
Mounts Cascading mounts
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 43
NFS Mount Protocol Establishes initial logical connection between server and
client. Mount operation includes name of remote directory to
be mounted and name of server machine storing it. Mount request is mapped to corresponding RPC and
forwarded to mount server running on server machine. Export list – specifies local file systems that server exports
for mounting, along with names of machines that are permitted to mount them.
Following a mount request that conforms to its export list, the server returns a file handle—a key for further accesses.
File handle – a file-system identifier, and an inode number to identify the mounted directory within the exported file system.
The mount operation changes only the user’s view and does not affect the server side.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 44
NFS Protocol
Provides a set of remote procedure calls for remote file operations. The procedures support the following operations: searching for a file within a directory reading a set of directory entries manipulating links and directories accessing file attributes reading and writing files
NFS servers are stateless; each request has to provide a full set of arguments.
Modified data must be committed to the server’s disk before results are returned to the client (lose advantages of caching).
The NFS protocol does not provide concurrency-control mechanisms.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 45
Three Major Layers of NFS Architecture
UNIX file-system interface (based on the open, read, write, and close calls, and file descriptors).
Virtual File System (VFS) layer – distinguishes local files from remote ones, and local files are further distinguished according to their file-system types. The VFS activates file-system-specific operations to
handle local requests according to their file-system types.
Calls the NFS protocol procedures for remote requests.
NFS service layer – bottom layer of the architecture; implements the NFS protocol.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 46
Schematic View of NFS Architecture
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 47
NFS Path-Name Translation
Performed by breaking the path into component names and performing a separate NFS lookup call for every pair of component name and directory vnode.
To make lookup faster, a directory name lookup cache on the client’s side holds the vnodes for remote directory names.
วิ�เช้ษฐ์� พลายมาศ | ระบบปฏิ�บ�ติ�การ (OS: Operating Systems) | การใช้�งานระบบแฟ้ ม (File-System Implementation) | 48
NFS Remote Operations
Nearly one-to-one correspondence between regular UNIX system calls and the NFS protocol RPCs (except opening and closing files).
NFS adheres to the remote-service paradigm, but employs buffering and caching techniques for the sake of performance.
File-blocks cache – when a file is opened, the kernel checks with the remote server whether to fetch or revalidate the cached attributes. Cached file blocks are used only if the corresponding cached attributes are up to date.
File-attribute cache – the attribute cache is updated whenever new attributes arrive from the server.
Clients do not free delayed-write blocks until the server confirms that the data have been written to disk.