fjlesystems 3
play

fjlesystems 3 1 last time FAT headers, free space, allocating - PowerPoint PPT Presentation

fjlesystems 3 1 last time FAT headers, free space, allocating space hard disk performance seek times from physical movement of disk head queues of requests, scheduled to control seek time smarts in controller: bad blocks, scheduling solid


  1. fjlesystems 3 1

  2. last time FAT headers, free space, allocating space hard disk performance seek times from physical movement of disk head queues of requests, scheduled to control seek time smarts in controller: bad blocks, scheduling solid state disks block remapping to hide erasure blocks in fmash xv6 fjlesystem inodes contain info about fjle blocks, type, size, etc. (instead of directory entries) 2

  3. xv6 fjlesystem xv6’s fjlesystem similar to modern Unix fjlesytems better at doing contiguous reads than FAT better at handling crashes supports hard links (more on these later) divides disk into blocks instead of clusters fjle block numbers, free blocks, etc. in difgerent tables 4

  4. xv6 disk layout logstart // File type short type; struct dinode { inode — fjle information bmapstart inodestart inode size short major; short minor; // T_DEV only nblocks }; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // T_DIR, T_FILE, T_DEV short nlink; uint logstart; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles // Number of links to inode in file system e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) uint size; // block # of first log block // # of log blocks 0 9 15 14 13 12 11 10 8 17 7 6 5 4 3 2 1 16 18 uint nlog; struct superblock { // # of inodes uint ninodes; // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; superblock — “header” block number data blocks free block map inode array log super block (boot block) the disk 5

  5. xv6 disk layout nblocks // T_DIR, T_FILE, T_DEV // File type short type; struct dinode { inode — fjle information inode size }; short nlink; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // block # of first log block uint logstart; short major; short minor; // T_DEV only // Number of links to inode in file system uint nlog; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles uint size; e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) 0 // # of log blocks // # of inodes 9 16 15 14 13 12 11 10 8 18 7 6 5 4 3 2 1 17 block number uint ninodes; free block map // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; struct superblock { superblock — “header” data blocks 5 the disk inode array log super block (boot block) ← logstart ← inodestart ninodes ← bmapstart

  6. xv6 disk layout logstart // File type short type; struct dinode { inode — fjle information bmapstart inodestart inode size short major; short minor; // T_DEV only nblocks }; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // T_DIR, T_FILE, T_DEV short nlink; uint logstart; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles // Number of links to inode in file system e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) uint size; // block # of first log block // # of log blocks 0 9 15 14 13 12 11 10 8 17 7 6 5 4 3 2 1 16 18 uint nlog; struct superblock { // # of inodes uint ninodes; // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; superblock — “header” block number data blocks free block map inode array log super block (boot block) the disk 5

  7. xv6 disk layout logstart // File type short type; struct dinode { inode — fjle information bmapstart inodestart inode size short major; short minor; // T_DEV only nblocks }; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // T_DIR, T_FILE, T_DEV short nlink; uint logstart; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles // Number of links to inode in file system e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) uint size; // block # of first log block // # of log blocks 0 9 15 14 13 12 11 10 8 17 7 6 5 4 3 2 1 16 18 uint nlog; struct superblock { // # of inodes uint ninodes; // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; superblock — “header” block number data blocks free block map inode array log super block (boot block) the disk 5

  8. xv6 disk layout logstart // File type short type; struct dinode { inode — fjle information bmapstart inodestart inode size short major; short minor; // T_DEV only nblocks }; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // T_DIR, T_FILE, T_DEV short nlink; uint logstart; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles // Number of links to inode in file system e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) uint size; // block # of first log block // # of log blocks 0 9 15 14 13 12 11 10 8 17 7 6 5 4 3 2 1 16 18 uint nlog; struct superblock { // # of inodes uint ninodes; // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; superblock — “header” block number data blocks free block map inode array log super block (boot block) the disk 5

  9. xv6 disk layout logstart // File type short type; struct dinode { inode — fjle information bmapstart inodestart inode size short major; short minor; // T_DEV only nblocks }; // block # of first free map block uint bmapstart; // block # of first inode block uint inodestart; // T_DIR, T_FILE, T_DEV short nlink; uint logstart; free block map — 1 bit per data block typical Unix solution: separate free inode map xv6 solution: scan for type = 0 what about fjnding free inodes contiguous 1s — contigous blocks allocating blocks: scan for 1 bits 1 if available, 0 if used special case for larger fjles // Number of links to inode in file system e.g. addrs[0] = 11; addrs[1] = 14; location of data as block numbers: }; // Data block addresses uint addrs[NDIRECT+1]; // Size of file (bytes) uint size; // block # of first log block // # of log blocks 0 9 15 14 13 12 11 10 8 17 7 6 5 4 3 2 1 16 18 uint nlog; struct superblock { // # of inodes uint ninodes; // # of data blocks uint nblocks; // Size of file system image (blocks) uint size; superblock — “header” block number data blocks free block map inode array log super block (boot block) the disk 5

  10. xv6 directory entries struct dirent { ushort inum; char name[DIRSIZ]; }; inum — index into inode array on disk name — name of fjle or directory each directory reference to inode called a hard link multiple hard links to fjle allowed! 6

  11. xv6 allocating inodes/blocks need new inode or data block: linear search simplest solution: xv6 always takes the fjrst one that’s free 7

  12. xv6 inode: direct and indirect blocks addrs[0] addrs[1] … addrs[11] addrs[12] addrs … data blocks … indirect block of direct blocks 8

  13. xv6 fjle sizes 512 byte blocks 2-byte block pointers: 256 block pointers in the indirect block 256 blocks = 131072 bytes of data referenced 12 direct blocks @ 512 bytes each = 6144 bytes 1 indirect block @ 131072 bytes each = 131072 bytes maximum fjle size = 6144 + 131072 bytes 9

  14. Linux ext2 inode __le16 i_gid; similar pointers like xv6 FS — but more indirection whole bunch of times owner and group and permissions (read/write/execute for owner/group/others) type (regular, directory, device) }; ... ... __le32 i_flags; __le32 i_blocks; __le16 i_links_count; struct ext2_inode { 10 __le32 i_size; __le32 i_mtime; __le16 i_mode; __le32 i_ctime; __le16 i_uid; __le32 i_dtime; __le32 i_atime; /* File mode */ /* Low 16 bits of Owner Uid */ /* Size in bytes */ /* Access time */ /* Creation time */ /* Modification time */ /* Deletion Time */ /* Low 16 bits of Group Id */ /* Links count */ /* Blocks count */ /* File flags */ __le32 i_block[EXT2_N_BLOCKS]; /* Pointers to blocks */

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend