Closed jserv closed 2 months ago
At present, simplefs utilizes an index_block to store up to 1024 block numbers, each encoded using 4 bytes.
I have some issues here. Currently, simplefs should be using an extent block to allocate blocks, with each extent being 8 blocks. Therefore, the maximum space should be SIMPLEFS_FILES_PER_BLOCK(341) * SIMPLEFS_MAX_BLOCKS_PER_EXTENT(8)
rather than 1024.
Another question is, if we implement read and write operations ourselves without using the page cache, does that mean we won't enter simplefs_write_begin
?
Another question is, if we implement read and write operations ourselves without using the page cache, does that mean we won't enter simplefs_write_begin?"
It is intentionally independent from page cache for read and write operations.
Currently, simplefs does not implement
read
andwrite
operations and therefore uses the default implementation provided by the Linux kernel. Unfortunately, this implementation assumes that the data blocks are filled contiguously, which leads to potential performance and usability problems.The simplefs does not store the size of data within each block, making it challenging to manage partially filled blocks. To address this issue, we need to modify the data structure used for storing data blocks. At present, simplefs utilizes an index_block to store up to 1024 block numbers, each encoded using 4 bytes. An ideal solution could be to limit the partition size to 4 GiB and repurpose the 12 bits of the block number to store the effective size of data within each block.
To simplify this step, we would implement
read
andwrite
operations that behave like the default implementation, but that will not use the page cache. To do this, we will need to use thesb_bread
andbrelse
functions provided by the Linux kernel to read data directly from the disk. We will also need to use themark_buffer_dirty
andsync_dirty_buffer
functions to write data to the disk.The possible implementation: