You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78-2
Original file line number
Diff line number
Diff line change
@@ -172,9 +172,85 @@ struct simplefs_extent
172
172
+---------+
173
173
```
174
174
175
-
##TODO
175
+
### journalling support
176
176
177
-
- journalling support
177
+
Simplefs now includes support for an external journal device, leveraging the journaling block device (jbd2) subsystem in the Linux kernel. This enhancement improves the file system's resilience by maintaining a log of changes, which helps prevent corruption and facilitates recovery in the event of a crash or power failure.
178
+
179
+
180
+
The journaling support in simplefs is implemented using the jbd2 subsystem, which is a widely-used journaling layer in Linux. Currently, simplefs primarily stores the journal-related information in an external journal device.
181
+
182
+
For a detailed introduction to journaling, please refer to these two websites:
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
+
195
+
196
+
How to Enable Journaling in simplefs:
197
+
198
+
Step 1: Create the Journal Disk Image
199
+
To create an 8MB disk image for the journal, use the following make command:
200
+
201
+
Note:
202
+
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
+
204
+
```shell
205
+
$ make journal
206
+
```
207
+
208
+
Step 2: Make sure you've loaded the SimpleFS Kernel Module
209
+
210
+
```shell
211
+
$ insmod simplefs/simplefs.ko
212
+
```
213
+
214
+
Step 3: Setup the Loop Device for the Journal
215
+
Find an available loop device and associate it with the journal image:
216
+
217
+
```shell
218
+
$ loop_device=$(losetup -f)
219
+
$ losetup $loop_device /simplefs/journal.img
220
+
```
221
+
222
+
You shall get the following kernel messages:
223
+
```
224
+
loop0: detected capacity change from 0 to 16384
225
+
```
226
+
227
+
Step 4: Mount the SimpleFS File System with the External Journal
228
+
Mount the SimpleFS file system along with the external journal device using the following command:
229
+
230
+
```shell
231
+
mount -o loop,rw,owner,group,users,journal_path="$loop_device" -t simplefs /simplefs/test.img /test
- The exact size of the external journal device cannot be determined. As a temporary solution, the size is set by dividing the device size by the block size, with the external journal device size fixed at 8 MB.
246
+
247
+
2. Metadata Recording:
248
+
249
+
- At present, only "extent" metadata is recorded. In the future, additional metadata such as "super block" and inode metadata can be included.
250
+
251
+
3. Implementation of External Journal Device:
252
+
253
+
- Only the external journal device is implemented. Future improvements can include the use of an internal journal (inode journal). However, this will require the addition of a bmap function and appropriate adjustments to the disk partition during mkfs.
0 commit comments