The Extended-2 Filesystem Overview

The Extended-2 Filesystem Overview

The extende d-2 le system overview Gadi Oxman, tgud@tochnap c2.technion.ac.il v0.1, August 3 1995 Contents 1 Pref ace 2 2 Intro duction 3 3 A le system - Whydowenee d it ? 3 4 The Linux VFS layer 3 5 Aboutblo cks andblo ck group s 4 6 The view of ino de s f rom the p oint of view of a blo cks group 4 7 The group de scr iptors 4 8 Theblo ck bitmap allo cation blo ck 5 9 The ino de allo cation bitmap 6 10 On the ino deandthe ino detable s 6 10.1 The allo cate d blo cks : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 7 10.2 Thei mo devar iable : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 8 10.2.1 The r ightmost 4 o ctal digits :::: ::: :::: ::: :::: ::: :::: ::: :::: : 8 10.2.2 The leftmost twooctal digits ::: ::: :::: ::: :::: ::: :::: ::: :::: : 8 10.3 Timeanddate : ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 9 s ize ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 9 10.4 i 10.5 Us er and group id :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 9 10.6 Hard links :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 10 10.7 The Ext2fs extende d ags :: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 10 10.8 Symb olic links :: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 11 1. Pref ace 2 10.8.1 Fast symb olic links :: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 11 10.8.2 Slow symb olic links :: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 11 10.9 i vers ion : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 11 10.10Re s erved var iable s :: :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 12 10.11Sp ecial re s erve d ino des :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 12 11 Director ie s 12 12 The sup erblo ck 13 12.1 sup erblo ckidenti cation ::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 14 12.2 File system xe d parameters : ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 14 12.3 Ext2fs error handling : :::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 15 12.4 Additional parameters us e d by e2fsck ::: ::: :::: ::: :::: ::: :::: ::: :::: : 15 12.5 Additional us er tunable parameters :::: ::: :::: ::: :::: ::: :::: ::: :::: : 16 12.6 File system currentstate ::: ::: :::: ::: :::: ::: :::: ::: :::: ::: :::: : 16 13 Copyr ight 16 14 Acknowle dgments 16 1 Pref ace Thi s do cumentattemptsto presentanoverview of theinter nal structure of the ext2 le system. It was wr itten in summer 95, while I was workingonthe ext2 filesystem editor project EXT2ED. In the pro ce ss of constructing EXT2ED, I acquire d knowle dge of thevar ious de s ign asp ectsofthethe ext2 le system. Thi s do cument i s a re sult of an e ort todocumentthi s knowle dge. Thi s i s only the initial vers ion of thi s do cument. It i s obviously neither error-prone nor complete, butat least it providesastarting p oint. In the pro ce ss of lear ningthesub ject, I have used the following source s / to ols: Exp er imenting with EXT2ED, as it was developed. The ext2 ker nel source s: fs.h { Themain ext2 include le, /usr/include/linux/ext2 { The contentsofthe directory /usr/src/linux/fs/ext2. { The VFS layer source s only a bit. The slides: The Second Extende d File System, CurrentState, Future Development, by Remy Card. 2. Intro duction 3 The slide s: Optimi sation in File Systems, by Stephen Tweedie. Thevar ious ext2 utilitie s. 2 Intro duction The Second Extended File System Ext2fs is very p opular among Linux us ers. If you us e Linux, chance s are thatyou are us ingthe ext2 le system. Ext2fs was de s igned by Remy Card and Wayne Davison.Itwas implemented by Remy Card andwas further enhance d by Stephen Tweedie and Theodore Ts'o. The ext2 le system i s still under development. I will do cumenthere vers ion 0.5a, which i s di str ibute d along with Linux 1.2.x. Atthi s timeofwriting, the most recentvers ion of Linux i s 1.3.13, andthevers ion of the ext2 ker nel source i s 0.5b. A lot of f ancy enhancements are planne d for the ext2 le system in Linux 1.3, so stay tuned. 3 A le system - Whydoweneedit? Ithoughtthat b efore we diveintothevar ious small details, I'll re s erve a few minute s for the di scuss ion of le systems f rom a general p oint of view. A filesystem cons i stsoftwoword - file and system. Everyone knows themeaningoftheword file -Abunchofdataput somewhere. where ? Thi s i s an imp ortant que stion. I, for example, usually throw almost everythingintoasingle drawer, andhave dicultie s nding somethinglater. Thi s i s where the system come s in - Instead of just throwingthedatatothedevice, we generalize and construct a system which will virtualize for us a nice and ordere d structure in whichwe could arrange our datainmuchthe sameway as b o oks are arrange d in a library.The purp os e of the le system, as I understand it, i s tomake it easy for us toupdateandmaintain our data. Normally,by mounting le systems, we just us e the nice and logical virtual structure. However, the di sk knows nothingaboutthat-Thedevice dr iver views the di sk as a large continuous pap er in whichwe can wr ite notes wherever we wi sh. It i s thetask of the le system managementcodetostore b o okkeeping information which will s ervetheker nel for showingusthe nice and ordere d virtual structure. In thi s do cument, we cons ider one particular admini strative structure - The Second Extende d File system. 4 The Linux VFS layer When Linux was rst developed, it supp orte d only one le system-TheMinix le system. Today, Linux has theabilityto supp ort s everal le systems concurrently. Thi s was donebytheintro duction of another layer between theker nel andthe le system co de-The Virtual File System VFS. 5. Aboutblo cks andblo ck group s 4 Theker nel "sp eaks" withthe VFS layer. The VFS layer pass e s theker nel's reque st tothe prop er le system managementcode. I haven't lear ned muchofthe VFS layer as I didn't nee d it for the construction of EXT2ED so that I can't elab orate on it. Just b e aware that it exi sts. 5 Aboutblo cks andblo ck group s In order to eas e management, the ext2 le system logically divides thediskintosmall units calle d blocks.A 1 blo ckisthesmalle st unit which can b e allo cate d. Each blo ckinthe le system can b e allocated or free. The blo ck s ize can b e s elected to b e 1024, 2048 or 4096 bytes when creatingthe le system. Ext2fs groups together a xe d numb er of s equential blo cks intoa group block.The re sultingsituation i s thatthe le system i s manage d as a s er ie s of group blo cks. Thi s i s done in order tokeep relate d information phys ically clos e on thediskandto eas e themanagementtask. As a re sult, muchofthe le system management re duce s tomanagementofa single blo cks group. 6 The view of ino de s f rom the p oint of view of a blo cks group Each le in the le system i s re s erve d a sp ecial inode. I don't wantto explain ino des now. Rather, I would liketo treat it as another re source, much likeablock - Each blo cks group contains a limited number of ino de, while any sp eci c ino de can b e allocated or unallocated. 7 The group de scr iptors Each blo cks group i s accompanie d byagroup descriptor.The group de scr iptor summar ize s somenece ssary information aboutthe sp eci c group blo ck. Follows thede nition of the group de scr iptor, as de ned in /usr/include/linux/ext2 fs.h: struct ext2_group_desc { __u32 bg_block_bitmap; /* Blocks bitmap block */ __u32 bg_inode_bitmap; /* Inodes bitmap block */ __u32 bg_inode_table; /* Inodes table block */ __u16 bg_free_blocks_count; /* Free blocks count */ __u16 bg_free_inodes_count; /* Free inodes count */ __u16 bg_used_dirs_count; /* Directories count */ __u16 bg_pad; __u32 bg_reserved[3]; }; 1 The Ext2fs source co de refers tothe concept of fragments, which I b elieve are supposed tobesub-blo ck allo cations. As f ar as I know, f ragments are currently unsupp orte d in Ext2fs. 8. Theblo ck bitmap allo cation blo ck 5 The last three var iable s: bg free blocks count, bg free inodes count and bg used dirs count provide statistics aboutthe us e of thethree re source s in a blo cks group - The blocks,the inodes andthe directories. I b elievethatthey are us e d bytheker nel for balancingthe load b etween thevar ious blo cks groups. bg block bitmap contains the blo cknumberofthe block allocation bitmap block. Thi s i s us e d to allo cate/ deallo cate each blo ckinthe sp eci c blo cks group. inode bitmap i s fully analogous tothe previous var iable - It contains the blo cknumberofthe inode bg allocation bitmap block, whichisusedto allo cate/ deallo cate each sp eci c ino deinthe le system. inode table contains the blo cknumberofthestart of the inode table of the current blocks group. bg The inode table i s just the actual ino de s which are re s erve d for the current blo ck. The blo ck bitmap blo ck, ino de bitmap blo ckandthe ino detable are created when the le system i s created. The group de scr iptors are place d one after theother. Together they makethe group descriptors table. Each blo cks group contains theentire table of group de scr iptors in its s econd blo ck, r ight after the sup erblo ck. However, only the rst copy in group 0 i s actually us e d bytheker nel. Theother copie s are there for backup purp os e s and can b e of us e if themain copy gets corrupted. 8 Theblo ck bitmap allo cation blo ck Each blo cks group contains one sp ecial blo ck whichisactually a map of theentire blo cks in the group, with re sp ect tothe ir allo cation status.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us