Lower Level File system Algorithms namei alloc iget

  • Slides: 34
Download presentation

Lower Level File system Algorithms namei alloc iget free ialloc ifree iput bmap buffer

Lower Level File system Algorithms namei alloc iget free ialloc ifree iput bmap buffer allocation algorithms getblk brelse breada bwrite 그림 4. 1 파일 시스템 알고리즘들

#include <stdio. h> #include <sys/types. h> #include <sys/stat. h> filedata(pathname) char *pathname; { struct

#include <stdio. h> #include <sys/types. h> #include <sys/stat. h> filedata(pathname) char *pathname; { struct statbuf; if (stat(pathname, &statbuf) < 0 ) { printf(“couldn’t stat %sn”, pathname); return(-1); } printf(“n. File %s: n”, pathname); printf(“Size %ld bytesn”, statbuf. st_size); printf(“User-id %d, Group-id %ldn”, statbuf. st_uid, statbuf. st_gid); }

Inode Data Blocks direct 0 direct 1 direct 2 direct 3 direct 4 direct

Inode Data Blocks direct 0 direct 1 direct 2 direct 3 direct 4 direct 5 direct 6 direct 7 direct 8 direct 9 single indirect double indirect triple indirect 그림 4. 6 inode내의 직접 및 간접 블럭들

10 direct blocks with 1 K bytes each=10 K bytes 1 indirect block with

10 direct blocks with 1 K bytes each=10 K bytes 1 indirect block with 256 direct blocks= 1 K*256=256 K bytes 1 double indirect block with 256 indirect blocks= 256 K*256=64 M bytes 1 triple indirect block with 256 double indirect blocks= 64 M*256=16 G bytes

Byte Offset in Dir. Inode Number File Names 0 83 . 16 2 .

Byte Offset in Dir. Inode Number File Names 0 83 . 16 2 . . 32 1798 init 48 1276 fsck 그림 4. 10 /etc의 디렉토리 배치

Super Block Free Inode List free inodes 83 48 18 19 empty 20 array

Super Block Free Inode List free inodes 83 48 18 19 empty 20 array 1 index Super Block Free Inode List free inodes 83 18 19 empty 20 array 2 index Assigning Free Inode from Middle of List 그림 4. 13 자유 inode 번호들을 수록한 2개의 배열 (a) 리스트의 중간에서 자유 inode를 할당

Super Block Free Inode List 470 empty 0 array 1 index Super Block Free

Super Block Free Inode List 470 empty 0 array 1 index Super Block Free Inode List 535 free inodes 0 array 2 476 475 471 48 49 50 Assigning Free Inode – Super Block List Empty 그림 4. 13(b) 자유 inode를 할당-수퍼 블록 리스트기 비었음

535 476 475 471 free inodes remembered inode index Original Super Block List of

535 476 475 471 free inodes remembered inode index Original Super Block List of Free Inodes 499 476 475 471 free inodes remembered inode index Free Inode 601 그림 4. 15 자유 inode 번호를 수퍼블럭에 넣는 작업

Process A Process B Process C Assigns inode I from super block Sleeps while

Process A Process B Process C Assigns inode I from super block Sleeps while reading inode(a) Tries to assign inode from super block use Super block empty(b) the lock Search for free inodes on disk, puts inode I in super block (c) Inode I in core Does usual activity Completes search, assigns another inode(d) Assigns inode I from super block I is in use! Assign another inode(e) Race Condition in Assigning Inodes 그림 4. 16 inode를 할당할 때 발생하는 경쟁상황

109 106 103 100 ……………. . 109 211 208 205 202 ………… 112 211

109 106 103 100 ……………. . 109 211 208 205 202 ………… 112 211 310 307 304 301 ………… 214 310 409 406 403 400 ………… 313 linked list of free disk block number 그림 4. 18 자유 디스크 블록 번호의 연결 리스트

super block list 109 …………………………… 109 211 208 205 202 ………………. . 112 (a)

super block list 109 …………………………… 109 211 208 205 202 ………………. . 112 (a) original configuration 109 949 …………………………. . 109 211 208 205 202 ………………. 112 (b) After freeing block number 949 그림 4. 20 디스크 블록에 대한 요구 및 자유화

109 ……………………………. . 109 211 208 205 202 ………………. 112 (c) after assigning block

109 ……………………………. . 109 211 208 205 202 ………………. 112 (c) after assigning block number(949) 211 208 205 202 ……………… 112 211 344 341 338 335 ………………. 243 (d) After assigning block number(109) replenish super block free list 그림 4. 20