This patch backports simplefs to kernel version 3.10.
current_time(struct inode *) was introduced from kernel
version 4.9. This patch backports simplefs to kernel
version 3.10 (Centos 7.5) by replacing current_time()
by CURRENT_TIME macro. The idea is to 'tag' this version
such that is becomes easy to experiment on commanly used
distribution which comes with little dated kernel.
After Patch:
~~~~~~~~~~~~
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
$ make
make -C /lib/modules/3.10.0-957.el7.x86_64/build M=/root/dev_world/simplefs modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
$
$ insmod simplefs.ko
$ lsmod | grep simplefs
simplefs 18383 0
jbd2 107478 2 ext4,simplefs
Signed-off-by: Arshad Hussain <arshad.super@gmail.com>
The CURRENT_TIME macro is no longer valid with the latest kernel
(commit bfe1c566453a0979c0b3cd3728d0de962272f034). Replace usage
with current_time() function.
This patchset adds journal support into simplefs using jbd2, the only
available journal is external (you could create it using mke2fs -O
journal_dev, for more info look into simple-test.sh), and the only spot
that have start/write_access/dirty_metadata/stop is simplefs_write()
(IOW no support for creation).
This branch is compacted, for more verbose versions of this patchset
please look into more older version (v4, v3, ...).
Here is the example of records in journal:
==> final-jbd2-ext4.logdump <==
logdump
Journal starts at block 1, transaction 4
Found expected sequence 4, type 1 (descriptor block) at block 1
Found expected sequence 4, type 2 (commit block) at block 16
Found expected sequence 5, type 1 (descriptor block) at block 17
Found expected sequence 5, type 2 (commit block) at block 19
Found expected sequence 6, type 1 (descriptor block) at block 20
Found expected sequence 6, type 2 (commit block) at block 22
No magic number at block 23: end of journal.
==> final-jbd2-simplefs.logdump <==
debugfs: logdump -f /dev/loop0
Ext2 superblock header found.
Journal starts at block 2, transaction 2
Found expected sequence 2, type 1 (descriptor block) at block 2
Found expected sequence 2, type 2 (commit block) at block 4
Found expected sequence 3, type 1 (descriptor block) at block 5
Found expected sequence 3, type 2 (commit block) at block 7
Found expected sequence 4, type 1 (descriptor block) at block 8
Found expected sequence 4, type 2 (commit block) at block 10
Found expected sequence 5, type 1 (descriptor block) at block 11
Found expected sequence 5, type 2 (commit block) at block 13
Found expected sequence 6, type 1 (descriptor block) at block 14
Found expected sequence 6, type 2 (commit block) at block 16
Found expected sequence 7, type 1 (descriptor block) at block 17
Found expected sequence 7, type 2 (commit block) at block 19
Found expected sequence 8, type 1 (descriptor block) at block 20
Found expected sequence 8, type 2 (commit block) at block 22
No magic number at block 23: end of journal.
* journal-v6:
simplefs_write: install h_sync (sync on close) for jbd2 handle
Use max available journal size with jbd2_journal_init_dev()
simple-test: create journal with 4k block size
simple-test: use losetup+journal_path=/dev/loopX for mounting with journal
Handle bdevs for journal_path= mount flag
Actually load journal by calling jbd2_journal_load()
simple-test: mount fs with journal
Implement journal_path option
Add loader for internal journal (we need to update mkfs to support this)
Add sfs_trace for lookup and compare inside it
simple-test: enable jbd2-debug
Check that journal was initialized successfully
Write journal device name
Implement external journal device instead of internal
simplefs_write: add journaling using jbd2
Initial support of journaling
This will make simplefs journaling more robust.
+ head -n100 /proc/fs/jbd2/loop0/info
7 transactions (7 requested), each up to 640 blocks
average:
0ms waiting for transaction
10ms request delay
26ms running transaction
0ms transaction was being locked
0ms flushing data (in ordered mode)
0ms logging transaction
3459us average transaction commit time
1 handles per transaction
1 blocks per transaction
2 logged blocks per transaction
- Reorder block numbers to make it more sequental for mkfs
- mkfs: adjust writing, to make it correct write journal blocks and ino too
- simplefs_iget: use fops for journal inode
- simplefs_iget: check sfs_inode->mode instead of i_mode (not initialized yet)
There we iterate over inodes using simplefs_get_inode(), while instead
we already have last inode number, just use it instead, and increment
some paddings to it (start inode, reserved inodes).
And form after this patch kedr shows that there is no leaks.
(but we must recheck it in the future.)
Release bh in simplefs_get_inode() and use kmalloc() instead, and also
add super_operations.destory_inode handler, to free allocated memory.
This is not optimal and it must be replaced by slab allocators.
In many cases we don't need such verbose loggin, just add macros to
print loggin only if SIMPLEFS_DEBUG isset.
And it will be installed by default. (in Makefile)