当前位置:网站首页>file system design

file system design

2022-08-10 13:54:00 Shui Sanya

filesystem

[参考gitHub博主][https://mp.weixin.qq.com/s?__biz=Mzk0MjE3NDE0Ng==&mid=2247494176&idx=1&sn=b4680b50090bb3c7b9c49379241c536c&chksm=c2c5908df5b2199b361885b32b07ab0f597ab25cd1d70bb75ca13fb897c200285685318f145f&scene=21#wechat_redirect]

What does the file system do, is to store files like xxx.txt, xxx.word, xxx.md, img, mv, etc. that we choose to write to the disk. How to manage and operateWell, that's what the file system does.

Assume the size of a disk is 1MB = 1024KB = 1024*1024B (bytes)

The 1MB disk is divided into 1024 blocks, then each block is 1024 bytes

Choose to introduce a data structure structure inode to store the relevant information of this file; assuming a inode structure occupies 128 bytes>, then just divided quickly, one can store 8 blocks, we call the block that stores the inode data structure inode table

Now a file is very large in size and needs a lot of space. It is impossible to write all the blocks it is in to the data blocks stored in the inode. Then the selection can be an indirect index in a block with a size of 1K, so it can be storedBlock 256 blocks

Then there is now a new question about whether the file is stored data. Some files are directories instead of data. Now it is necessary to change the type of data blocks pointed to by some directory files. If the file type is not a directory, it will be stored as before.If the file is a directory block, store the inode structure array to point to the location where it stores the inode table, and so on recursively, proceed

Now there are too many files, so one inode table is not enough, so you need more than one; then there is a problem, which inode structures in the inode table are used and which are not used, use it nowSet a inode bitmap to manage the inode structure in this inode table

There is a problem we need to know which blocks are used and which are not used. Now we need to set a block to store which blocks are used and which blocks are not used. Call this block Block bitmap, also if one bitmap block is not enough, just a few more.

Note: The inode bitmap is used to manage the inode structure

in the inode table (block)

Block Bitmap is to manage all used blocks (data blocks, inode tables...)

Then how should we know the location of block bitmap, inode bitmap, inode table, we need to set a blockdescriptor to store these three pieces of information

Finally, a super block is designed to store the number of inodes, the number of free inodes, the number of blocks, and the number of free blocks.

Superblock is placed in position 0, block descriptor is placed in position 1, block bitmap is placed in position 2,inode bitmap in position 3

原网站

版权声明
本文为[Shui Sanya]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208101326473979.html