Skip to content

Commit c5d9ab8

Browse files
committed
Merge tag 'f2fs-for-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs
Pull f2fs update from Jaegeuk Kim: "In this round, there are a number of updates on mainly two areas: Zoned block device support and Per-file compression. For example, we've found several issues to support Zoned block device especially having large sections regarding to GC and file pinning used for Android devices. In compression side, we've fixed many corner race conditions that had broken the design assumption. Enhancements: - Support file pinning for Zoned block device having large section - Enhance the data recovery after sudden power cut on Zoned block device - Add more error injection cases to easily detect the kernel panics - add a proc entry show the entire disk layout - Improve various error paths paniced by BUG_ON in block allocation and GC - support SEEK_DATA and SEEK_HOLE for compression files Bug fixes: - avoid use-after-free issue in f2fs_filemap_fault - fix some race conditions to break the atomic write design assumption - fix to truncate meta inode pages forcely - resolve various per-file compression issues wrt the space management and compression policies - fix some swap-related bugs In addition, we removed deprecated codes such as io_bits and heap_allocation, and also fixed minor error handling routines with neat debugging messages" * tag 'f2fs-for-6.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (60 commits) f2fs: fix to avoid use-after-free issue in f2fs_filemap_fault f2fs: truncate page cache before clearing flags when aborting atomic write f2fs: mark inode dirty for FI_ATOMIC_COMMITTED flag f2fs: prevent atomic write on pinned file f2fs: fix to handle error paths of {new,change}_curseg() f2fs: unify the error handling of f2fs_is_valid_blkaddr f2fs: zone: fix to remove pow2 check condition for zoned block device f2fs: fix to truncate meta inode pages forcely f2fs: compress: fix reserve_cblocks counting error when out of space f2fs: compress: relocate some judgments in f2fs_reserve_compress_blocks f2fs: add a proc entry show disk layout f2fs: introduce SEGS_TO_BLKS/BLKS_TO_SEGS for cleanup f2fs: fix to check return value of f2fs_gc_range f2fs: fix to check return value __allocate_new_segment f2fs: fix to do sanity check in update_sit_entry f2fs: fix to reset fields for unloaded curseg f2fs: clean up new_curseg() f2fs: relocate f2fs_precache_extents() in f2fs_swap_activate() f2fs: fix blkofs_end correctly in f2fs_migrate_blocks() f2fs: ro: don't start discard thread for readonly image ...
2 parents 0d7ca65 + eb70d5a commit c5d9ab8

File tree

22 files changed

+1054
-883
lines changed

22 files changed

+1054
-883
lines changed

Documentation/ABI/testing/sysfs-fs-f2fs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ Description: Controls the idle timing of system, if there is no FS operation
205205
What: /sys/fs/f2fs/<disk>/discard_idle_interval
206206
Date: September 2018
207207
Contact: "Chao Yu" <[email protected]>
208-
Contact: "Sahitya Tummala" <[email protected]>
208+
Contact: "Sahitya Tummala" <[email protected]>
209209
Description: Controls the idle timing of discard thread given
210210
this time interval.
211211
Default is 5 secs.
212212

213213
What: /sys/fs/f2fs/<disk>/gc_idle_interval
214214
Date: September 2018
215215
Contact: "Chao Yu" <[email protected]>
216-
Contact: "Sahitya Tummala" <[email protected]>
216+
Contact: "Sahitya Tummala" <[email protected]>
217217
Description: Controls the idle timing for gc path. Set to 5 seconds by default.
218218

219219
What: /sys/fs/f2fs/<disk>/iostat_enable
@@ -701,29 +701,31 @@ Description: Support configuring fault injection type, should be
701701
enabled with fault_injection option, fault type value
702702
is shown below, it supports single or combined type.
703703

704-
=================== ===========
705-
Type_Name Type_Value
706-
=================== ===========
707-
FAULT_KMALLOC 0x000000001
708-
FAULT_KVMALLOC 0x000000002
709-
FAULT_PAGE_ALLOC 0x000000004
710-
FAULT_PAGE_GET 0x000000008
711-
FAULT_ALLOC_BIO 0x000000010 (obsolete)
712-
FAULT_ALLOC_NID 0x000000020
713-
FAULT_ORPHAN 0x000000040
714-
FAULT_BLOCK 0x000000080
715-
FAULT_DIR_DEPTH 0x000000100
716-
FAULT_EVICT_INODE 0x000000200
717-
FAULT_TRUNCATE 0x000000400
718-
FAULT_READ_IO 0x000000800
719-
FAULT_CHECKPOINT 0x000001000
720-
FAULT_DISCARD 0x000002000
721-
FAULT_WRITE_IO 0x000004000
722-
FAULT_SLAB_ALLOC 0x000008000
723-
FAULT_DQUOT_INIT 0x000010000
724-
FAULT_LOCK_OP 0x000020000
725-
FAULT_BLKADDR 0x000040000
726-
=================== ===========
704+
=========================== ===========
705+
Type_Name Type_Value
706+
=========================== ===========
707+
FAULT_KMALLOC 0x000000001
708+
FAULT_KVMALLOC 0x000000002
709+
FAULT_PAGE_ALLOC 0x000000004
710+
FAULT_PAGE_GET 0x000000008
711+
FAULT_ALLOC_BIO 0x000000010 (obsolete)
712+
FAULT_ALLOC_NID 0x000000020
713+
FAULT_ORPHAN 0x000000040
714+
FAULT_BLOCK 0x000000080
715+
FAULT_DIR_DEPTH 0x000000100
716+
FAULT_EVICT_INODE 0x000000200
717+
FAULT_TRUNCATE 0x000000400
718+
FAULT_READ_IO 0x000000800
719+
FAULT_CHECKPOINT 0x000001000
720+
FAULT_DISCARD 0x000002000
721+
FAULT_WRITE_IO 0x000004000
722+
FAULT_SLAB_ALLOC 0x000008000
723+
FAULT_DQUOT_INIT 0x000010000
724+
FAULT_LOCK_OP 0x000020000
725+
FAULT_BLKADDR_VALIDITY 0x000040000
726+
FAULT_BLKADDR_CONSISTENCE 0x000080000
727+
FAULT_NO_SEGMENT 0x000100000
728+
=========================== ===========
727729

728730
What: /sys/fs/f2fs/<disk>/discard_io_aware_gran
729731
Date: January 2023

Documentation/filesystems/f2fs.rst

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read-
126126
discard/nodiscard Enable/disable real-time discard in f2fs, if discard is
127127
enabled, f2fs will issue discard/TRIM commands when a
128128
segment is cleaned.
129-
no_heap Disable heap-style segment allocation which finds free
130-
segments for data from the beginning of main area, while
131-
for node from the end of main area.
129+
heap/no_heap Deprecated.
132130
nouser_xattr Disable Extended User Attributes. Note: xattr is enabled
133131
by default if CONFIG_F2FS_FS_XATTR is selected.
134132
noacl Disable POSIX Access Control List. Note: acl is enabled
@@ -184,29 +182,31 @@ fault_type=%d Support configuring fault injection type, should be
184182
enabled with fault_injection option, fault type value
185183
is shown below, it supports single or combined type.
186184

187-
=================== ===========
188-
Type_Name Type_Value
189-
=================== ===========
190-
FAULT_KMALLOC 0x000000001
191-
FAULT_KVMALLOC 0x000000002
192-
FAULT_PAGE_ALLOC 0x000000004
193-
FAULT_PAGE_GET 0x000000008
194-
FAULT_ALLOC_BIO 0x000000010 (obsolete)
195-
FAULT_ALLOC_NID 0x000000020
196-
FAULT_ORPHAN 0x000000040
197-
FAULT_BLOCK 0x000000080
198-
FAULT_DIR_DEPTH 0x000000100
199-
FAULT_EVICT_INODE 0x000000200
200-
FAULT_TRUNCATE 0x000000400
201-
FAULT_READ_IO 0x000000800
202-
FAULT_CHECKPOINT 0x000001000
203-
FAULT_DISCARD 0x000002000
204-
FAULT_WRITE_IO 0x000004000
205-
FAULT_SLAB_ALLOC 0x000008000
206-
FAULT_DQUOT_INIT 0x000010000
207-
FAULT_LOCK_OP 0x000020000
208-
FAULT_BLKADDR 0x000040000
209-
=================== ===========
185+
=========================== ===========
186+
Type_Name Type_Value
187+
=========================== ===========
188+
FAULT_KMALLOC 0x000000001
189+
FAULT_KVMALLOC 0x000000002
190+
FAULT_PAGE_ALLOC 0x000000004
191+
FAULT_PAGE_GET 0x000000008
192+
FAULT_ALLOC_BIO 0x000000010 (obsolete)
193+
FAULT_ALLOC_NID 0x000000020
194+
FAULT_ORPHAN 0x000000040
195+
FAULT_BLOCK 0x000000080
196+
FAULT_DIR_DEPTH 0x000000100
197+
FAULT_EVICT_INODE 0x000000200
198+
FAULT_TRUNCATE 0x000000400
199+
FAULT_READ_IO 0x000000800
200+
FAULT_CHECKPOINT 0x000001000
201+
FAULT_DISCARD 0x000002000
202+
FAULT_WRITE_IO 0x000004000
203+
FAULT_SLAB_ALLOC 0x000008000
204+
FAULT_DQUOT_INIT 0x000010000
205+
FAULT_LOCK_OP 0x000020000
206+
FAULT_BLKADDR_VALIDITY 0x000040000
207+
FAULT_BLKADDR_CONSISTENCE 0x000080000
208+
FAULT_NO_SEGMENT 0x000100000
209+
=========================== ===========
210210
mode=%s Control block allocation mode which supports "adaptive"
211211
and "lfs". In "lfs" mode, there should be no random
212212
writes towards main area.
@@ -228,8 +228,6 @@ mode=%s Control block allocation mode which supports "adaptive"
228228
option for more randomness.
229229
Please, use these options for your experiments and we strongly
230230
recommend to re-format the filesystem after using these options.
231-
io_bits=%u Set the bit size of write IO requests. It should be set
232-
with "mode=lfs".
233231
usrquota Enable plain user disk quota accounting.
234232
grpquota Enable plain group disk quota accounting.
235233
prjquota Enable plain project quota accounting.

fs/f2fs/checkpoint.c

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -154,49 +154,47 @@ static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
154154
if (unlikely(f2fs_cp_error(sbi)))
155155
return exist;
156156

157-
if (exist && type == DATA_GENERIC_ENHANCE_UPDATE) {
158-
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
159-
blkaddr, exist);
160-
set_sbi_flag(sbi, SBI_NEED_FSCK);
161-
return exist;
162-
}
157+
if ((exist && type == DATA_GENERIC_ENHANCE_UPDATE) ||
158+
(!exist && type == DATA_GENERIC_ENHANCE))
159+
goto out_err;
160+
if (!exist && type != DATA_GENERIC_ENHANCE_UPDATE)
161+
goto out_handle;
162+
return exist;
163163

164-
if (!exist && type == DATA_GENERIC_ENHANCE) {
165-
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
166-
blkaddr, exist);
167-
set_sbi_flag(sbi, SBI_NEED_FSCK);
168-
dump_stack();
169-
}
164+
out_err:
165+
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
166+
blkaddr, exist);
167+
set_sbi_flag(sbi, SBI_NEED_FSCK);
168+
dump_stack();
169+
out_handle:
170+
f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
170171
return exist;
171172
}
172173

173-
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
174+
static bool __f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
174175
block_t blkaddr, int type)
175176
{
176-
if (time_to_inject(sbi, FAULT_BLKADDR))
177-
return false;
178-
179177
switch (type) {
180178
case META_NAT:
181179
break;
182180
case META_SIT:
183181
if (unlikely(blkaddr >= SIT_BLK_CNT(sbi)))
184-
return false;
182+
goto err;
185183
break;
186184
case META_SSA:
187185
if (unlikely(blkaddr >= MAIN_BLKADDR(sbi) ||
188186
blkaddr < SM_I(sbi)->ssa_blkaddr))
189-
return false;
187+
goto err;
190188
break;
191189
case META_CP:
192190
if (unlikely(blkaddr >= SIT_I(sbi)->sit_base_addr ||
193191
blkaddr < __start_cp_addr(sbi)))
194-
return false;
192+
goto err;
195193
break;
196194
case META_POR:
197195
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
198196
blkaddr < MAIN_BLKADDR(sbi)))
199-
return false;
197+
goto err;
200198
break;
201199
case DATA_GENERIC:
202200
case DATA_GENERIC_ENHANCE:
@@ -213,21 +211,38 @@ bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
213211
blkaddr);
214212
set_sbi_flag(sbi, SBI_NEED_FSCK);
215213
dump_stack();
216-
return false;
214+
goto err;
217215
} else {
218216
return __is_bitmap_valid(sbi, blkaddr, type);
219217
}
220218
break;
221219
case META_GENERIC:
222220
if (unlikely(blkaddr < SEG0_BLKADDR(sbi) ||
223221
blkaddr >= MAIN_BLKADDR(sbi)))
224-
return false;
222+
goto err;
225223
break;
226224
default:
227225
BUG();
228226
}
229227

230228
return true;
229+
err:
230+
f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
231+
return false;
232+
}
233+
234+
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
235+
block_t blkaddr, int type)
236+
{
237+
if (time_to_inject(sbi, FAULT_BLKADDR_VALIDITY))
238+
return false;
239+
return __f2fs_is_valid_blkaddr(sbi, blkaddr, type);
240+
}
241+
242+
bool f2fs_is_valid_blkaddr_raw(struct f2fs_sb_info *sbi,
243+
block_t blkaddr, int type)
244+
{
245+
return __f2fs_is_valid_blkaddr(sbi, blkaddr, type);
231246
}
232247

233248
/*
@@ -889,7 +904,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
889904

890905
cp_blocks = le32_to_cpu(cp_block->cp_pack_total_block_count);
891906

892-
if (cp_blocks > sbi->blocks_per_seg || cp_blocks <= F2FS_CP_PACKS) {
907+
if (cp_blocks > BLKS_PER_SEG(sbi) || cp_blocks <= F2FS_CP_PACKS) {
893908
f2fs_warn(sbi, "invalid cp_pack_total_block_count:%u",
894909
le32_to_cpu(cp_block->cp_pack_total_block_count));
895910
goto invalid_cp;
@@ -1324,7 +1339,7 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
13241339

13251340
if (cpc->reason & CP_UMOUNT) {
13261341
if (le32_to_cpu(ckpt->cp_pack_total_block_count) +
1327-
NM_I(sbi)->nat_bits_blocks > sbi->blocks_per_seg) {
1342+
NM_I(sbi)->nat_bits_blocks > BLKS_PER_SEG(sbi)) {
13281343
clear_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
13291344
f2fs_notice(sbi, "Disable nat_bits due to no space");
13301345
} else if (!is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG) &&
@@ -1527,7 +1542,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15271542
cp_ver |= ((__u64)crc32 << 32);
15281543
*(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
15291544

1530-
blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
1545+
blk = start_blk + BLKS_PER_SEG(sbi) - nm_i->nat_bits_blocks;
15311546
for (i = 0; i < nm_i->nat_bits_blocks; i++)
15321547
f2fs_update_meta_page(sbi, nm_i->nat_bits +
15331548
(i << F2FS_BLKSIZE_BITS), blk + i);
@@ -1587,8 +1602,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
15871602
*/
15881603
if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi) ||
15891604
f2fs_sb_has_compression(sbi))
1590-
invalidate_mapping_pages(META_MAPPING(sbi),
1591-
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
1605+
f2fs_bug_on(sbi,
1606+
invalidate_inode_pages2_range(META_MAPPING(sbi),
1607+
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1));
15921608

15931609
f2fs_release_ino_entry(sbi, false);
15941610

@@ -1730,9 +1746,9 @@ void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi)
17301746
im->ino_num = 0;
17311747
}
17321748

1733-
sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS -
1749+
sbi->max_orphans = (BLKS_PER_SEG(sbi) - F2FS_CP_PACKS -
17341750
NR_CURSEG_PERSIST_TYPE - __cp_payload(sbi)) *
1735-
F2FS_ORPHANS_PER_BLOCK;
1751+
F2FS_ORPHANS_PER_BLOCK;
17361752
}
17371753

17381754
int __init f2fs_create_checkpoint_caches(void)

0 commit comments

Comments
 (0)