@@ -101,48 +101,53 @@ on the type of file:
101101 ```
102102 inode
103103 +-----------------------+
104- | i_mode = IFDIR | 0755 | block 123
105- | ei_block = 123 ----|--------> +----------------+
106- | i_size = 4 KiB | 0 | ee_block = 0 |
107- | i_blocks = 1 | | ee_len = 8 | block 84
108- +-----------------------+ | ee_start = 84 |---> +-----------+
109- |----------------| 0 | 24 (foo) |
110- 1 | ee_block = 8 | |-----------|
111- | ee_len = 8 | 1 | 45 (bar) |
112- | ee_start = 16 | |-----------|
113- |----------------| | ... |
114- | ... | |-----------|
115- |----------------| 14 | 0 |
116- 341 | ee_block = 0 | +-----------+
117- | ee_len = 0 |
118- | ee_start = 0 |
119- +----------------+
104+ | i_mode = IFDIR | 0755 | block 123 (simplefs_file_ei_block)
105+ | ei_block = 123 ----|---> +----------------+
106+ | i_size = 4 KiB | | nr_files = 7 |
107+ | i_blocks = 1 | |----------------|
108+ +-----------------------+ 0 | ee_block = 0 |
109+ | ee_len = 8 | block 84(simplefs_dir_block)
110+ | ee_start = 84 |---> +-------------+
111+ | nr_file = 2 | |nr_files = 2 |
112+ |----------------| |-------------|
113+ 1 | ee_block = 8 | 0 | inode = 24 |
114+ | ee_len = 8 | | nr_blk = 1 |
115+ | ee_start = 16 | | (foo) |
116+ | nr_file = 5 | |-------------|
117+ |----------------| 1 | inode = 45 |
118+ | ... | | nr_blk = 14 |
119+ |----------------| | (bar) |
120+ 341 | ee_block = 0 | |-------------|
121+ | ee_len = 0 | | ... |
122+ | ee_start = 0 | |-------------|
123+ | nr_file = 12 | 14 | 0 |
124+ +----------------+ +-------------+
120125
121126 ```
122127 - For a file, it lists the extents that hold the actual data of the file.
123128 Given that block IDs are stored as values of ` sizeof(struct simplefs_extent) `
124129 bytes, a single block can accommodate up to 341 links. This limitation
125130 restricts the maximum size of a file to approximately 10.65 MiB (10,912 KiB).
126131 ```
127- inode
128- +-----------------------+
129- | i_mode = IFDIR | 0644 | block 93
130- | ei_block = 93 ----|------> +----------------+
131- | i_size = 10 KiB | 0 | ee_block = 0 |
132- | i_blocks = 25 | | ee_len = 8 | extent 94
132+ inode
133+ +-----------------------+
134+ | i_mode = IFDIR | 0644 | block 93
135+ | ei_block = 93 ----|------> +----------------+
136+ | i_size = 10 KiB | 0 | ee_block = 0 |
137+ | i_blocks = 25 | | ee_len = 8 | extent 94
133138 +-----------------------+ | ee_start = 94 |---> +--------+
134- |----------------| | |
139+ |----------------| | |
135140 1 | ee_block = 8 | +--------+
136141 | ee_len = 8 | extent 99
137- | ee_start = 99 |---> +--------+
142+ | ee_start = 99 |---> +--------+
138143 |----------------| | |
139144 2 | ee_block = 16 | +--------+
140- | ee_len = 8 | extent 66
145+ | ee_len = 8 | extent 66
141146 | ee_start = 66 |---> +--------+
142147 |----------------| | |
143148 | ... | +--------+
144- |----------------|
145- 341 | ee_block = 0 |
149+ |----------------|
150+ 341 | ee_block = 0 |
146151 | ee_len = 0 |
147152 | ee_start = 0 |
148153 +----------------+
@@ -158,8 +163,8 @@ comprises three members:
158163
159164```
160165struct simplefs_extent
161- +----------------+
162- | ee_block = 0 |
166+ +----------------+
167+ | ee_block = 0 |
163168 | ee_len = 200| extent
164169 | ee_start = 12 |-----------> +---------+
165170 +----------------+ block 12 | |
@@ -181,7 +186,7 @@ The journaling support in simplefs is implemented using the jbd2 subsystem, whic
181186
182187For a detailed introduction to journaling, please refer to these two websites:
183188[ Journal(jbd2) document] ( https://www.kernel.org/doc/html/latest/filesystems/ext4/journal.html )
184- [ Journal(jbd2) api] ( https://docs.kernel.org/filesystems/journalling.html )
189+ [ Journal(jbd2) api] ( https://docs.kernel.org/filesystems/journalling.html )
185190
186191External journal device disk layout:
187192
@@ -193,12 +198,12 @@ Hint:
193198Each transaction starts with a descriptor block, followed by several metadata blocks or data blocks, and ends with a commit block. Every modified metadata (such as inode, bitmap, etc.) occupies its own block. Currently, simplefs primarily records "extent" metadata.
194199
195200
196- How to Enable Journaling in simplefs:
201+ How to Enable Journaling in simplefs:
197202
198203Step 1: Create the Journal Disk Image
199204To create an 8MB disk image for the journal, use the following make command:
200205
201- Note:
206+ Note:
202207Assuming an 8 MB size for the external journal device, which is an arbitrary choice for now, I will set the journal block length to a fixed 2048, calculated by dividing the device size by the block size (4096 bytes).
203208
204209``` shell
0 commit comments