<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/f2fs/node.c, branch v5.10</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>f2fs: handle errors of f2fs_get_meta_page_nofail</title>
<updated>2020-10-14T06:23:29+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2020-10-02T21:17:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=86f33603f8c51537265ff7ac0320638fd2cbdb1b'/>
<id>86f33603f8c51537265ff7ac0320638fd2cbdb1b</id>
<content type='text'>
First problem is we hit BUG_ON() in f2fs_get_sum_page given EIO on
f2fs_get_meta_page_nofail().

Quick fix was not to give any error with infinite loop, but syzbot caught
a case where it goes to that loop from fuzzed image. In turned out we abused
f2fs_get_meta_page_nofail() like in the below call stack.

- f2fs_fill_super
 - f2fs_build_segment_manager
  - build_sit_entries
   - get_current_sit_page

INFO: task syz-executor178:6870 can't die for more than 143 seconds.
task:syz-executor178 state:R
 stack:26960 pid: 6870 ppid:  6869 flags:0x00004006
Call Trace:

Showing all locks held in the system:
1 lock held by khungtaskd/1179:
 #0: ffffffff8a554da0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6242
1 lock held by systemd-journal/3920:
1 lock held by in:imklog/6769:
 #0: ffff88809eebc130 (&amp;f-&gt;f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe9/0x100 fs/file.c:930
1 lock held by syz-executor178/6870:
 #0: ffff8880925120e0 (&amp;type-&gt;s_umount_key#47/1){+.+.}-{3:3}, at: alloc_super+0x201/0xaf0 fs/super.c:229

Actually, we didn't have to use _nofail in this case, since we could return
error to mount(2) already with the error handler.

As a result, this patch tries to 1) remove _nofail callers as much as possible,
2) deal with error case in last remaining caller, f2fs_get_sum_page().

Reported-by: syzbot+ee250ac8137be41d7b13@syzkaller.appspotmail.com
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
First problem is we hit BUG_ON() in f2fs_get_sum_page given EIO on
f2fs_get_meta_page_nofail().

Quick fix was not to give any error with infinite loop, but syzbot caught
a case where it goes to that loop from fuzzed image. In turned out we abused
f2fs_get_meta_page_nofail() like in the below call stack.

- f2fs_fill_super
 - f2fs_build_segment_manager
  - build_sit_entries
   - get_current_sit_page

INFO: task syz-executor178:6870 can't die for more than 143 seconds.
task:syz-executor178 state:R
 stack:26960 pid: 6870 ppid:  6869 flags:0x00004006
Call Trace:

Showing all locks held in the system:
1 lock held by khungtaskd/1179:
 #0: ffffffff8a554da0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6242
1 lock held by systemd-journal/3920:
1 lock held by in:imklog/6769:
 #0: ffff88809eebc130 (&amp;f-&gt;f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe9/0x100 fs/file.c:930
1 lock held by syz-executor178/6870:
 #0: ffff8880925120e0 (&amp;type-&gt;s_umount_key#47/1){+.+.}-{3:3}, at: alloc_super+0x201/0xaf0 fs/super.c:229

Actually, we didn't have to use _nofail in this case, since we could return
error to mount(2) already with the error handler.

As a result, this patch tries to 1) remove _nofail callers as much as possible,
2) deal with error case in last remaining caller, f2fs_get_sum_page().

Reported-by: syzbot+ee250ac8137be41d7b13@syzkaller.appspotmail.com
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: remove unused check on version_bitmap</title>
<updated>2020-09-29T08:48:33+00:00</updated>
<author>
<name>Wang Xiaojun</name>
<email>wangxiaojun11@huawei.com</email>
</author>
<published>2020-09-19T03:35:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e6e421870b5f4a73802dac7c123dcb02f929989f'/>
<id>e6e421870b5f4a73802dac7c123dcb02f929989f</id>
<content type='text'>
A NULL will not be return by __bitmap_ptr here.
Remove the unused check.

Signed-off-by: Wang Xiaojun &lt;wangxiaojun11@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A NULL will not be return by __bitmap_ptr here.
Remove the unused check.

Signed-off-by: Wang Xiaojun &lt;wangxiaojun11@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: clean up kvfree</title>
<updated>2020-09-14T18:15:37+00:00</updated>
<author>
<name>Chao Yu</name>
<email>yuchao0@huawei.com</email>
</author>
<published>2020-09-14T08:47:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c8eb702484ed5badb2b654f2c9d086e43a00b954'/>
<id>c8eb702484ed5badb2b654f2c9d086e43a00b954</id>
<content type='text'>
After commit 0b6d4ca04a86 ("f2fs: don't return vmalloc() memory from
f2fs_kmalloc()"), f2fs_k{m,z}alloc() will not return vmalloc()'ed
memory, so clean up to use kfree() instead of kvfree() to free
vmalloc()'ed memory.

Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After commit 0b6d4ca04a86 ("f2fs: don't return vmalloc() memory from
f2fs_kmalloc()"), f2fs_k{m,z}alloc() will not return vmalloc()'ed
memory, so clean up to use kfree() instead of kvfree() to free
vmalloc()'ed memory.

Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: fix indefinite loop scanning for free nid</title>
<updated>2020-09-09T03:31:33+00:00</updated>
<author>
<name>Sahitya Tummala</name>
<email>stummala@codeaurora.org</email>
</author>
<published>2020-08-18T10:10:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e2cab031ba7b5003cd12185b3ef38f1a75e3dae8'/>
<id>e2cab031ba7b5003cd12185b3ef38f1a75e3dae8</id>
<content type='text'>
If the sbi-&gt;ckpt-&gt;next_free_nid is not NAT block aligned and if there
are free nids in that NAT block between the start of the block and
next_free_nid, then those free nids will not be scanned in scan_nat_page().
This results into mismatch between nm_i-&gt;available_nids and the sum of
nm_i-&gt;free_nid_count of all NAT blocks scanned. And nm_i-&gt;available_nids
will always be greater than the sum of free nids in all the blocks.
Under this condition, if we use all the currently scanned free nids,
then it will loop forever in f2fs_alloc_nid() as nm_i-&gt;available_nids
is still not zero but nm_i-&gt;free_nid_count of that partially scanned
NAT block is zero.

Fix this to align the nm_i-&gt;next_scan_nid to the first nid of the
corresponding NAT block.

Signed-off-by: Sahitya Tummala &lt;stummala@codeaurora.org&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the sbi-&gt;ckpt-&gt;next_free_nid is not NAT block aligned and if there
are free nids in that NAT block between the start of the block and
next_free_nid, then those free nids will not be scanned in scan_nat_page().
This results into mismatch between nm_i-&gt;available_nids and the sum of
nm_i-&gt;free_nid_count of all NAT blocks scanned. And nm_i-&gt;available_nids
will always be greater than the sum of free nids in all the blocks.
Under this condition, if we use all the currently scanned free nids,
then it will loop forever in f2fs_alloc_nid() as nm_i-&gt;available_nids
is still not zero but nm_i-&gt;free_nid_count of that partially scanned
NAT block is zero.

Fix this to align the nm_i-&gt;next_scan_nid to the first nid of the
corresponding NAT block.

Signed-off-by: Sahitya Tummala &lt;stummala@codeaurora.org&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>treewide: Use fallthrough pseudo-keyword</title>
<updated>2020-08-23T22:36:59+00:00</updated>
<author>
<name>Gustavo A. R. Silva</name>
<email>gustavoars@kernel.org</email>
</author>
<published>2020-08-23T22:36:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=df561f6688fef775baa341a0f5d960becd248b11'/>
<id>df561f6688fef775baa341a0f5d960becd248b11</id>
<content type='text'>
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva &lt;gustavoars@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: space related cleanup</title>
<updated>2020-07-26T15:15:40+00:00</updated>
<author>
<name>Jack Qiu</name>
<email>jack.qiu@huawei.com</email>
</author>
<published>2020-07-24T08:55:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a87aff1d491f6d824d9cc53303544361d7eaae75'/>
<id>a87aff1d491f6d824d9cc53303544361d7eaae75</id>
<content type='text'>
Just for code style, no logic change
1. delete useless space
2. change spaces into tab

Signed-off-by: Jack Qiu &lt;jack.qiu@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Just for code style, no logic change
1. delete useless space
2. change spaces into tab

Signed-off-by: Jack Qiu &lt;jack.qiu@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: Change the type of f2fs_flush_inline_data() to void</title>
<updated>2020-07-24T03:22:37+00:00</updated>
<author>
<name>Jia Yang</name>
<email>jiayang5@huawei.com</email>
</author>
<published>2020-07-21T03:49:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=68e79baf41f89fcdf9edf9bf3d65a71b667d066c'/>
<id>68e79baf41f89fcdf9edf9bf3d65a71b667d066c</id>
<content type='text'>
The return value of f2fs_flush_inline_data() is not used,
so delete it.

Signed-off-by: Jia Yang &lt;jiayang5@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The return value of f2fs_flush_inline_data() is not used,
so delete it.

Signed-off-by: Jia Yang &lt;jiayang5@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: should avoid inode eviction in synchronous path</title>
<updated>2020-07-21T19:55:54+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2020-07-16T16:57:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=b0f3b87fb3abc42c81d76c6c5795f26dbdb2f04b'/>
<id>b0f3b87fb3abc42c81d76c6c5795f26dbdb2f04b</id>
<content type='text'>
https://bugzilla.kernel.org/show_bug.cgi?id=208565

PID: 257    TASK: ecdd0000  CPU: 0   COMMAND: "init"
  #0 [&lt;c0b420ec&gt;] (__schedule) from [&lt;c0b423c8&gt;]
  #1 [&lt;c0b423c8&gt;] (schedule) from [&lt;c0b459d4&gt;]
  #2 [&lt;c0b459d4&gt;] (rwsem_down_read_failed) from [&lt;c0b44fa0&gt;]
  #3 [&lt;c0b44fa0&gt;] (down_read) from [&lt;c044233c&gt;]
  #4 [&lt;c044233c&gt;] (f2fs_truncate_blocks) from [&lt;c0442890&gt;]
  #5 [&lt;c0442890&gt;] (f2fs_truncate) from [&lt;c044d408&gt;]
  #6 [&lt;c044d408&gt;] (f2fs_evict_inode) from [&lt;c030be18&gt;]
  #7 [&lt;c030be18&gt;] (evict) from [&lt;c030a558&gt;]
  #8 [&lt;c030a558&gt;] (iput) from [&lt;c047c600&gt;]
  #9 [&lt;c047c600&gt;] (f2fs_sync_node_pages) from [&lt;c0465414&gt;]
 #10 [&lt;c0465414&gt;] (f2fs_write_checkpoint) from [&lt;c04575f4&gt;]
 #11 [&lt;c04575f4&gt;] (f2fs_sync_fs) from [&lt;c0441918&gt;]
 #12 [&lt;c0441918&gt;] (f2fs_do_sync_file) from [&lt;c0441098&gt;]
 #13 [&lt;c0441098&gt;] (f2fs_sync_file) from [&lt;c0323fa0&gt;]
 #14 [&lt;c0323fa0&gt;] (vfs_fsync_range) from [&lt;c0324294&gt;]
 #15 [&lt;c0324294&gt;] (do_fsync) from [&lt;c0324014&gt;]
 #16 [&lt;c0324014&gt;] (sys_fsync) from [&lt;c0108bc0&gt;]

This can be caused by flush_dirty_inode() in f2fs_sync_node_pages() where
iput() requires f2fs_lock_op() again resulting in livelock.

Reported-by: Zhiguo Niu &lt;Zhiguo.Niu@unisoc.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://bugzilla.kernel.org/show_bug.cgi?id=208565

PID: 257    TASK: ecdd0000  CPU: 0   COMMAND: "init"
  #0 [&lt;c0b420ec&gt;] (__schedule) from [&lt;c0b423c8&gt;]
  #1 [&lt;c0b423c8&gt;] (schedule) from [&lt;c0b459d4&gt;]
  #2 [&lt;c0b459d4&gt;] (rwsem_down_read_failed) from [&lt;c0b44fa0&gt;]
  #3 [&lt;c0b44fa0&gt;] (down_read) from [&lt;c044233c&gt;]
  #4 [&lt;c044233c&gt;] (f2fs_truncate_blocks) from [&lt;c0442890&gt;]
  #5 [&lt;c0442890&gt;] (f2fs_truncate) from [&lt;c044d408&gt;]
  #6 [&lt;c044d408&gt;] (f2fs_evict_inode) from [&lt;c030be18&gt;]
  #7 [&lt;c030be18&gt;] (evict) from [&lt;c030a558&gt;]
  #8 [&lt;c030a558&gt;] (iput) from [&lt;c047c600&gt;]
  #9 [&lt;c047c600&gt;] (f2fs_sync_node_pages) from [&lt;c0465414&gt;]
 #10 [&lt;c0465414&gt;] (f2fs_write_checkpoint) from [&lt;c04575f4&gt;]
 #11 [&lt;c04575f4&gt;] (f2fs_sync_fs) from [&lt;c0441918&gt;]
 #12 [&lt;c0441918&gt;] (f2fs_do_sync_file) from [&lt;c0441098&gt;]
 #13 [&lt;c0441098&gt;] (f2fs_sync_file) from [&lt;c0323fa0&gt;]
 #14 [&lt;c0323fa0&gt;] (vfs_fsync_range) from [&lt;c0324294&gt;]
 #15 [&lt;c0324294&gt;] (do_fsync) from [&lt;c0324014&gt;]
 #16 [&lt;c0324014&gt;] (sys_fsync) from [&lt;c0108bc0&gt;]

This can be caused by flush_dirty_inode() in f2fs_sync_node_pages() where
iput() requires f2fs_lock_op() again resulting in livelock.

Reported-by: Zhiguo Niu &lt;Zhiguo.Niu@unisoc.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: fix error path in do_recover_data()</title>
<updated>2020-07-08T17:11:19+00:00</updated>
<author>
<name>Chao Yu</name>
<email>yuchao0@huawei.com</email>
</author>
<published>2020-07-06T10:23:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9627a7b31f3c4ff8bc8f3be3683983ffe6eaebe6'/>
<id>9627a7b31f3c4ff8bc8f3be3683983ffe6eaebe6</id>
<content type='text'>
- don't panic kernel if f2fs_get_node_page() fails in
f2fs_recover_inline_data() or f2fs_recover_inline_xattr();
- return error number of f2fs_truncate_blocks() to
f2fs_recover_inline_data()'s caller;

Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- don't panic kernel if f2fs_get_node_page() fails in
f2fs_recover_inline_data() or f2fs_recover_inline_xattr();
- return error number of f2fs_truncate_blocks() to
f2fs_recover_inline_data()'s caller;

Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: lost matching-pair of trace in f2fs_truncate_inode_blocks</title>
<updated>2020-07-08T04:51:47+00:00</updated>
<author>
<name>Yubo Feng</name>
<email>fengyubo3@huawei.com</email>
</author>
<published>2020-06-20T08:39:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9039d8355d6e37647b31a42122a26f1858a2470a'/>
<id>9039d8355d6e37647b31a42122a26f1858a2470a</id>
<content type='text'>
if get_node_path() return -E2BIG and trace of
f2fs_truncate_inode_blocks_enter/exit enabled
then the matching-pair of trace_exit will lost
in log.

Signed-off-by: Yubo Feng &lt;fengyubo3@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
if get_node_path() return -E2BIG and trace of
f2fs_truncate_inode_blocks_enter/exit enabled
then the matching-pair of trace_exit will lost
in log.

Signed-off-by: Yubo Feng &lt;fengyubo3@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
