<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/fs/f2fs/checkpoint.c, branch update-toolchain</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/fs/f2fs/checkpoint.c?h=update-toolchain</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/fs/f2fs/checkpoint.c?h=update-toolchain'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2024-07-10T22:47:57Z</updated>
<entry>
<title>f2fs: fix to update user block counts in block_operations()</title>
<updated>2024-07-10T22:47:57Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2024-06-25T02:32:39Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=f06c0f82e38bbda7264d6ef3c90045ad2810e0f3'/>
<id>urn:sha1:f06c0f82e38bbda7264d6ef3c90045ad2810e0f3</id>
<content type='text'>
Commit 59c9081bc86e ("f2fs: allow write page cache when writting cp")
allows write() to write data to page cache during checkpoint, so block
count fields like .total_valid_block_count, .alloc_valid_block_count
and .rf_node_block_count may encounter race condition as below:

CP				Thread A
- write_checkpoint
 - block_operations
  - f2fs_down_write(&amp;sbi-&gt;node_change)
  - __prepare_cp_block
  : ckpt-&gt;valid_block_count = .total_valid_block_count
  - f2fs_up_write(&amp;sbi-&gt;node_change)
				- write
				 - f2fs_preallocate_blocks
				  - f2fs_map_blocks(,F2FS_GET_BLOCK_PRE_AIO)
				   - f2fs_map_lock
				    - f2fs_down_read(&amp;sbi-&gt;node_change)
				   - f2fs_reserve_new_blocks
				    - inc_valid_block_count
				    : percpu_counter_add(&amp;sbi-&gt;alloc_valid_block_count, count)
				    : sbi-&gt;total_valid_block_count += count
				    - f2fs_up_read(&amp;sbi-&gt;node_change)
 - do_checkpoint
 : sbi-&gt;last_valid_block_count = sbi-&gt;total_valid_block_count
 : percpu_counter_set(&amp;sbi-&gt;alloc_valid_block_count, 0)
 : percpu_counter_set(&amp;sbi-&gt;rf_node_block_count, 0)
				- fsync
				 - need_do_checkpoint
				  - f2fs_space_for_roll_forward
				  : alloc_valid_block_count was reset to zero,
				    so, it may missed last data during checkpoint

Let's change to update .total_valid_block_count, .alloc_valid_block_count
and .rf_node_block_count in block_operations(), then their access can be
protected by .node_change and .cp_rwsem lock, so that it can avoid above
race condition.

Fixes: 59c9081bc86e ("f2fs: allow write page cache when writting cp")
Cc: Yunlei He &lt;heyunlei@oppo.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: enable atgc dynamically if conditions are met</title>
<updated>2024-06-18T02:26:58Z</updated>
<author>
<name>Zhiguo Niu</name>
<email>zhiguo.niu@unisoc.com</email>
</author>
<published>2024-06-07T09:00:30Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=6efc3a05e6132812edf7eee0eb040eb88af34203'/>
<id>urn:sha1:6efc3a05e6132812edf7eee0eb040eb88af34203</id>
<content type='text'>
Now atgc can only be enabled when umounted-&gt;mounted device
even related conditions have reached. If the device has not
be umounted-&gt;mounted for a long time, atgc can not work.

So enable atgc dynamically when atgc_age_threshold is less than
elapsed_time and ATGC mount option is on.

Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Zhiguo Niu &lt;zhiguo.niu@unisoc.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: fix false alarm on invalid block address</title>
<updated>2024-04-25T15:33:09Z</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2024-04-09T20:34:11Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=b864ddb57eb00c4ea1e6801c7b2f70f1db2a7f4b'/>
<id>urn:sha1:b864ddb57eb00c4ea1e6801c7b2f70f1db2a7f4b</id>
<content type='text'>
f2fs_ra_meta_pages can try to read ahead on invalid block address which is
not the corruption case.

Cc: &lt;stable@kernel.org&gt; # v6.9+
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218770
Fixes: 31f85ccc84b8 ("f2fs: unify the error handling of f2fs_is_valid_blkaddr")
Reviewed-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: convert f2fs__page tracepoint class to use folio</title>
<updated>2024-04-19T17:57:10Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2024-04-16T07:23:18Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=92f750d847c997ff4b0f04d83443af00fb729ba3'/>
<id>urn:sha1:92f750d847c997ff4b0f04d83443af00fb729ba3</id>
<content type='text'>
Convert f2fs__page tracepoint class() and its instances to use folio
and related functionality, and rename it to f2fs__folio().

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: unify the error handling of f2fs_is_valid_blkaddr</title>
<updated>2024-03-13T01:25:17Z</updated>
<author>
<name>Zhiguo Niu</name>
<email>zhiguo.niu@unisoc.com</email>
</author>
<published>2024-03-08T06:25:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=31f85ccc84b82cc7eb122af01f5017fbe1e29289'/>
<id>urn:sha1:31f85ccc84b82cc7eb122af01f5017fbe1e29289</id>
<content type='text'>
There are some cases of f2fs_is_valid_blkaddr not handled as
ERROR_INVALID_BLKADDR,so unify the error handling about all of
f2fs_is_valid_blkaddr.
Do f2fs_handle_error in __f2fs_is_valid_blkaddr for cleanup.

Signed-off-by: Zhiguo Niu &lt;zhiguo.niu@unisoc.com&gt;
Signed-off-by: Chao Yu &lt;chao@kernel.org&gt;
Reviewed-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 truncate meta inode pages forcely</title>
<updated>2024-03-13T01:25:17Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2024-03-08T01:08:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=9f0c4a46be1fe9b97dbe66d49204c1371e3ece65'/>
<id>urn:sha1:9f0c4a46be1fe9b97dbe66d49204c1371e3ece65</id>
<content type='text'>
Below race case can cause data corruption:

Thread A				GC thread
					- gc_data_segment
					 - ra_data_block
					  - locked meta_inode page
- f2fs_inplace_write_data
 - invalidate_mapping_pages
 : fail to invalidate meta_inode page
   due to lock failure or dirty|writeback
   status
 - f2fs_submit_page_bio
 : write last dirty data to old blkaddr
					 - move_data_block
					  - load old data from meta_inode page
					  - f2fs_submit_page_write
					  : write old data to new blkaddr

Because invalidate_mapping_pages() will skip invalidating page which
has unclear status including locked, dirty, writeback and so on, so
we need to use truncate_inode_pages_range() instead of
invalidate_mapping_pages() to make sure meta_inode page will be dropped.

Fixes: 6aa58d8ad20a ("f2fs: readahead encrypted block during GC")
Fixes: e3b49ea36802 ("f2fs: invalidate META_MAPPING before IPU/DIO write")
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: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC</title>
<updated>2024-02-27T17:41:12Z</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@kernel.org</email>
</author>
<published>2024-02-06T21:56:27Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=a60108f7dfb5867da1ad9c777d2fbbe47e4dbdd7'/>
<id>urn:sha1:a60108f7dfb5867da1ad9c777d2fbbe47e4dbdd7</id>
<content type='text'>
No functional change.

Reviewed-by: Daeho Jeong &lt;daehojeong@google.com&gt;
Reviewed-by: Chao Yu &lt;chao@kernel.org&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@kernel.org&gt;
</content>
</entry>
<entry>
<title>f2fs: introduce FAULT_BLKADDR_CONSISTENCE</title>
<updated>2024-02-06T02:58:39Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2024-01-12T19:41:32Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=c7115e094ca820bb72e0c89f158d16bc48c6fa04'/>
<id>urn:sha1:c7115e094ca820bb72e0c89f158d16bc48c6fa04</id>
<content type='text'>
We will encounter below inconsistent status when FAULT_BLKADDR type
fault injection is on.

Info: checkpoint state = d6 :  nat_bits crc fsck compacted_summary orphan_inodes sudden-power-off
[ASSERT] (fsck_chk_inode_blk:1254)  --&gt; ino: 0x1c100 has i_blocks: 000000c0, but has 191 blocks
[FIX] (fsck_chk_inode_blk:1260)  --&gt; [0x1c100] i_blocks=0x000000c0 -&gt; 0xbf
[FIX] (fsck_chk_inode_blk:1269)  --&gt; [0x1c100] i_compr_blocks=0x00000026 -&gt; 0x27
[ASSERT] (fsck_chk_inode_blk:1254)  --&gt; ino: 0x1cadb has i_blocks: 0000002f, but has 46 blocks
[FIX] (fsck_chk_inode_blk:1260)  --&gt; [0x1cadb] i_blocks=0x0000002f -&gt; 0x2e
[FIX] (fsck_chk_inode_blk:1269)  --&gt; [0x1cadb] i_compr_blocks=0x00000011 -&gt; 0x12
[ASSERT] (fsck_chk_inode_blk:1254)  --&gt; ino: 0x1c62c has i_blocks: 00000002, but has 1 blocks
[FIX] (fsck_chk_inode_blk:1260)  --&gt; [0x1c62c] i_blocks=0x00000002 -&gt; 0x1

After we inject fault into f2fs_is_valid_blkaddr() during truncation,
a) it missed to increase @nr_free or @valid_blocks
b) it can cause in blkaddr leak in truncated dnode
Which may cause inconsistent status.

This patch separates FAULT_BLKADDR_CONSISTENCE from FAULT_BLKADDR,
and rename FAULT_BLKADDR to FAULT_BLKADDR_VALIDITY
so that we can:
a) use FAULT_BLKADDR_CONSISTENCE in f2fs_truncate_data_blocks_range()
to simulate inconsistent issue independently, then it can verify fsck
repair flow.
b) FAULT_BLKADDR_VALIDITY fault will not cause any inconsistent status,
we can just use it to check error path handling in kernel side.

Reviewed-by: Daeho Jeong &lt;daehojeong@google.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: fix to account cp stats correctly</title>
<updated>2023-08-14T20:42:05Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2023-08-08T00:59:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=eb61c2cca2eb2110cc7b61a7bc15b3850977a778'/>
<id>urn:sha1:eb61c2cca2eb2110cc7b61a7bc15b3850977a778</id>
<content type='text'>
cp_foreground_calls sysfs entry shows total CP call count rather than
foreground CP call count, fix it.

Fixes: fc7100ea2a52 ("f2fs: Add f2fs stats to sysfs")
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: support errors=remount-ro|continue|panic mountoption</title>
<updated>2023-05-08T18:18:04Z</updated>
<author>
<name>Chao Yu</name>
<email>chao@kernel.org</email>
</author>
<published>2023-04-23T15:49:15Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=b62e71be2110d8b52bf5faf3c3ed7ca1a0c113a5'/>
<id>urn:sha1:b62e71be2110d8b52bf5faf3c3ed7ca1a0c113a5</id>
<content type='text'>
This patch supports errors=remount-ro|continue|panic mount option
for f2fs.

f2fs behaves as below in three different modes:
mode			continue	remount-ro	panic
access ops		normal		noraml		N/A
syscall errors		-EIO		-EROFS		N/A
mount option		rw		ro		N/A
pending dir write	keep		keep		N/A
pending non-dir write	drop		keep		N/A
pending node write	drop		keep		N/A
pending meta write	keep		keep		N/A

By default it uses "continue" mode.

[Yangtao helps to clean up function's name]
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>
