การใช้งานระบบแฟ้ม File-System Implementation

Slides:



Advertisements
งานนำเสนอที่คล้ายกัน
Bansomdej Chaopraya Rajabhat University
Advertisements

การซ้อนทับกัน และคลื่นนิ่ง
แนวทางการรายงานผลการปฏิบัติราชการโดยผ่านระบบเครือข่ายอินเตอร์เน็ต
ระบบสารสนเทศแผนงานบำรุงทาง
สภาวะแวดล้อมในขณะโปรแกรมทำงาน
Software คือ ชุดคำสั่งหรือ ขั้นตอนการทำงานของคอมพิวเตอร์
Stack.
Introduction Newsgroups Newsgroup Names Major Newsgroup Categories Newsreaders Reading Newsgroup Articles Posting Articles Cross - Posting.
Security and Integrity
การจัดการหน่วยความจำ Memory Management
การจัดการระบบแฟ้ม File-System Management
การสืบค้นข้อมูลจาก Web OPAC
การจัดการอุปกรณ์รับ และแสดงผล
หลักการทำงานของคอมพิวเตอร์
Lecture no. 10 Files System
ระบบเครือข่ายคอมพิวเตอร์
ASP:ACCESS Database.
ASP:ACCESS Database.
Network programming Asst. Prof. Dr. Choopan Rattanapoka
โครงสร้างการทำงานของ OS
แนะนำรายวิชา ระบบปฏิบัติการ ภาคเรียนที่ 1/2557
Millennium : Import-Export Step by Step
การสืบค้นข้อมูลจาก Web OPAC
Functional components of a computer
ให้ประหยัดการใช้หน่วยความจำ (space) ด้วยความรวดเร็ว (time)
Introduction to Cache Memory Systems
Chapter 2 Database systems Architecture
สถาปัตยกรรมของระบบฐานข้อมูล
Kampol chanchoengpan it สถาปัตยกรรมคอมพิวเตอร์ Arithmetic and Logic Unit 1.
Install Driver Token Key
โครงสร้างการจัดเก็บข้อมูลเชิงกายภาพ
ความรู้เบื้องต้นเกี่ยวกับระบบฐานข้อมูล
PHP:Hypertext Preprocessor
โครงสร้างข้อมูลแบบคิว
Memory Management ในยุคก่อน
บทที่ 8 File Management. ประเด็นที่ต้องพิจารณา ถ้าต้องการเก็บข้อมูลจะเก็บข้อมูลไว้ที่ไหน สามารถเก็บข้อมูลตรงไปยัง media โดยไม่ต้อง จัดรูปแบบการเก็บได้หรือไม่
บทที่ 8 การจัดเรียงแฟ้มลำดับเชิงดรรชนี
หลักการวิเคราะห์และออกแบบระบบฐานข้อมูล
Charter 7 1 Chapter 7 การจัดการไฟล์ข้อมูล Data File Management.
บทที่ 3 การวิเคราะห์ Analysis.
List ADTs By Pantharee S..
M&E Systems Strengthening Tool
ProQuest Nursing & Allied Health Source
ระบบคอมพิวเตอร์และการประมวลผล
การเขียนโปรแกรม PHP เชื่อมต่อกับ MySQL
วิทยา กรระสี (วท.บ. วิทยาการคอมพิวเตอร์)
Chapter 4 หมายเลขไอพี และการจัดสรร
ลิงค์ลิสต์ (Linked List)
ฟังก์ชัน.
วิชา COSC2202 โครงสร้างข้อมูล (Data Structure)
เกียรติพงษ์ ยอดเยี่ยมแกร
การลงข้อมูลแผนการสอน
“Disk Operating System”
Introduction to Server Services
Chapter 04 Flowchart ผู้สอน อ.ยืนยง กันทะเนตร
School of Information Communication Technology,
Commission Commission on Higher Education Quality Assessment online system CHEQA Updated July 25, 2013
stack #1 ผู้สอน อาจารย์ ยืนยง กันทะเนตร
โครงสร้างข้อมูลแบบ สแตก (stack)
กราฟเบื้องต้น.
Week 13 Basic Algorithm 2 (Searching)
นายรัฐราษฎร์ เกื้อสกุล 1. 2 Disk Password Protection เป็นชุดของโปรแกรมสำหรับปกป้องและจำกัด การเข้าถึง Harddisk สามารถปกป้อง Disk/Partition ด้วย Password,
บทที่ 7. L INKED LISTS ใน class ของ data structure ได้เรียนรู้เกี่ยวกับพื้นฐานของ Linked lists ไปแล้ว เมื่อไรที่ Linked lists ถูกเก็บไว้ที่ DASD จะถูกเรียกว่า.
CC-NUMA (Cache-coherent nonuniform memory access).
1 LAN Implementation Sanchai Yeewiyom School of Information & Communication Technology Naresuan University, Phayao Campus.
การจัดการไฟล์ File Management.
บทที่ 3 การจัดการหน่วยความจำ (Memory Management)
Memory Management Ex. C = A + B A typical instruction-execution cycle
ใบสำเนางานนำเสนอ:

การใช้งานระบบแฟ้ม File-System Implementation นงลักษณ์ พรมทอง และวิเชษฐ์ พลายมาศ การใช้งานระบบแฟ้ม File-System Implementation

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

โครงสร้างระบบแฟ้ม File-System Structure File structure หน่วยของหน่วยเก็บเชิงตรรกะ (Logical storage unit) หน่วยรวมของข้อมูลที่เกี่ยวข้องกัน ระบบแฟ้มเก็บอยู่บนหน่วยเก็บรอง-ดิสก์ (secondary storage-disks) ระบบแฟ้มถูกจัดเก็บเป็นเลเยอร์ File control block – โครงสร้างของหน่วยเก็บประกอบด้วยข้อมูลเกี่ยวกับแฟ้ม

Layered File System

A Typical File Control Block

โครงสร้างระบบแฟ้มในหน่วยความจำ In-Memory File System Structures ภาพต่อไปนี้ใช้แสดงถึงโครงสร้างที่จำเป็นของระบบแฟ้มที่จัดเตรียมไว้โดย OS Figure 12-3(a) อ้างถึงการเปิดแฟ้ม Figure 12-3(b) อ้างถึงการอ่านแฟ้ม

In-Memory File System Structures

ระบบแฟ้มเสมือน Virtual File Systems Virtual File Systems (VFS) เป็นวิธีการใช้งานระบบแฟ้มเชิงวัตถุ VFS อนุญาตให้ระบบที่เหมือนกันสามารถเรียกส่วนต่อประสาน (Application Program Interface-API) ที่ใช้สำหรับระบบแฟ้มประเภทที่แตกต่างกันได้ API ถือเป็นส่วนต่อประสานแบบระบบแฟ้มเสมือน (VFS interface), มากกว่าจะระบุให้เป็นระบบแฟ้มชนิดใดๆ

Schematic View of Virtual File System

Directory Implementation รายการแบบเส้นตรง (Linear list) ของชื่อแฟ้มพร้อมพอยน์เตอร์ที่ชี้ไปยังบล็อกข้อมูล (data blocks) โปรแกรมอย่างง่าย ใช้เวลาในการ execute ตารางแฮช (Hash Table) – รยการแบบเส้นตรงพร้อมโครงสร้างข้อมูลแบบแฮช (hash data structure) ลดเวลาค้นหา directory การชนกัน (collisions) – สถานการณ์ที่ 2 แฟ้ม มีชื่อแฮชอยู่ตำแหน่งเดียวกัน ขนาดคงที่ (fixed size)

วิธีการจัดสรร Allocation Methods วิธีการจัดสรร หมายถึง บล็อกของดิสก์จะถูกจัดสรรสำหรับแฟ้มต่างๆ ได้อย่างไร การจัดสรรแบบต่อเนื่อง (Contiguous allocation) การจัดสรรแบบเชื่อมโยง (Linked allocation) การจัดสรรแบบดัชนี (Indexed allocation)

การจัดสรรแบบต่อเนื่อง Contiguous Allocation แต่ละแฟ้มจะอยู่กันเป็นชุดของบล็อกที่เรียงต่อเนื่องกันบนดิสก์ ง่าย – ต้องการเพียงบล็อกตำแหน่งเริ่มต้น (block #) และความยาวของบล็อก (number of blocks) เท่านั้น การเข้าถึงแบบสุ่ม (Random access) จะมีพื้นที่ใช้การไม่ได้มาก เกิดปัญหาการจัดสรรหน่วยเก็บแบบพลวัต (dynamic storage-allocation problem) แฟ้มไม่สามารถขยายได้ (Files cannot grow)

Contiguous Allocation of Disk Space

ระบบขยาย Extent-Based Systems มีระบบแฟ้มใหม่ๆ จำนวนมาก (I.e. Veritas File System) ใช้โครงสร้างการจัดสรรแบบต่อเนื่อง Extent-based file systems จัดสรรบล็อกของดิสก์แบบขยาย (extents) ส่วนขยาย (extent) คือขยายบล็อกของดิสก์แบบต่อเนื่อง โดยส่วนที่ถูกขยายคือการจัดสรรแฟ้ม แฟ้มจะประกอบด้วยส่วนขยาย (extents) จำนวนหนึ่งหรือมากกว่าหนึ่ง

การจัดสรรแบบเชื่อมโยง Linked Allocation แต่ละแฟ้มจะมีรายการเชื่อมโยง (linked list) ของบล็อกดิสก์ โดยที่บล็อกอาจเป็นการแบ่งส่วนใดๆก็ได้บนดิสก์ pointer block =

Linked Allocation (Cont.) ง่าย– ต้องการเพียงที่อยู่เริ่มต้น (starting address) ระบบการจัดการพื้นที่ว่าง (Free-space management system) – ไม่มีพื้นที่ว่างโดยเปล่าประโยชน์ ไม่รองรับการเข้าแบบสุ่ม (random access) ต้องแปลงส่ง (Mapping) Q LA/511 R บล็อกที่เข้าถึงคือ Qth block ในสายโยงใยของบล็อกที่แทนแฟ้ม Displacement into block = R + 1 File-allocation table (FAT) – การจัดสรรพื้นที่ว่างดิสก์ (disk-space allocation) ดังกล่าวนี้มีใช้โดย MS-DOS และ OS/2.

Linked Allocation

File-Allocation Table

การจัดสรรแบบดัชนี Indexed Allocation นำ pointers ทั้งหมดเข้าไปเก็บไว้ด้วยกันใน index block. มุมมองเชิงตรรกะ (Logical view) index table

Example of Indexed Allocation

Indexed Allocation (Cont.) ต้องมีตารางดัชนี (index table) เข้าถึงแบบสุ่ม (Random access) การเข้าถึงแบบพลวัต (Dynamic access) โดยไม่มีการแตกกระจายแบบภายนอก (external fragmentation), แต่จะมีoverhead ของ index block การ Mapping จากเชิงตรรกะเป็นเชิงกายภาพในแฟ้มหนึ่งๆ สูงสุดขนาดไม่เกิน 256K words และ block size of 512 words ต้องใช้เพียง 1 block สำหรับ index table Q LA/512 R Q = displacement into index table R = displacement into block

Indexed Allocation – Mapping (Cont.) Mapping จากเชิงตรรกะเป็นเชิงกายภาพในแฟ้มหนึ่งๆ นั้นไม่ผูกติดกับความยาว (block size of 512 words) โครงสร้างแบบโยง (Linked scheme) – Link blocks ของ index table (ไม่จำกัดขนาด) Q1 LA / (512 x 511) R1 Q1 = block of index table R1 is used as follows: Q2 R1 / 512 R2 Q2 = displacement into block of index table R2 displacement into block of file:

Indexed Allocation – Mapping (Cont.) ดัชนีแบบ 2 ระดับ (Two-level index) ขนาดไฟล์สูงสุดคือ 5123 Q1 LA / (512 x 512) R1 Q1 = displacement into outer-index R1 is used as follows: Q2 R1 / 512 R2 Q2 = displacement into block of index table R2 displacement into block of file:

Indexed Allocation – Mapping (Cont.)  outer-index index table file

Combined Scheme: UNIX (4K bytes per block)

การจัดการพื้นที่ว่าง Free-Space Management Bit vector (n blocks) 1 2 n-1 … 0  block[i] free 1  block[i] occupied bit[i] =  Block number calculation (number of bits per word) * (number of 0-value words) + offset of first 1 bit

Free-Space Management (Cont.) Bit map ต้องการพื้นที่เพิ่มเติม Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32K bytes) ง่ายต่อแฟ้มแบบต่อเนื่อง Linked list (free list) หาพื้นที่ต่อเนื่องได้ยาก ไม่มีพื้นที่ไร้ประโยชน์ Grouping Counting

Free-Space Management (Cont.) ต้องมีการป้องกัน (protect) Pointer ไปยังรายการที่ว่าง (free list) Bit map ต้องเก็บบนดิสก์ สำเนาบนหน่วยความจำและบนดิสก์อาจคนละชุด ไม่ยินยอมให้เกิดสถานการณ์สำหรับ block[i] โดยที่ bit[i] = 1 ในหน่วยความจำ และ bit[i] = 0 บนดิสก์ Solution: Set bit[i] = 1 in disk. Allocate block[i] Set bit[i] = 1 in memory

Linked Free Space List on Disk

ความสะดวกและประสิทธิภาพ Efficiency and Performance อัลกอริธึมในการจัดสรรดิสก์และไดเรกทอรี ชนิดของข้อมูลที่เก็บในรายการไดเรกทอรของแฟ้ม (file’s directory entry) ประสิทธิภาพ (Performance) ดิสก์แคช (disk cache) – แยกส่วนของหน่วยความจำสำหรับบล็อกที่ถูกใช้งานบ่อย free-behind and read-ahead – เป็นเทคนิคในการเข้าแบบลำดับได้เหมาะที่สุด (optimize sequential access) การปรับปรุงประสิทธิภาพของพีซีโดยสร้าง dedicating section ของหน่วยความจำเหมือนกับดิสก์เสมือน หรือแรมดิสก์ (virtual disk, or RAM disk)

Various Disk-Caching Locations

Page Cache เพจแคช (page cache) ใช้มากกว่าบล็อกดิสก์โดยใช้เทคนิคvirtual memory Memory-mapped I/O ใช้ page cache Routine I/O ผ่าน file system ใช้ buffer (disk) cache จะนำไปสู่ภาพในหน้าถัดไป

I/O Without a Unified Buffer Cache

Unified Buffer Cache A unified buffer cache ใช้เพจแคชเดียวกันสำหรับเป็นแคชทั้งหน่วยความจำ memory-mapped pages และ ordinary file system I/O

I/O Using a Unified Buffer Cache

การกู้คืน Recovery การตรวจสอบความสอดคล้องกัน (Consistency checking) – เปรียบเทียบข้อมูลในโครงสร้างไดเรกทอรีด้วยบล็อกข้อมูลบนดิสก์ และพยายามแก้ไขความไม่สอดคล้องกัน ใช้ system programs ในการ back up สำรองข้อมูลจากดิสก์ ไปยังอุปกรณ์หน่วยเก็บอื่นๆ (floppy disk, magnetic tape). กู้แฟ้มหรือดิสก์ที่เสียหาย โดยเรียกคืน restoring ข้อมูลจากระบบสำรอง

Log Structured File Systems Log structured (หรือ journaling) ทำการบันทึกระบบแฟ้มที่ถูกปรับปรุงแต่ละครั้งไปยังระบบแฟ้มในลักษณะของธุรกรรม (transaction) ทุกธุรกรรมจะถูกเขียนลงบน log ธุรกรรมหนึ่งๆ จะบันทึกว่าสำเร็จ (committed) หลังจากที่ถูกเขียนบน log เสร็จแล้ว อย่างไรก็ตาม file system อาจปรับปรุงยังไม่แล้วเสร็จก็ได้ ธุรกรรมใน log เป็นถูกเขียนแบบไม่พร้อมกัน (asynchronously written) บน file system เมื่อ file system ถูกแก้ไข ธุรกรรมก็จะถูกลบออกจาก log ถ้าระบบแฟ้มล่ม (crashes) ธุรกรรมที่ยังเหลืออยู่ใน log จต้องยังคงใช้การต่อได้

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.

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.

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.

Three Independent File Systems

Mounting in NFS Mounts Cascading mounts

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.

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.

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.

Schematic View of NFS Architecture

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.

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.