f2fs-tools/fsck
Chao Yu a423b5f91e f2fs-tools: relocate chksum_offset for large_nat_bitmap feature
For large_nat_bitmap feature, there is a design flaw:

Previous:

struct f2fs_checkpoint layout:
+--------------------------+  0x0000
| checkpoint_ver           |
| ......                   |
| checksum_offset          |------+
| ......                   |      |
| sit_nat_version_bitmap[] |<-----|-------+
| ......                   |      |       |
| checksum_value           |<-----+       |
+--------------------------+  0x1000      |
|                          |      nat_bitmap + sit_bitmap
| payload blocks           |              |
|                          |              |
+--------------------------|<-------------+

Obviously, if nat_bitmap size + sit_bitmap size is larger than
MAX_BITMAP_SIZE_IN_CKPT, nat_bitmap or sit_bitmap may overlap
checkpoint checksum's position, once checkpoint() is triggered
from kernel, nat or sit bitmap will be damaged by checksum field.

In order to fix this, let's relocate checksum_value's position
to the head of sit_nat_version_bitmap as below, then nat/sit
bitmap and chksum value update will become safe.

After:

struct f2fs_checkpoint layout:
+--------------------------+  0x0000
| checkpoint_ver           |
| ......                   |
| checksum_offset          |------+
| ......                   |      |
| sit_nat_version_bitmap[] |<-----+
| ......                   |<-------------+
|                          |              |
+--------------------------+  0x1000      |
|                          |      nat_bitmap + sit_bitmap
| payload blocks           |              |
|                          |              |
+--------------------------|<-------------+

Related report and discussion:

https://sourceforge.net/p/linux-f2fs/mailman/message/36642346/

In addition, during writing checkpoint, if large_nat_bitmap feature is
enabled, we need to set CP_LARGE_NAT_BITMAP_FLAG flag in checkpoint.

Reported-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2019-05-20 17:30:16 -07:00
..
common.h fsck.f2fs: support quota 2017-11-06 20:07:40 -08:00
defrag.c WIP: Add partial shrinking support to f2fs 2018-11-21 11:38:23 -08:00
dict.c fsck.f2fs: support quota 2017-11-06 20:07:40 -08:00
dict.h fsck.f2fs: support quota 2017-11-06 20:07:40 -08:00
dir.c f2fs-tools: get rid of unneeded fields in on-disk inode 2019-05-20 17:29:50 -07:00
dqblk_v2.h fsck.f2fs: support quota 2017-11-06 20:07:40 -08:00
dump.c f2fs-tools: improve filename printing 2019-05-20 17:29:50 -07:00
f2fs.h f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
fsck.c f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
fsck.h f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
main.c f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
Makefile.am fsck/Makefile.am, mkfs/Makefile.am: fix to make distcheck correctly 2017-11-13 21:04:23 -08:00
mkquota.c fsck.f2fs: don't allocate new blocks on unclean shutdown 2018-11-21 11:38:23 -08:00
mount.c f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
node.c fsck.f2fs: don't allocate new blocks on unclean shutdown 2018-11-21 11:38:23 -08:00
node.h f2fs-tools: enhance on-disk inode structure scalability 2017-07-26 11:42:49 -07:00
quotaio_tree.c f2fs-tools:fix memory leak in write dquot 2019-04-28 06:25:58 -07:00
quotaio_tree.h fsck.f2fs: don't allocate new blocks on unclean shutdown 2018-11-21 11:38:23 -08:00
quotaio_v2.c fsck.f2fs: don't allocate new blocks on unclean shutdown 2018-11-21 11:38:23 -08:00
quotaio_v2.h fsck.f2fs: support quota 2017-11-06 20:07:40 -08:00
quotaio.c fsck.f2fs: don't allocate new blocks on unclean shutdown 2018-11-21 11:38:23 -08:00
quotaio.h fsck.f2fs: add an option to preserve quota limits 2017-11-11 18:01:07 -08:00
resize.c f2fs-tools: relocate chksum_offset for large_nat_bitmap feature 2019-05-20 17:30:16 -07:00
segment.c f2fs-tools: get rid of unneeded fields in on-disk inode 2019-05-20 17:29:50 -07:00
sload.c WIP: Add partial shrinking support to f2fs 2018-11-21 11:38:23 -08:00
xattr.c sload.f2fs: fix memory leak 2018-11-21 11:38:23 -08:00
xattr.h f2fs-tools: improve xattr value printing 2019-05-20 17:29:50 -07:00