<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/f2fs/checkpoint.c, branch linux-5.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-04-08T12:05:23Z</updated>
<entry>
<title>f2fs: fix to do sanity check on .cp_pack_total_block_count</title>
<updated>2022-04-08T12:05:23Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2022-03-21T15:22:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7bab2d3bccd045c07d09a10a3d7f65f70b5c4330'/>
<id>urn:sha1:7bab2d3bccd045c07d09a10a3d7f65f70b5c4330</id>
<content type='text'>
commit 5b5b4f85b01604389f7a0f11ef180a725bf0e2d4 upstream.

As bughunter reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=215709

f2fs may hang when mounting a fuzzed image, the dmesg shows as below:

__filemap_get_folio+0x3a9/0x590
pagecache_get_page+0x18/0x60
__get_meta_page+0x95/0x460 [f2fs]
get_checkpoint_version+0x2a/0x1e0 [f2fs]
validate_checkpoint+0x8e/0x2a0 [f2fs]
f2fs_get_valid_checkpoint+0xd0/0x620 [f2fs]
f2fs_fill_super+0xc01/0x1d40 [f2fs]
mount_bdev+0x18a/0x1c0
f2fs_mount+0x15/0x20 [f2fs]
legacy_get_tree+0x28/0x50
vfs_get_tree+0x27/0xc0
path_mount+0x480/0xaa0
do_mount+0x7c/0xa0
__x64_sys_mount+0x8b/0xe0
do_syscall_64+0x38/0xc0
entry_SYSCALL_64_after_hwframe+0x44/0xae

The root cause is cp_pack_total_block_count field in checkpoint was fuzzed
to one, as calcuated, two cp pack block locates in the same block address,
so then read latter cp pack block, it will block on the page lock due to
the lock has already held when reading previous cp pack block, fix it by
adding sanity check for cp_pack_total_block_count.

Cc: stable@vger.kernel.org
Signed-off-by: Chao Yu &lt;chao.yu@oppo.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>f2fs: fix to check available space of CP area correctly in update_ckpt_flags()</title>
<updated>2022-01-27T11:02:56Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-12-12T12:28:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=efc0f3f844503d2fd478272039d5f8539a533c09'/>
<id>urn:sha1:efc0f3f844503d2fd478272039d5f8539a533c09</id>
<content type='text'>
commit b702c83e2eaa2fa2d72e957c55c0321535cc8b9f upstream.

Otherwise, nat_bit area may be persisted across boundary of CP area during
nat_bit rebuilding.

Fixes: 94c821fb286b ("f2fs: rebuild nat_bits during umount")
Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>f2fs: support fault injection for dquot_initialize()</title>
<updated>2021-10-29T17:38:53Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-10-28T13:03:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=10a26878564f27327b12e8f4b4d8d7b43065fae5'/>
<id>urn:sha1:10a26878564f27327b12e8f4b4d8d7b43065fae5</id>
<content type='text'>
This patch adds a new function f2fs_dquot_initialize() to wrap
dquot_initialize(), and it supports to inject fault into
f2fs_dquot_initialize() to simulate inner failure occurs in
dquot_initialize().

Usage:
a) echo 65536 &gt; /sys/fs/f2fs/&lt;dev&gt;/inject_type or
b) mount -o fault_type=65536 &lt;dev&gt; &lt;mountpoint&gt;

Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: avoid attaching SB_ACTIVE flag during mount</title>
<updated>2021-09-16T15:38:32Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-09-01T08:06:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c02599f210d90c76e42e2eb544511a47cceb60c9'/>
<id>urn:sha1:c02599f210d90c76e42e2eb544511a47cceb60c9</id>
<content type='text'>
Quoted from [1]

"I do remember that I've added this code back then because otherwise
orphan cleanup was losing updates to quota files. But you're right
that now I don't see how that could be happening and it would be nice
if we could get rid of this hack"

[1] https://lore.kernel.org/linux-ext4/99cce8ca-e4a0-7301-840f-2ace67c551f3@huawei.com/T/#m04990cfbc4f44592421736b504afcc346b2a7c00

Related fix in ext4 by
commit 72ffb49a7b62 ("ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()").

f2fs has the same hack implementation in
- f2fs_recover_orphan_inodes()
- f2fs_recover_fsync_data()

Let's get rid of this hack as well in f2fs.

Cc: Zhang Yi &lt;yi.zhang@huawei.com&gt;
Cc: Jan Kara &lt;jack@suse.cz&gt;
Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: quota: fix potential deadlock</title>
<updated>2021-09-16T15:38:32Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-09-03T02:38:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a5c0042200b28fff3bde6fa128ddeaef97990f8d'/>
<id>urn:sha1:a5c0042200b28fff3bde6fa128ddeaef97990f8d</id>
<content type='text'>
As Yi Zhuang reported in bugzilla:

https://bugzilla.kernel.org/show_bug.cgi?id=214299

There is potential deadlock during quota data flush as below:

Thread A:			Thread B:
f2fs_dquot_acquire
down_read(&amp;sbi-&gt;quota_sem)
				f2fs_write_checkpoint
				block_operations
				f2fs_look_all
				down_write(&amp;sbi-&gt;cp_rwsem)
f2fs_quota_write
f2fs_write_begin
__do_map_lock
f2fs_lock_op
down_read(&amp;sbi-&gt;cp_rwsem)
				__need_flush_qutoa
				down_write(&amp;sbi-&gt;quota_sem)

This patch changes block_operations() to use trylock, if it fails,
it means there is potential quota data updater, in this condition,
let's flush quota data first and then trylock again to check dirty
status of quota data.

The side effect is: in heavy race condition (e.g. multi quota data
upaters vs quota data flusher), it may decrease the probability of
synchronizing quota data successfully in checkpoint() due to limited
retry time of quota flush.

Reported-by: Yi Zhuang &lt;zhuangyi1@huawei.com&gt;
Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: rebuild nat_bits during umount</title>
<updated>2021-08-23T17:25:52Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-08-20T10:54:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=94c821fb286b545d37549ff30a0c341e066f0d6c'/>
<id>urn:sha1:94c821fb286b545d37549ff30a0c341e066f0d6c</id>
<content type='text'>
If all free_nat_bitmap are available, we can rebuild nat_bits from
free_nat_bitmap entirely during umount, let's make another chance
to reenable nat_bits for image.

Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: separate out iostat feature</title>
<updated>2021-08-23T17:25:51Z</updated>
<author>
<name>Daeho Jeong</name>
</author>
<published>2021-08-20T03:52:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=521187439abfb3e1c946796dc2187c443e5457ab'/>
<id>urn:sha1:521187439abfb3e1c946796dc2187c443e5457ab</id>
<content type='text'>
Added F2FS_IOSTAT config option to support getting IO statistics through
sysfs and printing out periodic IO statistics tracepoint events and
moved I/O statistics related codes into separate files for better
maintenance.

Signed-off-by: Daeho Jeong &lt;daehojeong@google.com&gt;
Reviewed-by: Chao Yu &lt;chao@kernel.org&gt;
[Jaegeuk Kim: set default=y]
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: support fault injection for f2fs_kmem_cache_alloc()</title>
<updated>2021-08-17T18:59:05Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-08-09T00:24:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=324105775c1982aacbd2972b7024d8cc06474abe'/>
<id>urn:sha1:324105775c1982aacbd2972b7024d8cc06474abe</id>
<content type='text'>
This patch supports to inject fault into f2fs_kmem_cache_alloc().

Usage:
a) echo 32768 &gt; /sys/fs/f2fs/&lt;dev&gt;/inject_type or
b) mount -o fault_type=32768 &lt;dev&gt; &lt;mountpoint&gt;

Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: avoid unneeded memory allocation in __add_ino_entry()</title>
<updated>2021-08-06T00:16:36Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-08-06T00:05:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b10651864429386ae931167d3518f37a8c762e0'/>
<id>urn:sha1:4b10651864429386ae931167d3518f37a8c762e0</id>
<content type='text'>
__add_ino_entry() will allocate slab cache even if we have already
cached ino entry in radix tree, e.g. for case of multiple devices.

Let's check radix tree first under protection of rcu lock to see
whether we need to do slab allocation, it will mitigate memory
pressure from "f2fs_ino_entry" slab cache.

Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: fix to stop filesystem update once CP failed</title>
<updated>2021-08-04T01:08:29Z</updated>
<author>
<name>Chao Yu</name>
</author>
<published>2021-08-04T00:38:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=91803392c732c43b5cf440e885ea89be7f5fecef'/>
<id>urn:sha1:91803392c732c43b5cf440e885ea89be7f5fecef</id>
<content type='text'>
During f2fs_write_checkpoint(), once we failed in
f2fs_flush_nat_entries() or do_checkpoint(), metadata of filesystem
such as prefree bitmap, nat/sit version bitmap won't be recovered,
it may cause f2fs image to be inconsistent, let's just set CP error
flag to avoid further updates until we figure out a scheme to rollback
all metadatas in such condition.

Reported-by: Yangtao Li &lt;frank.li@vivo.com&gt;
Signed-off-by: Yangtao Li &lt;frank.li@vivo.com&gt;
Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
</feed>
