Ext2 ÎļþϵͳµÄÓ²Å̲¼¾Ö
±¾ÎÄÖ÷Òª½²Êö Linux ÉϱȽÏÁ÷ÐÐµÄ ext2 ÎļþϵͳÔÚÓ²ÅÌ·ÖÇøÉϵÄÏêϸ²¼¾ÖÇé¿ö¡£Ext2 Îļþϵͳ¼ÓÉÏÈÕÖ¾Ö§³ÖµÄÏÂÒ»¸ö°æ±¾ÊÇ ext3 Îļþϵͳ£¬ËüºÍ ext2 ÎļþϵͳÔÚÓ²Å̲¼¾ÖÉÏÊÇÒ»ÑùµÄ£¬Æä²î±ð½ö½öÊÇ ext3 ÎļþϵͳÔÚÓ²ÅÌÉ϶à³öÁËÒ»¸öÌØÊâµÄ inode£¨¿ÉÒÔÀí½âΪһ¸öÌØÊâÎļþ£©£¬ÓÃÀ´¼Ç¼ÎļþϵͳµÄÈÕÖ¾£¬Ò²¼´ËùνµÄ journal¡£ÓÉÓÚ±¾ÎIJ¢²»ÌÖÂÛÈÕÖ¾Îļþ£¬ËùÒÔ±¾ÎĵÄÄÚÈݶÔÓÚ ext2 ºÍ ext3 ¶¼ÊÇÊÊÓõġ£ Ç°ÑÔ
±¾ÎĵÄ×ÊÁÏÀ´Ô´ÊÇ Linux ÄÚºËÖÐ ext3 ÎļþϵͳµÄÔ´´úÂ롣ΪÁ˱ãÓÚ¶ÁÕß²éÔÄÔ´´úÂ룬±¾ÎÄÖÐһЩ¹Ø¼üµÄ¼¼Êõ´Ê»ã¶¼Ê¹ÓÃÁËÄÚºËÔ´´úÂëÖÐËùʹÓõÄÓ¢Óïµ¥´Ê£¬¶øûÓÐʹÓÃÏàÓ¦µÄÖÐÎÄ·Òë¡£(ÕâÖÖ·½·¨ÊÇ·ñÇ¡µ±£¬»¹Çë¶ÁÕßÅóÓÑÃÇÖ¸½Ì¡£)
´ÖÂÔµÄÃèÊö
¶ÔÓÚ ext2 ÎļþϵͳÀ´Ëµ£¬Ó²ÅÌ·ÖÇøÊ×Ïȱ»»®·ÖΪһ¸ö¸öµÄ block£¬Ò»¸ö ext2 ÎļþϵͳÉϵÄÿ¸ö block ¶¼ÊÇÒ»Ñù´óСµÄ£¬µ«ÊǶÔÓÚ²»Í¬µÄ ext2 Îļþϵͳ£¬block µÄ´óС¿ÉÒÔÓÐÇø±ð¡£µäÐ굀 block ´óСÊÇ 1024 bytes »òÕß 4096 bytes¡£Õâ¸ö´óСÔÚ´´½¨ ext2 ÎļþϵͳµÄʱºò±»¾ö¶¨£¬Ëü¿ÉÒÔÓÉϵͳ¹ÜÀíÔ±Ö¸¶¨£¬Ò²¿ÉÒÔÓÉÎļþϵͳµÄ´´½¨³ÌÐò¸ù¾ÝÓ²ÅÌ·ÖÇøµÄ´óС£¬×Ô¶¯Ñ¡ÔñÒ»¸ö½ÏºÏÀíµÄÖµ¡£ÕâЩ blocks ±»¾ÛÔÚÒ»Æð·Ö³É¼¸¸ö´óµÄ block group¡£Ã¿¸ö block group ÖÐÓжàÉÙ¸ö block Êǹ̶¨µÄ¡£
ÿ¸ö block group ¶¼Ïà¶ÔÓ¦Ò»¸ö group descriptor£¬ÕâЩ group descriptor ±»¾ÛÔÚÒ»Æð·ÅÔÚÓ²ÅÌ·ÖÇøµÄ¿ªÍ·²¿·Ö£¬¸úÔÚ super block µÄºóÃæ¡£Ëùν super block£¬ÎÒÃÇÏÂÃ滹Ҫ½²µ½¡£ÔÚÕâ¸ö descriptor µ±ÖÐÓм¸¸öÖØÒªµÄ block Ö¸Õë¡£ÎÒÃÇÕâÀïËù˵µÄ block Ö¸Õ룬¾ÍÊÇÖ¸Ó²ÅÌ·ÖÇøÉ쵀 block ºÅÊý£¬±ÈÈ磬ָÕëµÄֵΪ 0£¬ÎÒÃǾÍ˵ËüÊÇÖ¸ÏòÓ²ÅÌ·ÖÇøÉ쵀 block 0£»Ö¸ÕëµÄֵΪ 1023£¬ÎÒÃǾÍ˵ËüÊÇÖ¸ÏòÓ²ÅÌ·ÖÇøÉ쵀 block 1023¡£ÎÒÃÇ×¢Òâµ½£¬Ò»¸öÓ²ÅÌ·ÖÇøÉ쵀 block ¼ÆÊýÊÇ´Ó 0 ¿ªÊ¼µÄ£¬²¢ÇÒÕâ¸ö¼ÆÊý¶ÔÓÚÕâ¸öÓ²ÅÌ·ÖÇøÀ´ËµÊÇÈ«¾ÖÐÔÖʵġ£
ÔÚ block group µÄ group descriptor ÖУ¬ÆäÖÐÓÐÒ»¸ö block Ö¸ÕëÖ¸ÏòÕâ¸ö block group µÄ block bitmap£¬block bitmap ÖеÄÿ¸ö bit ±íʾһ¸ö block£¬Èç¹û¸Ã bit Ϊ 0£¬±íʾ¸Ã block ÖÐÓÐÊý¾Ý£¬Èç¹û bit Ϊ 1£¬Ôò±íʾ¸Ã block ÊÇ¿ÕÏеġ£×¢Ò⣬Õâ¸ö block bitmap ±¾ÉíÒ²ÕýºÃÖ»ÓÐÒ»¸ö block ÄÇô´óС¡£¼ÙÉè block ´óСΪ S bytes£¬ÄÇô block bitmap µ±ÖÐÖ»ÄܼÇÔØ 8*S ¸ö block µÄÇé¿ö£¨ÒòΪһ¸ö byte µÈÓÚ 8 ¸ö bits£¬¶øÒ»¸ö bit ¶ÔÓ¦Ò»¸ö block£©¡£ÕâÒ²¾ÍÊÇ˵£¬Ò»¸ö block group ×î¶àÖ»ÄÜÓÐ 8*S*S bytes Õâô´ó¡£
ÔÚ block group µÄ group descriptor ÖÐÁíÓÐÒ»¸ö block Ö¸ÕëÖ¸Ïò inode bitmap£¬Õâ¸ö bitmap ͬÑùÒ²ÊÇÕýºÃÓÐÒ»¸ö block ÄÇô´ó£¬ÀïÃæµÄÿһ¸ö bit Ïà¶ÔÓ¦Ò»¸ö inode¡£Ó²ÅÌÉϵÄÒ»¸ö inode ´óÌåÉÏÏà¶ÔÓ¦ÓÚÎļþϵͳÉϵÄÒ»¸öÎļþ»òÕßĿ¼¡£¹ØÓÚ inode£¬ÎÒÃÇÏÂÃ滹Ҫ½øÒ»²½½²µ½¡£
ÔÚ block group µÄ descriptor ÖÐÁíÒ»¸öÖØÒªµÄ block Ö¸Õ룬ÊÇÖ¸ÏòËùνµÄ inode table¡£Õâ¸ö inode table ¾Í²»Ö¹Ò»¸ö block ÄÇô´óÁË¡£Õâ¸ö inode table ¾ÍÊÇÕâ¸ö block group ÖÐËù¾Û¼¯µ½µÄÈ«²¿ inode ·ÅÔÚÒ»ÆðÐγɵġ£
Ò»¸ö inode µ±ÖмÇÔصÄ×î¹Ø¼üµÄÐÅÏ¢£¬ÊÇÕâ¸ö inode ÖеÄÓû§Êý¾Ý´æ·ÅÔÚʲôµØ·½¡£ÎÒÃÇÔÚÇ°ÃæÌáµ½£¬Ò»¸ö inode ´óÌåÉÏÏà¶ÔÓ¦ÓÚÎļþϵͳÖеÄÒ»¸öÎļþ£¬ÄÇôÓû§ÎļþµÄÄÚÈÝ´æ·ÅÔÚʲôµØ·½£¬Õâ¾ÍÊÇÒ»¸ö inode Òª»Ø´ðµÄÎÊÌâ¡£Ò»¸ö inode ͨ¹ýÌṩһϵÁÐµÄ block Ö¸Õ룬À´»Ø´ðÕâ¸öÎÊÌâ¡£ÕâЩ block Ö¸ÕëÖ¸ÏòµÄ block£¬ÀïÃæ¾Í´æ·ÅÁËÓû§ÎļþµÄÄÚÈÝ¡£
2.1 »Ø¹Ë
ÏÖÔÚÎÒÃǻعËһϡ£Ó²ÅÌ·ÖÇøÊ×Ïȱ»·ÖΪºÃ¶à¸ö block¡£ÕâЩ block ¾ÛÔÚÒ»Æ𣬱»·Ö³É¼¸×飬Ҳ¾ÍÊÇ block group¡£Ã¿¸ö block group ¶¼ÓÐÒ»¸ö group descriptor¡£ËùÓÐÕâЩ descriptor ±»¾ÛÔÚÒ»Æ𣬷ÅÔÚÓ²ÅÌ·ÖÇøµÄ¿ªÍ·²¿·Ö£¬¸úÔÚ super block µÄºóÃæ¡£´Ó group descriptor ÎÒÃÇ¿ÉÒÔͨ¹ý block Ö¸Õ룬ÕÒµ½Õâ¸ö block group µÄ inode table ºÍ block bitmap µÈµÈ¡£´Ó inode table ÀïÃ棬ÎÒÃǾͿÉÒÔ¿´µ½Ò»¸ö¸öµÄ inode ÁË¡£´ÓÒ»¸ö inode£¬ÎÒÃÇͨ¹ýËüÀïÃæµÄ block Ö¸Õ룬¾Í¿ÉÒÔ½ø¶øÕÒµ½´æ·ÅÓû§Êý¾ÝµÄÄÇЩ block¡£ÎÒÃÇ»¹ÒªÌáһϣ¬block Ö¸Õë²»ÊÇ¿ÉÒÔµ½´¦ÂÒÖ¸µÄ¡£Ò»¸ö block group µÄ block bitmap ºÍ inode bitmap ÒÔ¼° inode table£¬¶¼ÒÀ´Î´æ·ÅÔÚÕâ¸ö block group µÄ¿ªÍ·²¿·Ö£¬¶øÄÇЩ´æ·ÅÓû§Êý¾ÝµÄ block ¾Í½ô¸úÔÚËüÃǵĺóÃæ¡£Ò»¸ö block group ½áÊøºó£¬ÁíÒ»¸ö block group ÓÖ¸ú×Å¿ªÊ¼¡£ ±¾ÐÂÎŹ² 6Ò³,µ±Ç°ÔÚµÚ 1Ò³ 1 2 3 4 5 6 |