@@ -101,48 +101,53 @@ on the type of file:
101
101
```
102
102
inode
103
103
+-----------------------+
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
+ +----------------+ +-------------+
120
125
121
126
```
122
127
- For a file, it lists the extents that hold the actual data of the file.
123
128
Given that block IDs are stored as values of ` sizeof(struct simplefs_extent) `
124
129
bytes, a single block can accommodate up to 341 links. This limitation
125
130
restricts the maximum size of a file to approximately 10.65 MiB (10,912 KiB).
126
131
```
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
133
138
+-----------------------+ | ee_start = 94 |---> +--------+
134
- |----------------| | |
139
+ |----------------| | |
135
140
1 | ee_block = 8 | +--------+
136
141
| ee_len = 8 | extent 99
137
- | ee_start = 99 |---> +--------+
142
+ | ee_start = 99 |---> +--------+
138
143
|----------------| | |
139
144
2 | ee_block = 16 | +--------+
140
- | ee_len = 8 | extent 66
145
+ | ee_len = 8 | extent 66
141
146
| ee_start = 66 |---> +--------+
142
147
|----------------| | |
143
148
| ... | +--------+
144
- |----------------|
145
- 341 | ee_block = 0 |
149
+ |----------------|
150
+ 341 | ee_block = 0 |
146
151
| ee_len = 0 |
147
152
| ee_start = 0 |
148
153
+----------------+
@@ -158,8 +163,8 @@ comprises three members:
158
163
159
164
```
160
165
struct simplefs_extent
161
- +----------------+
162
- | ee_block = 0 |
166
+ +----------------+
167
+ | ee_block = 0 |
163
168
| ee_len = 200| extent
164
169
| ee_start = 12 |-----------> +---------+
165
170
+----------------+ block 12 | |
@@ -181,7 +186,7 @@ The journaling support in simplefs is implemented using the jbd2 subsystem, whic
181
186
182
187
For a detailed introduction to journaling, please refer to these two websites:
183
188
[ 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 )
185
190
186
191
External journal device disk layout:
187
192
@@ -193,12 +198,12 @@ Hint:
193
198
Each 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.
194
199
195
200
196
- How to Enable Journaling in simplefs:
201
+ How to Enable Journaling in simplefs:
197
202
198
203
Step 1: Create the Journal Disk Image
199
204
To create an 8MB disk image for the journal, use the following make command:
200
205
201
- Note:
206
+ Note:
202
207
Assuming 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).
203
208
204
209
``` shell
0 commit comments