<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/fs/f2fs/inline.c, branch linux-6.0.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-6.0.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-6.0.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-05-18T22:36:11+00:00</updated>
<entry>
<title>f2fs: fix to do sanity check for inline inode</title>
<updated>2022-05-18T22:36:11+00:00</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2022-05-18T12:28:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=677a82b44ebf263d4f9a0cfbd576a6ade797a07b'/>
<id>urn:sha1:677a82b44ebf263d4f9a0cfbd576a6ade797a07b</id>
<content type='text'>
Yanming reported a kernel bug in Bugzilla kernel [1], which can be
reproduced. The bug message is:

The kernel message is shown below:

kernel BUG at fs/inode.c:611!
Call Trace:
 evict+0x282/0x4e0
 __dentry_kill+0x2b2/0x4d0
 dput+0x2dd/0x720
 do_renameat2+0x596/0x970
 __x64_sys_rename+0x78/0x90
 do_syscall_64+0x3b/0x90

[1] https://bugzilla.kernel.org/show_bug.cgi?id=215895

The bug is due to fuzzed inode has both inline_data and encrypted flags.
During f2fs_evict_inode(), as the inode was deleted by rename(), it
will cause inline data conversion due to conflicting flags. The page
cache will be polluted and the panic will be triggered in clear_inode().

Try fixing the bug by doing more sanity checks for inline data inode in
sanity_check_inode().

Cc: stable@vger.kernel.org
Reported-by: Ming Yan &lt;yanming@tju.edu.cn&gt;
Signed-off-by: Chao Yu &lt;chao.yu@oppo.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: move f2fs to use reader-unfair rwsems</title>
<updated>2022-01-25T01:40:04+00:00</updated>
<author>
<name>Tim Murray</name>
<email>timmurray@google.com</email>
</author>
<published>2022-01-07T20:48:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e4544b63a7ee49e7fbebf35ece0a6acd3b9617ae'/>
<id>urn:sha1:e4544b63a7ee49e7fbebf35ece0a6acd3b9617ae</id>
<content type='text'>
f2fs rw_semaphores work better if writers can starve readers,
especially for the checkpoint thread, because writers are strictly
more important than reader threads. This prevents significant priority
inversion between low-priority readers that blocked while trying to
acquire the read lock and a second acquisition of the write lock that
might be blocking high priority work.

Signed-off-by: Tim Murray &lt;timmurray@google.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: do not bother checkpoint by f2fs_get_node_info</title>
<updated>2022-01-04T21:20:49+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2021-12-13T22:16:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a9419b63bf414775e8aeee95d8c4a5e0df690748'/>
<id>urn:sha1:a9419b63bf414775e8aeee95d8c4a5e0df690748</id>
<content type='text'>
This patch tries to mitigate lock contention between f2fs_write_checkpoint and
f2fs_get_node_info along with nat_tree_lock.

The idea is, if checkpoint is currently running, other threads that try to grab
nat_tree_lock would be better to wait for checkpoint.

Reviewed-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: support fault injection for dquot_initialize()</title>
<updated>2021-10-29T17:38:53+00:00</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2021-10-28T13:03:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.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: restructure f2fs page.private layout</title>
<updated>2021-05-14T18:22:08+00:00</updated>
<author>
<name>Chao Yu</name>
<email>yuchao0@huawei.com</email>
</author>
<published>2021-04-28T09:20:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b763f3bedc2da2edf81bba550430847f561eae0e'/>
<id>urn:sha1:b763f3bedc2da2edf81bba550430847f561eae0e</id>
<content type='text'>
Restruct f2fs page private layout for below reasons:

There are some cases that f2fs wants to set a flag in a page to
indicate a specified status of page:
a) page is in transaction list for atomic write
b) page contains dummy data for aligned write
c) page is migrating for GC
d) page contains inline data for inline inode flush
e) page belongs to merkle tree, and is verified for fsverity
f) page is dirty and has filesystem/inode reference count for writeback
g) page is temporary and has decompress io context reference for compression

There are existed places in page structure we can use to store
f2fs private status/data:
- page.flags: PG_checked, PG_private
- page.private

However it was a mess when we using them, which may cause potential
confliction:
		page.private	PG_private	PG_checked	page._refcount (+1 at most)
a)		-1		set				+1
b)		-2		set
c), d), e)					set
f)		0		set				+1
g)		pointer		set

The other problem is page.flags has no free slot, if we can avoid set
zero to page.private and set PG_private flag, then we use non-zero value
to indicate PG_private status, so that we may have chance to reclaim
PG_private slot for other usage. [1]

The other concern is f2fs has bad scalability in aspect of indicating
more page status.

So in this patch, let's restructure f2fs' page.private as below to
solve above issues:

Layout A: lowest bit should be 1
| bit0 = 1 | bit1 | bit2 | ... | bit MAX | private data .... |
 bit 0	PAGE_PRIVATE_NOT_POINTER
 bit 1	PAGE_PRIVATE_ATOMIC_WRITE
 bit 2	PAGE_PRIVATE_DUMMY_WRITE
 bit 3	PAGE_PRIVATE_ONGOING_MIGRATION
 bit 4	PAGE_PRIVATE_INLINE_INODE
 bit 5	PAGE_PRIVATE_REF_RESOURCE
 bit 6-	f2fs private data

Layout B: lowest bit should be 0
 page.private is a wrapped pointer.

After the change:
		page.private	PG_private	PG_checked	page._refcount (+1 at most)
a)		11		set				+1
b)		101		set				+1
c)		1001		set				+1
d)		10001		set				+1
e)						set
f)		100001		set				+1
g)		pointer		set				+1

[1] https://lore.kernel.org/linux-f2fs-devel/20210422154705.GO3596236@casper.infradead.org/T/#u

Cc: Matthew Wilcox &lt;willy@infradead.org&gt;
Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: fix a redundant call to f2fs_balance_fs if an error occurs</title>
<updated>2021-03-12T21:16:44+00:00</updated>
<author>
<name>Colin Ian King</name>
<email>colin.king@canonical.com</email>
</author>
<published>2021-03-04T09:21:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=28e18ee636ba28532dbe425540af06245a0bbecb'/>
<id>urn:sha1:28e18ee636ba28532dbe425540af06245a0bbecb</id>
<content type='text'>
The  uninitialized variable dn.node_changed does not get set when a
call to f2fs_get_node_page fails.  This uninitialized value gets used
in the call to f2fs_balance_fs() that may or not may not balances
dirty node and dentry pages depending on the uninitialized state of
the variable. Fix this by only calling f2fs_balance_fs if err is
not set.

Thanks to Jaegeuk Kim for suggesting an appropriate fix.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: 2a3407607028 ("f2fs: call f2fs_balance_fs only when node was changed")
Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: fix to avoid inconsistent quota data</title>
<updated>2021-02-01T22:32:51+00:00</updated>
<author>
<name>Yi Chen</name>
<email>chenyi77@huawei.com</email>
</author>
<published>2021-01-28T09:02:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=25fb04dbce6a0e165d28fd1fa8a1d7018c637fe8'/>
<id>urn:sha1:25fb04dbce6a0e165d28fd1fa8a1d7018c637fe8</id>
<content type='text'>
Occasionally, quota data may be corrupted detected by fsck:

Info: checkpoint state = 45 :  crc compacted_summary unmount
[QUOTA WARNING] Usage inconsistent for ID 0:actual (1543036928, 762) != expected (1543032832, 762)
[ASSERT] (fsck_chk_quota_files:1986)  --&gt; Quota file is missing or invalid quota file content found.
[QUOTA WARNING] Usage inconsistent for ID 0:actual (1352478720, 344) != expected (1352474624, 344)
[ASSERT] (fsck_chk_quota_files:1986)  --&gt; Quota file is missing or invalid quota file content found.

[FSCK] Unreachable nat entries                        [Ok..] [0x0]
[FSCK] SIT valid block bitmap checking                [Ok..]
[FSCK] Hard link checking for regular file            [Ok..] [0x0]
[FSCK] valid_block_count matching with CP             [Ok..] [0xdf299]
[FSCK] valid_node_count matcing with CP (de lookup)   [Ok..] [0x2b01]
[FSCK] valid_node_count matcing with CP (nat lookup)  [Ok..] [0x2b01]
[FSCK] valid_inode_count matched with CP              [Ok..] [0x2665]
[FSCK] free segment_count matched with CP             [Ok..] [0xcb04]
[FSCK] next block offset is free                      [Ok..]
[FSCK] fixing SIT types
[FSCK] other corrupted bugs                           [Fail]

The root cause is:
If we open file w/ readonly flag, disk quota info won't be initialized
for this file, however, following mmap() will force to convert inline
inode via f2fs_convert_inline_inode(), which may increase block usage
for this inode w/o updating quota data, it causes inconsistent disk quota
info.

The issue will happen in following stack:
open(file, O_RDONLY)
mmap(file)
- f2fs_convert_inline_inode
 - f2fs_convert_inline_page
  - f2fs_reserve_block
   - f2fs_reserve_new_block
    - f2fs_reserve_new_blocks
     - f2fs_i_blocks_write
      - dquot_claim_block
inode-&gt;i_blocks increase, but the dqb_curspace keep the size for the dquots
is NULL.

To fix this issue, let's call dquot_initialize() anyway in both
f2fs_truncate() and f2fs_convert_inline_inode() functions to avoid potential
inconsistent quota data issue.

Fixes: 0abd675e97e6 ("f2fs: support plain user/group quota")
Signed-off-by: Daiyue Zhang &lt;zhangdaiyue1@huawei.com&gt;
Signed-off-by: Dehe Gu &lt;gudehe@huawei.com&gt;
Signed-off-by: Junchao Jiang &lt;jiangjunchao1@huawei.com&gt;
Signed-off-by: Ge Qiu &lt;qiuge@huawei.com&gt;
Signed-off-by: Yi Chen &lt;chenyi77@huawei.com&gt;
Reviewed-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: inline: fix wrong inline inode stat</title>
<updated>2020-12-08T22:25:41+00:00</updated>
<author>
<name>Jack Qiu</name>
<email>jack.qiu@huawei.com</email>
</author>
<published>2020-12-07T12:01:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=84921561532f771bd338e7791bf275b2b605d642'/>
<id>urn:sha1:84921561532f771bd338e7791bf275b2b605d642</id>
<content type='text'>
Miss to stat inline inode in f2fs_recover_inline_data.

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>
</entry>
<entry>
<title>f2fs: inline: correct comment in f2fs_recover_inline_data</title>
<updated>2020-12-08T22:25:41+00:00</updated>
<author>
<name>Jack Qiu</name>
<email>jack.qiu@huawei.com</email>
</author>
<published>2020-12-07T12:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6e5ca4fce7b3fc6065593a3a58f734a14d5a44c3'/>
<id>urn:sha1:6e5ca4fce7b3fc6065593a3a58f734a14d5a44c3</id>
<content type='text'>
In 3rd scene, it should remove data blocks instead of inline_data.

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>
</entry>
<entry>
<title>f2fs: don't allow any writes on readonly mount</title>
<updated>2020-12-07T16:41:16+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2020-12-03T17:14:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ec2ddf499402a665d1f6f7f5ce1391100e54089e'/>
<id>urn:sha1:ec2ddf499402a665d1f6f7f5ce1391100e54089e</id>
<content type='text'>
generic_make_request: Trying to write to read-only block-device dm-5 (partno 0)
WARNING: CPU: 7 PID: 546 at block/blk-core.c:2190 generic_make_request_checks+0x664/0x690
pc : generic_make_request_checks+0x664/0x690
lr : generic_make_request_checks+0x664/0x690
Call trace:
 generic_make_request_checks+0x664/0x690
 generic_make_request+0xf0/0x3a4
 submit_bio+0x80/0x250
 __submit_merged_bio+0x368/0x4e0
 __submit_merged_write_cond.llvm.12294350193007536502+0xe0/0x3e8
 f2fs_wait_on_page_writeback+0x84/0x128
 f2fs_convert_inline_page+0x35c/0x6f8
 f2fs_convert_inline_inode+0xe0/0x2e0
 f2fs_file_mmap+0x48/0x9c
 mmap_region+0x41c/0x74c
 do_mmap+0x40c/0x4fc
 vm_mmap_pgoff+0xb8/0x114
 vm_mmap+0x34/0x48
 elf_map+0x68/0x108
 load_elf_binary+0x538/0xb70
 search_binary_handler+0xac/0x1dc
 exec_binprm+0x50/0x15c
 __do_execve_file+0x620/0x740
 __arm64_sys_execve+0x54/0x68
 el0_svc_common+0x9c/0x168
 el0_svc_handler+0x60/0x6c
 el0_svc+0x8/0xc

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