Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'f2fs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs

Pull f2fs updates from Jaegeuk Kim:
"In this series, there are several major improvements such as folio
conversion by Matthew, speed-up of block truncation, and caching more
dentry pages.

In addition, we implemented a linear dentry search to address recent
unicode regression, and figured out some false alarms that we could
get rid of.

Enhancements:
- foilio conversion in various IO paths
- optimize f2fs_truncate_data_blocks_range()
- cache more dentry pages
- remove unnecessary blk_finish_plug
- procfs: show mtime in segment_bits

Bug fixes:
- introduce linear search for dentries
- don't call block truncation for aliased file
- fix using wrong 'submitted' value in f2fs_write_cache_pages
- fix to do sanity check correctly on i_inline_xattr_size
- avoid trying to get invalid block address
- fix inconsistent dirty state of atomic file"

* tag 'f2fs-for-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (32 commits)
f2fs: fix inconsistent dirty state of atomic file
f2fs: fix to avoid changing 'check only' behaior of recovery
f2fs: Clean up the loop outside of f2fs_invalidate_blocks()
f2fs: procfs: show mtime in segment_bits
f2fs: fix to avoid return invalid mtime from f2fs_get_section_mtime()
f2fs: Fix format specifier in sanity_check_inode()
f2fs: avoid trying to get invalid block address
f2fs: fix to do sanity check correctly on i_inline_xattr_size
f2fs: remove blk_finish_plug
f2fs: Optimize f2fs_truncate_data_blocks_range()
f2fs: fix using wrong 'submitted' value in f2fs_write_cache_pages
f2fs: add parameter @len to f2fs_invalidate_blocks()
f2fs: update_sit_entry_for_release() supports consecutive blocks.
f2fs: introduce update_sit_entry_for_release/alloc()
f2fs: don't call block truncation for aliased file
f2fs: Introduce linear search for dentries
f2fs: add parameter @len to f2fs_invalidate_internal_cache()
f2fs: expand f2fs_invalidate_compress_page() to f2fs_invalidate_compress_pages_range()
f2fs: ensure that node info flags are always initialized
f2fs: The GC triggered by ioctl also needs to mark the segno as victim
...

+336 -213
+23 -15
fs/f2fs/compress.c
··· 846 846 bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct page **pages, 847 847 int index, int nr_pages, bool uptodate) 848 848 { 849 - unsigned long pgidx = pages[index]->index; 849 + unsigned long pgidx = page_folio(pages[index])->index; 850 850 int i = uptodate ? 0 : 1; 851 851 852 852 /* ··· 860 860 return false; 861 861 862 862 for (; i < cc->cluster_size; i++) { 863 - if (pages[index + i]->index != pgidx + i) 863 + struct folio *folio = page_folio(pages[index + i]); 864 + 865 + if (folio->index != pgidx + i) 864 866 return false; 865 - if (uptodate && !PageUptodate(pages[index + i])) 867 + if (uptodate && !folio_test_uptodate(folio)) 866 868 return false; 867 869 } 868 870 ··· 1197 1195 .cluster_size = F2FS_I(inode)->i_cluster_size, 1198 1196 .rpages = fsdata, 1199 1197 }; 1200 - bool first_index = (index == cc.rpages[0]->index); 1198 + struct folio *folio = page_folio(cc.rpages[0]); 1199 + bool first_index = (index == folio->index); 1201 1200 1202 1201 if (copied) 1203 1202 set_cluster_dirty(&cc); ··· 1242 1239 int i; 1243 1240 1244 1241 for (i = cluster_size - 1; i >= 0; i--) { 1245 - loff_t start = rpages[i]->index << PAGE_SHIFT; 1242 + struct folio *folio = page_folio(rpages[i]); 1243 + loff_t start = folio->index << PAGE_SHIFT; 1246 1244 1247 1245 if (from <= start) { 1248 - zero_user_segment(rpages[i], 0, PAGE_SIZE); 1246 + folio_zero_segment(folio, 0, folio_size(folio)); 1249 1247 } else { 1250 - zero_user_segment(rpages[i], from - start, 1251 - PAGE_SIZE); 1248 + folio_zero_segment(folio, from - start, 1249 + folio_size(folio)); 1252 1250 break; 1253 1251 } 1254 1252 } ··· 1282 1278 .encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ? 1283 1279 1 : 0, 1284 1280 }; 1281 + struct folio *folio; 1285 1282 struct dnode_of_data dn; 1286 1283 struct node_info ni; 1287 1284 struct compress_io_ctx *cic; ··· 1294 1289 1295 1290 /* we should bypass data pages to proceed the kworker jobs */ 1296 1291 if (unlikely(f2fs_cp_error(sbi))) { 1297 - mapping_set_error(cc->rpages[0]->mapping, -EIO); 1292 + mapping_set_error(inode->i_mapping, -EIO); 1298 1293 goto out_free; 1299 1294 } 1300 1295 ··· 1321 1316 goto out_put_dnode; 1322 1317 } 1323 1318 1324 - psize = (loff_t)(cc->rpages[last_index]->index + 1) << PAGE_SHIFT; 1319 + folio = page_folio(cc->rpages[last_index]); 1320 + psize = folio_pos(folio) + folio_size(folio); 1325 1321 1326 1322 err = f2fs_get_node_info(fio.sbi, dn.nid, &ni, false); 1327 1323 if (err) ··· 1345 1339 1346 1340 for (i = 0; i < cc->valid_nr_cpages; i++) { 1347 1341 f2fs_set_compressed_page(cc->cpages[i], inode, 1348 - cc->rpages[i + 1]->index, cic); 1342 + page_folio(cc->rpages[i + 1])->index, cic); 1349 1343 fio.compressed_page = cc->cpages[i]; 1350 1344 1351 1345 fio.old_blkaddr = data_blkaddr(dn.inode, dn.node_page, ··· 1380 1374 if (blkaddr == COMPRESS_ADDR) 1381 1375 fio.compr_blocks++; 1382 1376 if (__is_valid_data_blkaddr(blkaddr)) 1383 - f2fs_invalidate_blocks(sbi, blkaddr); 1377 + f2fs_invalidate_blocks(sbi, blkaddr, 1); 1384 1378 f2fs_update_data_blkaddr(&dn, COMPRESS_ADDR); 1385 1379 goto unlock_continue; 1386 1380 } ··· 1390 1384 1391 1385 if (i > cc->valid_nr_cpages) { 1392 1386 if (__is_valid_data_blkaddr(blkaddr)) { 1393 - f2fs_invalidate_blocks(sbi, blkaddr); 1387 + f2fs_invalidate_blocks(sbi, blkaddr, 1); 1394 1388 f2fs_update_data_blkaddr(&dn, NEW_ADDR); 1395 1389 } 1396 1390 goto unlock_continue; ··· 1551 1545 if (!clear_page_dirty_for_io(cc->rpages[i])) 1552 1546 goto continue_unlock; 1553 1547 1548 + submitted = 0; 1554 1549 ret = f2fs_write_single_data_page(page_folio(cc->rpages[i]), 1555 1550 &submitted, 1556 1551 NULL, NULL, wbc, io_type, ··· 1910 1903 return sbi->compress_inode->i_mapping; 1911 1904 } 1912 1905 1913 - void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr) 1906 + void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi, 1907 + block_t blkaddr, unsigned int len) 1914 1908 { 1915 1909 if (!sbi->compress_inode) 1916 1910 return; 1917 - invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr); 1911 + invalidate_mapping_pages(COMPRESS_MAPPING(sbi), blkaddr, blkaddr + len - 1); 1918 1912 } 1919 1913 1920 1914 void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page,
+25 -37
fs/f2fs/data.c
··· 70 70 return false; 71 71 } 72 72 73 - static enum count_type __read_io_type(struct page *page) 73 + static enum count_type __read_io_type(struct folio *folio) 74 74 { 75 - struct address_space *mapping = page_file_mapping(page); 75 + struct address_space *mapping = folio->mapping; 76 76 77 77 if (mapping) { 78 78 struct inode *inode = mapping->host; ··· 136 136 */ 137 137 static void f2fs_finish_read_bio(struct bio *bio, bool in_task) 138 138 { 139 - struct bio_vec *bv; 140 - struct bvec_iter_all iter_all; 139 + struct folio_iter fi; 141 140 struct bio_post_read_ctx *ctx = bio->bi_private; 142 141 143 - bio_for_each_segment_all(bv, bio, iter_all) { 144 - struct page *page = bv->bv_page; 142 + bio_for_each_folio_all(fi, bio) { 143 + struct folio *folio = fi.folio; 145 144 146 - if (f2fs_is_compressed_page(page)) { 145 + if (f2fs_is_compressed_page(&folio->page)) { 147 146 if (ctx && !ctx->decompression_attempted) 148 - f2fs_end_read_compressed_page(page, true, 0, 147 + f2fs_end_read_compressed_page(&folio->page, true, 0, 149 148 in_task); 150 - f2fs_put_page_dic(page, in_task); 149 + f2fs_put_page_dic(&folio->page, in_task); 151 150 continue; 152 151 } 153 152 154 - if (bio->bi_status) 155 - ClearPageUptodate(page); 156 - else 157 - SetPageUptodate(page); 158 - dec_page_count(F2FS_P_SB(page), __read_io_type(page)); 159 - unlock_page(page); 153 + dec_page_count(F2FS_F_SB(folio), __read_io_type(folio)); 154 + folio_end_read(folio, bio->bi_status == 0); 160 155 } 161 156 162 157 if (ctx) ··· 511 516 enum page_type type) 512 517 { 513 518 WARN_ON_ONCE(is_read_io(bio_op(bio))); 514 - 515 - if (f2fs_lfs_mode(sbi) && current->plug && PAGE_TYPE_ON_MAIN(type)) 516 - blk_finish_plug(current->plug); 517 - 518 519 trace_f2fs_submit_write_bio(sbi->sb, type, bio); 519 520 iostat_update_submit_ctx(bio, type); 520 521 submit_bio(bio); ··· 680 689 int f2fs_submit_page_bio(struct f2fs_io_info *fio) 681 690 { 682 691 struct bio *bio; 683 - struct page *page = fio->encrypted_page ? 684 - fio->encrypted_page : fio->page; 692 + struct folio *fio_folio = page_folio(fio->page); 693 + struct folio *data_folio = fio->encrypted_page ? 694 + page_folio(fio->encrypted_page) : fio_folio; 685 695 686 696 if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr, 687 697 fio->is_por ? META_POR : (__is_meta_io(fio) ? 688 698 META_GENERIC : DATA_GENERIC_ENHANCE))) 689 699 return -EFSCORRUPTED; 690 700 691 - trace_f2fs_submit_page_bio(page, fio); 701 + trace_f2fs_submit_folio_bio(data_folio, fio); 692 702 693 703 /* Allocate a new bio */ 694 704 bio = __bio_alloc(fio, 1); 695 705 696 - f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host, 697 - page_folio(fio->page)->index, fio, GFP_NOIO); 698 - 699 - if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { 700 - bio_put(bio); 701 - return -EFAULT; 702 - } 706 + f2fs_set_bio_crypt_ctx(bio, fio_folio->mapping->host, 707 + fio_folio->index, fio, GFP_NOIO); 708 + bio_add_folio_nofail(bio, data_folio, folio_size(data_folio), 0); 703 709 704 710 if (fio->io_wbc && !is_read_io(fio->op)) 705 - wbc_account_cgroup_owner(fio->io_wbc, page_folio(fio->page), 706 - PAGE_SIZE); 711 + wbc_account_cgroup_owner(fio->io_wbc, fio_folio, PAGE_SIZE); 707 712 708 713 inc_page_count(fio->sbi, is_read_io(fio->op) ? 709 - __read_io_type(page) : WB_DATA_TYPE(fio->page, false)); 714 + __read_io_type(data_folio) : WB_DATA_TYPE(fio->page, false)); 710 715 711 716 if (is_read_io(bio_op(bio))) 712 717 f2fs_submit_read_bio(fio->sbi, bio, fio->type); ··· 881 894 __is_meta_io(fio) ? META_GENERIC : DATA_GENERIC)) 882 895 return -EFSCORRUPTED; 883 896 884 - trace_f2fs_submit_page_bio(page, fio); 897 + trace_f2fs_submit_folio_bio(page_folio(page), fio); 885 898 886 899 if (bio && !page_is_mergeable(fio->sbi, bio, *fio->last_block, 887 900 fio->new_blkaddr)) ··· 1005 1018 1006 1019 io->last_block_in_bio = fio->new_blkaddr; 1007 1020 1008 - trace_f2fs_submit_page_write(fio->page, fio); 1021 + trace_f2fs_submit_folio_write(page_folio(fio->page), fio); 1009 1022 #ifdef CONFIG_BLK_DEV_ZONED 1010 1023 if (f2fs_sb_has_blkzoned(sbi) && btype < META && 1011 1024 is_end_zone_blkaddr(sbi, fio->new_blkaddr)) { ··· 1276 1289 struct address_space *mapping = inode->i_mapping; 1277 1290 struct page *page; 1278 1291 1279 - page = find_get_page(mapping, index); 1292 + page = find_get_page_flags(mapping, index, FGP_ACCESSED); 1280 1293 if (page && PageUptodate(page)) 1281 1294 return page; 1282 1295 f2fs_put_page(page, 0); ··· 1410 1423 return err; 1411 1424 1412 1425 if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) 1413 - f2fs_invalidate_internal_cache(sbi, old_blkaddr); 1426 + f2fs_invalidate_internal_cache(sbi, old_blkaddr, 1); 1414 1427 1415 1428 f2fs_update_data_blkaddr(dn, dn->data_blkaddr); 1416 1429 return 0; ··· 2451 2464 2452 2465 static int f2fs_read_data_folio(struct file *file, struct folio *folio) 2453 2466 { 2454 - struct inode *inode = folio_file_mapping(folio)->host; 2467 + struct inode *inode = folio->mapping->host; 2455 2468 int ret = -EAGAIN; 2456 2469 2457 2470 trace_f2fs_readpage(folio, DATA); ··· 3150 3163 continue; 3151 3164 } 3152 3165 #endif 3166 + submitted = 0; 3153 3167 ret = f2fs_write_single_data_page(folio, 3154 3168 &submitted, &bio, &last_block, 3155 3169 wbc, io_type, 0, true);
+38 -15
fs/f2fs/dir.c
··· 175 175 static struct f2fs_dir_entry *find_in_block(struct inode *dir, 176 176 struct page *dentry_page, 177 177 const struct f2fs_filename *fname, 178 - int *max_slots) 178 + int *max_slots, 179 + bool use_hash) 179 180 { 180 181 struct f2fs_dentry_block *dentry_blk; 181 182 struct f2fs_dentry_ptr d; ··· 184 183 dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page); 185 184 186 185 make_dentry_ptr_block(dir, &d, dentry_blk); 187 - return f2fs_find_target_dentry(&d, fname, max_slots); 186 + return f2fs_find_target_dentry(&d, fname, max_slots, use_hash); 188 187 } 189 188 190 189 static inline int f2fs_match_name(const struct inode *dir, ··· 209 208 } 210 209 211 210 struct f2fs_dir_entry *f2fs_find_target_dentry(const struct f2fs_dentry_ptr *d, 212 - const struct f2fs_filename *fname, int *max_slots) 211 + const struct f2fs_filename *fname, int *max_slots, 212 + bool use_hash) 213 213 { 214 214 struct f2fs_dir_entry *de; 215 215 unsigned long bit_pos = 0; ··· 233 231 continue; 234 232 } 235 233 236 - if (de->hash_code == fname->hash) { 234 + if (!use_hash || de->hash_code == fname->hash) { 237 235 res = f2fs_match_name(d->inode, fname, 238 236 d->filename[bit_pos], 239 237 le16_to_cpu(de->name_len)); ··· 260 258 static struct f2fs_dir_entry *find_in_level(struct inode *dir, 261 259 unsigned int level, 262 260 const struct f2fs_filename *fname, 263 - struct page **res_page) 261 + struct page **res_page, 262 + bool use_hash) 264 263 { 265 264 int s = GET_DENTRY_SLOTS(fname->disk_name.len); 266 265 unsigned int nbucket, nblock; 267 - unsigned int bidx, end_block; 266 + unsigned int bidx, end_block, bucket_no; 268 267 struct page *dentry_page; 269 268 struct f2fs_dir_entry *de = NULL; 270 269 pgoff_t next_pgofs; ··· 275 272 nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level); 276 273 nblock = bucket_blocks(level); 277 274 275 + bucket_no = use_hash ? le32_to_cpu(fname->hash) % nbucket : 0; 276 + 277 + start_find_bucket: 278 278 bidx = dir_block_index(level, F2FS_I(dir)->i_dir_level, 279 - le32_to_cpu(fname->hash) % nbucket); 279 + bucket_no); 280 280 end_block = bidx + nblock; 281 281 282 282 while (bidx < end_block) { ··· 296 290 } 297 291 } 298 292 299 - de = find_in_block(dir, dentry_page, fname, &max_slots); 293 + de = find_in_block(dir, dentry_page, fname, &max_slots, use_hash); 300 294 if (IS_ERR(de)) { 301 295 *res_page = ERR_CAST(de); 302 296 de = NULL; ··· 313 307 bidx++; 314 308 } 315 309 316 - if (!de && room && F2FS_I(dir)->chash != fname->hash) { 317 - F2FS_I(dir)->chash = fname->hash; 318 - F2FS_I(dir)->clevel = level; 319 - } 310 + if (de) 311 + return de; 320 312 321 - return de; 313 + if (likely(use_hash)) { 314 + if (room && F2FS_I(dir)->chash != fname->hash) { 315 + F2FS_I(dir)->chash = fname->hash; 316 + F2FS_I(dir)->clevel = level; 317 + } 318 + } else if (++bucket_no < nbucket) { 319 + goto start_find_bucket; 320 + } 321 + return NULL; 322 322 } 323 323 324 324 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, ··· 335 323 struct f2fs_dir_entry *de = NULL; 336 324 unsigned int max_depth; 337 325 unsigned int level; 326 + bool use_hash = true; 338 327 339 328 *res_page = NULL; 340 329 330 + #if IS_ENABLED(CONFIG_UNICODE) 331 + start_find_entry: 332 + #endif 341 333 if (f2fs_has_inline_dentry(dir)) { 342 - de = f2fs_find_in_inline_dir(dir, fname, res_page); 334 + de = f2fs_find_in_inline_dir(dir, fname, res_page, use_hash); 343 335 goto out; 344 336 } 345 337 ··· 359 343 } 360 344 361 345 for (level = 0; level < max_depth; level++) { 362 - de = find_in_level(dir, level, fname, res_page); 346 + de = find_in_level(dir, level, fname, res_page, use_hash); 363 347 if (de || IS_ERR(*res_page)) 364 348 break; 365 349 } 350 + 366 351 out: 352 + #if IS_ENABLED(CONFIG_UNICODE) 353 + if (IS_CASEFOLDED(dir) && !de && use_hash) { 354 + use_hash = false; 355 + goto start_find_entry; 356 + } 357 + #endif 367 358 /* This is to increase the speed of f2fs_create */ 368 359 if (!de) 369 360 F2FS_I(dir)->task = current;
+19 -10
fs/f2fs/f2fs.h
··· 1985 1985 return F2FS_I_SB(mapping->host); 1986 1986 } 1987 1987 1988 + static inline struct f2fs_sb_info *F2FS_F_SB(struct folio *folio) 1989 + { 1990 + return F2FS_M_SB(folio->mapping); 1991 + } 1992 + 1988 1993 static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page) 1989 1994 { 1990 - return F2FS_M_SB(page_file_mapping(page)); 1995 + return F2FS_F_SB(page_folio(page)); 1991 1996 } 1992 1997 1993 1998 static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) ··· 3570 3565 struct f2fs_filename *fname); 3571 3566 void f2fs_free_filename(struct f2fs_filename *fname); 3572 3567 struct f2fs_dir_entry *f2fs_find_target_dentry(const struct f2fs_dentry_ptr *d, 3573 - const struct f2fs_filename *fname, int *max_slots); 3568 + const struct f2fs_filename *fname, int *max_slots, 3569 + bool use_hash); 3574 3570 int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, 3575 3571 unsigned int start_pos, struct fscrypt_str *fstr); 3576 3572 void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent, ··· 3706 3700 int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi); 3707 3701 int f2fs_flush_device_cache(struct f2fs_sb_info *sbi); 3708 3702 void f2fs_destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free); 3709 - void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr); 3703 + void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr, 3704 + unsigned int len); 3710 3705 bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr); 3711 3706 int f2fs_start_discard_thread(struct f2fs_sb_info *sbi); 3712 3707 void f2fs_drop_discard_cmd(struct f2fs_sb_info *sbi); ··· 4208 4201 int f2fs_recover_inline_data(struct inode *inode, struct page *npage); 4209 4202 struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir, 4210 4203 const struct f2fs_filename *fname, 4211 - struct page **res_page); 4204 + struct page **res_page, 4205 + bool use_hash); 4212 4206 int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent, 4213 4207 struct page *ipage); 4214 4208 int f2fs_add_inline_entry(struct inode *dir, const struct f2fs_filename *fname, ··· 4376 4368 int __init f2fs_init_compress_cache(void); 4377 4369 void f2fs_destroy_compress_cache(void); 4378 4370 struct address_space *COMPRESS_MAPPING(struct f2fs_sb_info *sbi); 4379 - void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, block_t blkaddr); 4371 + void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi, 4372 + block_t blkaddr, unsigned int len); 4380 4373 void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, struct page *page, 4381 4374 nid_t ino, block_t blkaddr); 4382 4375 bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, struct page *page, ··· 4432 4423 static inline void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) { } 4433 4424 static inline int __init f2fs_init_compress_cache(void) { return 0; } 4434 4425 static inline void f2fs_destroy_compress_cache(void) { } 4435 - static inline void f2fs_invalidate_compress_page(struct f2fs_sb_info *sbi, 4436 - block_t blkaddr) { } 4426 + static inline void f2fs_invalidate_compress_pages_range(struct f2fs_sb_info *sbi, 4427 + block_t blkaddr, unsigned int len) { } 4437 4428 static inline void f2fs_cache_compressed_page(struct f2fs_sb_info *sbi, 4438 4429 struct page *page, nid_t ino, block_t blkaddr) { } 4439 4430 static inline bool f2fs_load_compressed_page(struct f2fs_sb_info *sbi, ··· 4749 4740 } 4750 4741 4751 4742 static inline void f2fs_invalidate_internal_cache(struct f2fs_sb_info *sbi, 4752 - block_t blkaddr) 4743 + block_t blkaddr, unsigned int len) 4753 4744 { 4754 - f2fs_truncate_meta_inode_pages(sbi, blkaddr, 1); 4755 - f2fs_invalidate_compress_page(sbi, blkaddr); 4745 + f2fs_truncate_meta_inode_pages(sbi, blkaddr, len); 4746 + f2fs_invalidate_compress_pages_range(sbi, blkaddr, len); 4756 4747 } 4757 4748 4758 4749 #define EFSBADCRC EBADMSG /* Bad CRC detected */
+28 -9
fs/f2fs/file.c
··· 621 621 int cluster_index = 0, valid_blocks = 0; 622 622 int cluster_size = F2FS_I(dn->inode)->i_cluster_size; 623 623 bool released = !atomic_read(&F2FS_I(dn->inode)->i_compr_blocks); 624 + block_t blkstart; 625 + int blklen = 0; 624 626 625 627 addr = get_dnode_addr(dn->inode, dn->node_page) + ofs; 628 + blkstart = le32_to_cpu(*addr); 626 629 627 630 /* Assumption: truncation starts with cluster */ 628 631 for (; count > 0; count--, addr++, dn->ofs_in_node++, cluster_index++) { ··· 641 638 } 642 639 643 640 if (blkaddr == NULL_ADDR) 644 - continue; 641 + goto next; 645 642 646 643 f2fs_set_data_blkaddr(dn, NULL_ADDR); 647 644 648 645 if (__is_valid_data_blkaddr(blkaddr)) { 649 646 if (time_to_inject(sbi, FAULT_BLKADDR_CONSISTENCE)) 650 - continue; 647 + goto next; 651 648 if (!f2fs_is_valid_blkaddr_raw(sbi, blkaddr, 652 649 DATA_GENERIC_ENHANCE)) 653 - continue; 650 + goto next; 654 651 if (compressed_cluster) 655 652 valid_blocks++; 656 653 } 657 654 658 - f2fs_invalidate_blocks(sbi, blkaddr); 655 + if (blkstart + blklen == blkaddr) { 656 + blklen++; 657 + } else { 658 + f2fs_invalidate_blocks(sbi, blkstart, blklen); 659 + blkstart = blkaddr; 660 + blklen = 1; 661 + } 659 662 660 663 if (!released || blkaddr != COMPRESS_ADDR) 661 664 nr_free++; 665 + 666 + continue; 667 + 668 + next: 669 + if (blklen) 670 + f2fs_invalidate_blocks(sbi, blkstart, blklen); 671 + 672 + blkstart = le32_to_cpu(*(addr + 1)); 673 + blklen = 0; 662 674 } 675 + 676 + if (blklen) 677 + f2fs_invalidate_blocks(sbi, blkstart, blklen); 663 678 664 679 if (compressed_cluster) 665 680 f2fs_i_compr_blocks_update(dn->inode, valid_blocks, false); ··· 768 747 if (IS_DEVICE_ALIASING(inode)) { 769 748 struct extent_tree *et = F2FS_I(inode)->extent_tree[EX_READ]; 770 749 struct extent_info ei = et->largest; 771 - unsigned int i; 772 750 773 - for (i = 0; i < ei.len; i++) 774 - f2fs_invalidate_blocks(sbi, ei.blk + i); 751 + f2fs_invalidate_blocks(sbi, ei.blk, ei.len); 775 752 776 753 dec_valid_block_count(sbi, inode, ei.len); 777 754 f2fs_update_time(sbi, REQ_TIME); ··· 1342 1323 ret = f2fs_get_dnode_of_data(&dn, off + i, LOOKUP_NODE_RA); 1343 1324 if (ret) { 1344 1325 dec_valid_block_count(sbi, inode, 1); 1345 - f2fs_invalidate_blocks(sbi, *blkaddr); 1326 + f2fs_invalidate_blocks(sbi, *blkaddr, 1); 1346 1327 } else { 1347 1328 f2fs_update_data_blkaddr(&dn, *blkaddr); 1348 1329 } ··· 1594 1575 break; 1595 1576 } 1596 1577 1597 - f2fs_invalidate_blocks(sbi, dn->data_blkaddr); 1578 + f2fs_invalidate_blocks(sbi, dn->data_blkaddr, 1); 1598 1579 f2fs_set_data_blkaddr(dn, NEW_ADDR); 1599 1580 } 1600 1581
+8 -5
fs/f2fs/gc.c
··· 806 806 goto out; 807 807 } 808 808 809 - if (sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result))) 809 + if (sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result))) { 810 810 ret = -EBUSY; 811 - else 812 - p.min_segno = *result; 813 - goto out; 811 + goto out; 812 + } 813 + if (gc_type == FG_GC) 814 + clear_bit(GET_SEC_FROM_SEG(sbi, *result), dirty_i->victim_secmap); 815 + p.min_segno = *result; 816 + goto got_result; 814 817 } 815 818 816 819 ret = -ENODATA; ··· 1415 1412 page_address(mpage), PAGE_SIZE); 1416 1413 f2fs_put_page(mpage, 1); 1417 1414 1418 - f2fs_invalidate_internal_cache(fio.sbi, fio.old_blkaddr); 1415 + f2fs_invalidate_internal_cache(fio.sbi, fio.old_blkaddr, 1); 1419 1416 1420 1417 set_page_dirty(fio.encrypted_page); 1421 1418 if (clear_page_dirty_for_io(fio.encrypted_page))
+4 -3
fs/f2fs/inline.c
··· 81 81 82 82 void f2fs_do_read_inline_data(struct folio *folio, struct page *ipage) 83 83 { 84 - struct inode *inode = folio_file_mapping(folio)->host; 84 + struct inode *inode = folio->mapping->host; 85 85 86 86 if (folio_test_uptodate(folio)) 87 87 return; ··· 352 352 353 353 struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir, 354 354 const struct f2fs_filename *fname, 355 - struct page **res_page) 355 + struct page **res_page, 356 + bool use_hash) 356 357 { 357 358 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 358 359 struct f2fs_dir_entry *de; ··· 370 369 inline_dentry = inline_data_addr(dir, ipage); 371 370 372 371 make_dentry_ptr_inline(dir, &d, inline_dentry); 373 - de = f2fs_find_target_dentry(&d, fname, NULL); 372 + de = f2fs_find_target_dentry(&d, fname, NULL, use_hash); 374 373 unlock_page(ipage); 375 374 if (IS_ERR(de)) { 376 375 *res_page = ERR_CAST(de);
+10 -9
fs/f2fs/inode.c
··· 302 302 F2FS_TOTAL_EXTRA_ATTR_SIZE); 303 303 return false; 304 304 } 305 - if (f2fs_sb_has_flexible_inline_xattr(sbi) && 306 - f2fs_has_inline_xattr(inode) && 307 - (!fi->i_inline_xattr_size || 308 - fi->i_inline_xattr_size > MAX_INLINE_XATTR_SIZE)) { 309 - f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_inline_xattr_size: %d, max: %lu", 310 - __func__, inode->i_ino, fi->i_inline_xattr_size, 311 - MAX_INLINE_XATTR_SIZE); 312 - return false; 313 - } 314 305 if (f2fs_sb_has_compression(sbi) && 315 306 fi->i_flags & F2FS_COMPR_FL && 316 307 F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, ··· 309 318 if (!sanity_check_compress_inode(inode, ri)) 310 319 return false; 311 320 } 321 + } 322 + 323 + if (f2fs_sb_has_flexible_inline_xattr(sbi) && 324 + f2fs_has_inline_xattr(inode) && 325 + (fi->i_inline_xattr_size < MIN_INLINE_XATTR_SIZE || 326 + fi->i_inline_xattr_size > MAX_INLINE_XATTR_SIZE)) { 327 + f2fs_warn(sbi, "%s: inode (ino=%lx) has corrupted i_inline_xattr_size: %d, min: %zu, max: %lu", 328 + __func__, inode->i_ino, fi->i_inline_xattr_size, 329 + MIN_INLINE_XATTR_SIZE, MAX_INLINE_XATTR_SIZE); 330 + return false; 312 331 } 313 332 314 333 if (!f2fs_sb_has_extra_attr(sbi)) {
+1
fs/f2fs/namei.c
··· 341 341 trace_f2fs_new_inode(inode, err); 342 342 dquot_drop(inode); 343 343 inode->i_flags |= S_NOQUOTA; 344 + make_bad_inode(inode); 344 345 if (nid_free) 345 346 set_inode_flag(inode, FI_FREE_NID); 346 347 clear_nlink(inode);
+6 -4
fs/f2fs/node.c
··· 558 558 block_t blkaddr; 559 559 int i; 560 560 561 + ni->flag = 0; 561 562 ni->nid = nid; 562 563 retry: 563 564 /* Check nat cache */ ··· 917 916 } 918 917 919 918 /* Deallocate node address */ 920 - f2fs_invalidate_blocks(sbi, ni.blk_addr); 919 + f2fs_invalidate_blocks(sbi, ni.blk_addr, 1); 921 920 dec_valid_node_count(sbi, dn->inode, dn->nid == dn->inode->i_ino); 922 921 set_node_addr(sbi, &ni, NULL_ADDR, false); 923 922 ··· 1275 1274 } 1276 1275 1277 1276 /* remove potential inline_data blocks */ 1278 - if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1279 - S_ISLNK(inode->i_mode)) 1277 + if (!IS_DEVICE_ALIASING(inode) && 1278 + (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 1279 + S_ISLNK(inode->i_mode))) 1280 1280 f2fs_truncate_data_blocks_range(&dn, 1); 1281 1281 1282 1282 /* 0 is possible, after f2fs_new_inode() has failed */ ··· 2765 2763 if (err) 2766 2764 return err; 2767 2765 2768 - f2fs_invalidate_blocks(sbi, ni.blk_addr); 2766 + f2fs_invalidate_blocks(sbi, ni.blk_addr, 1); 2769 2767 dec_valid_node_count(sbi, inode, false); 2770 2768 set_node_addr(sbi, &ni, NULL_ADDR, false); 2771 2769
+1 -3
fs/f2fs/recovery.c
··· 899 899 * and the f2fs is not read only, check and fix zoned block devices' 900 900 * write pointer consistency. 901 901 */ 902 - if (!err) { 902 + if (!err) 903 903 err = f2fs_check_and_fix_write_pointer(sbi); 904 - ret = err; 905 - } 906 904 907 905 if (!err) 908 906 clear_sbi_flag(sbi, SBI_POR_DOING);
+152 -82
fs/f2fs/segment.c
··· 201 201 clear_inode_flag(inode, FI_ATOMIC_FILE); 202 202 if (is_inode_flag_set(inode, FI_ATOMIC_DIRTIED)) { 203 203 clear_inode_flag(inode, FI_ATOMIC_DIRTIED); 204 + /* 205 + * The vfs inode keeps clean during commit, but the f2fs inode 206 + * doesn't. So clear the dirty state after commit and let 207 + * f2fs_mark_inode_dirty_sync ensure a consistent dirty state. 208 + */ 209 + f2fs_inode_synced(inode); 204 210 f2fs_mark_inode_dirty_sync(inode, true); 205 211 } 206 212 stat_dec_atomic_inode(inode); ··· 251 245 if (!__is_valid_data_blkaddr(new_addr)) { 252 246 if (new_addr == NULL_ADDR) 253 247 dec_valid_block_count(sbi, inode, 1); 254 - f2fs_invalidate_blocks(sbi, dn.data_blkaddr); 248 + f2fs_invalidate_blocks(sbi, dn.data_blkaddr, 1); 255 249 f2fs_update_data_blkaddr(&dn, new_addr); 256 250 } else { 257 251 f2fs_replace_block(sbi, &dn, dn.data_blkaddr, ··· 2432 2426 SIT_I(sbi)->max_mtime = ctime; 2433 2427 } 2434 2428 2429 + /* 2430 + * NOTE: when updating multiple blocks at the same time, please ensure 2431 + * that the consecutive input blocks belong to the same segment. 2432 + */ 2433 + static int update_sit_entry_for_release(struct f2fs_sb_info *sbi, struct seg_entry *se, 2434 + block_t blkaddr, unsigned int offset, int del) 2435 + { 2436 + bool exist; 2437 + #ifdef CONFIG_F2FS_CHECK_FS 2438 + bool mir_exist; 2439 + #endif 2440 + int i; 2441 + int del_count = -del; 2442 + 2443 + f2fs_bug_on(sbi, GET_SEGNO(sbi, blkaddr) != GET_SEGNO(sbi, blkaddr + del_count - 1)); 2444 + 2445 + for (i = 0; i < del_count; i++) { 2446 + exist = f2fs_test_and_clear_bit(offset + i, se->cur_valid_map); 2447 + #ifdef CONFIG_F2FS_CHECK_FS 2448 + mir_exist = f2fs_test_and_clear_bit(offset + i, 2449 + se->cur_valid_map_mir); 2450 + if (unlikely(exist != mir_exist)) { 2451 + f2fs_err(sbi, "Inconsistent error when clearing bitmap, blk:%u, old bit:%d", 2452 + blkaddr + i, exist); 2453 + f2fs_bug_on(sbi, 1); 2454 + } 2455 + #endif 2456 + if (unlikely(!exist)) { 2457 + f2fs_err(sbi, "Bitmap was wrongly cleared, blk:%u", blkaddr + i); 2458 + f2fs_bug_on(sbi, 1); 2459 + se->valid_blocks++; 2460 + del += 1; 2461 + } else if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { 2462 + /* 2463 + * If checkpoints are off, we must not reuse data that 2464 + * was used in the previous checkpoint. If it was used 2465 + * before, we must track that to know how much space we 2466 + * really have. 2467 + */ 2468 + if (f2fs_test_bit(offset + i, se->ckpt_valid_map)) { 2469 + spin_lock(&sbi->stat_lock); 2470 + sbi->unusable_block_count++; 2471 + spin_unlock(&sbi->stat_lock); 2472 + } 2473 + } 2474 + 2475 + if (f2fs_block_unit_discard(sbi) && 2476 + f2fs_test_and_clear_bit(offset + i, se->discard_map)) 2477 + sbi->discard_blks++; 2478 + 2479 + if (!f2fs_test_bit(offset + i, se->ckpt_valid_map)) 2480 + se->ckpt_valid_blocks -= 1; 2481 + } 2482 + 2483 + return del; 2484 + } 2485 + 2486 + static int update_sit_entry_for_alloc(struct f2fs_sb_info *sbi, struct seg_entry *se, 2487 + block_t blkaddr, unsigned int offset, int del) 2488 + { 2489 + bool exist; 2490 + #ifdef CONFIG_F2FS_CHECK_FS 2491 + bool mir_exist; 2492 + #endif 2493 + 2494 + exist = f2fs_test_and_set_bit(offset, se->cur_valid_map); 2495 + #ifdef CONFIG_F2FS_CHECK_FS 2496 + mir_exist = f2fs_test_and_set_bit(offset, 2497 + se->cur_valid_map_mir); 2498 + if (unlikely(exist != mir_exist)) { 2499 + f2fs_err(sbi, "Inconsistent error when setting bitmap, blk:%u, old bit:%d", 2500 + blkaddr, exist); 2501 + f2fs_bug_on(sbi, 1); 2502 + } 2503 + #endif 2504 + if (unlikely(exist)) { 2505 + f2fs_err(sbi, "Bitmap was wrongly set, blk:%u", blkaddr); 2506 + f2fs_bug_on(sbi, 1); 2507 + se->valid_blocks--; 2508 + del = 0; 2509 + } 2510 + 2511 + if (f2fs_block_unit_discard(sbi) && 2512 + !f2fs_test_and_set_bit(offset, se->discard_map)) 2513 + sbi->discard_blks--; 2514 + 2515 + /* 2516 + * SSR should never reuse block which is checkpointed 2517 + * or newly invalidated. 2518 + */ 2519 + if (!is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { 2520 + if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map)) 2521 + se->ckpt_valid_blocks++; 2522 + } 2523 + 2524 + if (!f2fs_test_bit(offset, se->ckpt_valid_map)) 2525 + se->ckpt_valid_blocks += del; 2526 + 2527 + return del; 2528 + } 2529 + 2530 + /* 2531 + * If releasing blocks, this function supports updating multiple consecutive blocks 2532 + * at one time, but please note that these consecutive blocks need to belong to the 2533 + * same segment. 2534 + */ 2435 2535 static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) 2436 2536 { 2437 2537 struct seg_entry *se; 2438 2538 unsigned int segno, offset; 2439 2539 long int new_vblocks; 2440 - bool exist; 2441 - #ifdef CONFIG_F2FS_CHECK_FS 2442 - bool mir_exist; 2443 - #endif 2444 2540 2445 2541 segno = GET_SEGNO(sbi, blkaddr); 2446 2542 if (segno == NULL_SEGNO) ··· 2559 2451 2560 2452 /* Update valid block bitmap */ 2561 2453 if (del > 0) { 2562 - exist = f2fs_test_and_set_bit(offset, se->cur_valid_map); 2563 - #ifdef CONFIG_F2FS_CHECK_FS 2564 - mir_exist = f2fs_test_and_set_bit(offset, 2565 - se->cur_valid_map_mir); 2566 - if (unlikely(exist != mir_exist)) { 2567 - f2fs_err(sbi, "Inconsistent error when setting bitmap, blk:%u, old bit:%d", 2568 - blkaddr, exist); 2569 - f2fs_bug_on(sbi, 1); 2570 - } 2571 - #endif 2572 - if (unlikely(exist)) { 2573 - f2fs_err(sbi, "Bitmap was wrongly set, blk:%u", 2574 - blkaddr); 2575 - f2fs_bug_on(sbi, 1); 2576 - se->valid_blocks--; 2577 - del = 0; 2578 - } 2579 - 2580 - if (f2fs_block_unit_discard(sbi) && 2581 - !f2fs_test_and_set_bit(offset, se->discard_map)) 2582 - sbi->discard_blks--; 2583 - 2584 - /* 2585 - * SSR should never reuse block which is checkpointed 2586 - * or newly invalidated. 2587 - */ 2588 - if (!is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { 2589 - if (!f2fs_test_and_set_bit(offset, se->ckpt_valid_map)) 2590 - se->ckpt_valid_blocks++; 2591 - } 2454 + del = update_sit_entry_for_alloc(sbi, se, blkaddr, offset, del); 2592 2455 } else { 2593 - exist = f2fs_test_and_clear_bit(offset, se->cur_valid_map); 2594 - #ifdef CONFIG_F2FS_CHECK_FS 2595 - mir_exist = f2fs_test_and_clear_bit(offset, 2596 - se->cur_valid_map_mir); 2597 - if (unlikely(exist != mir_exist)) { 2598 - f2fs_err(sbi, "Inconsistent error when clearing bitmap, blk:%u, old bit:%d", 2599 - blkaddr, exist); 2600 - f2fs_bug_on(sbi, 1); 2601 - } 2602 - #endif 2603 - if (unlikely(!exist)) { 2604 - f2fs_err(sbi, "Bitmap was wrongly cleared, blk:%u", 2605 - blkaddr); 2606 - f2fs_bug_on(sbi, 1); 2607 - se->valid_blocks++; 2608 - del = 0; 2609 - } else if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { 2610 - /* 2611 - * If checkpoints are off, we must not reuse data that 2612 - * was used in the previous checkpoint. If it was used 2613 - * before, we must track that to know how much space we 2614 - * really have. 2615 - */ 2616 - if (f2fs_test_bit(offset, se->ckpt_valid_map)) { 2617 - spin_lock(&sbi->stat_lock); 2618 - sbi->unusable_block_count++; 2619 - spin_unlock(&sbi->stat_lock); 2620 - } 2621 - } 2622 - 2623 - if (f2fs_block_unit_discard(sbi) && 2624 - f2fs_test_and_clear_bit(offset, se->discard_map)) 2625 - sbi->discard_blks++; 2456 + del = update_sit_entry_for_release(sbi, se, blkaddr, offset, del); 2626 2457 } 2627 - if (!f2fs_test_bit(offset, se->ckpt_valid_map)) 2628 - se->ckpt_valid_blocks += del; 2629 2458 2630 2459 __mark_sit_entry_dirty(sbi, segno); 2631 2460 ··· 2573 2528 get_sec_entry(sbi, segno)->valid_blocks += del; 2574 2529 } 2575 2530 2576 - void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr) 2531 + void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr, 2532 + unsigned int len) 2577 2533 { 2578 2534 unsigned int segno = GET_SEGNO(sbi, addr); 2579 2535 struct sit_info *sit_i = SIT_I(sbi); 2536 + block_t addr_start = addr, addr_end = addr + len - 1; 2537 + unsigned int seg_num = GET_SEGNO(sbi, addr_end) - segno + 1; 2538 + unsigned int i = 1, max_blocks = sbi->blocks_per_seg, cnt; 2580 2539 2581 2540 f2fs_bug_on(sbi, addr == NULL_ADDR); 2582 2541 if (addr == NEW_ADDR || addr == COMPRESS_ADDR) 2583 2542 return; 2584 2543 2585 - f2fs_invalidate_internal_cache(sbi, addr); 2544 + f2fs_invalidate_internal_cache(sbi, addr, len); 2586 2545 2587 2546 /* add it into sit main buffer */ 2588 2547 down_write(&sit_i->sentry_lock); 2589 2548 2590 - update_segment_mtime(sbi, addr, 0); 2591 - update_sit_entry(sbi, addr, -1); 2549 + if (seg_num == 1) 2550 + cnt = len; 2551 + else 2552 + cnt = max_blocks - GET_BLKOFF_FROM_SEG0(sbi, addr); 2592 2553 2593 - /* add it into dirty seglist */ 2594 - locate_dirty_segment(sbi, segno); 2554 + do { 2555 + update_segment_mtime(sbi, addr_start, 0); 2556 + update_sit_entry(sbi, addr_start, -cnt); 2557 + 2558 + /* add it into dirty seglist */ 2559 + locate_dirty_segment(sbi, segno); 2560 + 2561 + /* update @addr_start and @cnt and @segno */ 2562 + addr_start = START_BLOCK(sbi, ++segno); 2563 + if (++i == seg_num) 2564 + cnt = GET_BLKOFF_FROM_SEG0(sbi, addr_end) + 1; 2565 + else 2566 + cnt = max_blocks; 2567 + } while (i <= seg_num); 2595 2568 2596 2569 up_write(&sit_i->sentry_lock); 2597 2570 } ··· 3920 3857 goto out; 3921 3858 } 3922 3859 if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO) 3923 - f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr); 3860 + f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr, 1); 3924 3861 3925 3862 /* writeout dirty page into bdev */ 3926 3863 f2fs_submit_page_write(fio); ··· 4112 4049 update_sit_entry(sbi, new_blkaddr, 1); 4113 4050 } 4114 4051 if (GET_SEGNO(sbi, old_blkaddr) != NULL_SEGNO) { 4115 - f2fs_invalidate_internal_cache(sbi, old_blkaddr); 4052 + f2fs_invalidate_internal_cache(sbi, old_blkaddr, 1); 4116 4053 if (!from_gc) 4117 4054 update_segment_mtime(sbi, old_blkaddr, 0); 4118 4055 update_sit_entry(sbi, old_blkaddr, -1); ··· 5468 5405 { 5469 5406 int ret; 5470 5407 5471 - if (!f2fs_sb_has_blkzoned(sbi) || f2fs_readonly(sbi->sb)) 5408 + if (!f2fs_sb_has_blkzoned(sbi) || f2fs_readonly(sbi->sb) || 5409 + f2fs_hw_is_readonly(sbi)) 5472 5410 return 0; 5473 5411 5474 5412 f2fs_notice(sbi, "Checking entire write pointers"); ··· 5556 5492 secno = GET_SEC_FROM_SEG(sbi, segno); 5557 5493 start = GET_SEG_FROM_SEC(sbi, secno); 5558 5494 5559 - if (!__is_large_section(sbi)) 5560 - return get_seg_entry(sbi, start + i)->mtime; 5495 + if (!__is_large_section(sbi)) { 5496 + mtime = get_seg_entry(sbi, start + i)->mtime; 5497 + goto out; 5498 + } 5561 5499 5562 5500 for (i = 0; i < usable_segs_per_sec; i++) { 5563 5501 /* for large section, only check the mtime of valid segments */ ··· 5572 5506 if (total_valid_blocks == 0) 5573 5507 return INVALID_MTIME; 5574 5508 5575 - return div_u64(mtime, total_valid_blocks); 5509 + mtime = div_u64(mtime, total_valid_blocks); 5510 + out: 5511 + if (unlikely(mtime == INVALID_MTIME)) 5512 + mtime -= 1; 5513 + return mtime; 5576 5514 } 5577 5515 5578 5516 /*
+2 -1
fs/f2fs/sysfs.c
··· 1472 1472 le32_to_cpu(sbi->raw_super->segment_count_main); 1473 1473 int i, j; 1474 1474 1475 - seq_puts(seq, "format: segment_type|valid_blocks|bitmaps\n" 1475 + seq_puts(seq, "format: segment_type|valid_blocks|bitmaps|mtime\n" 1476 1476 "segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n"); 1477 1477 1478 1478 for (i = 0; i < total_segs; i++) { ··· 1482 1482 seq_printf(seq, "%d|%-3u|", se->type, se->valid_blocks); 1483 1483 for (j = 0; j < SIT_VBLOCK_MAP_SIZE; j++) 1484 1484 seq_printf(seq, " %.2x", se->cur_valid_map[j]); 1485 + seq_printf(seq, "| %llx", se->mtime); 1485 1486 seq_putc(seq, '\n'); 1486 1487 } 1487 1488 return 0;
+19 -20
include/trace/events/f2fs.h
··· 1119 1119 (unsigned long long)__entry->count) 1120 1120 ); 1121 1121 1122 - DECLARE_EVENT_CLASS(f2fs__submit_page_bio, 1122 + DECLARE_EVENT_CLASS(f2fs__submit_folio_bio, 1123 1123 1124 - TP_PROTO(struct page *page, struct f2fs_io_info *fio), 1124 + TP_PROTO(struct folio *folio, struct f2fs_io_info *fio), 1125 1125 1126 - TP_ARGS(page, fio), 1126 + TP_ARGS(folio, fio), 1127 1127 1128 1128 TP_STRUCT__entry( 1129 1129 __field(dev_t, dev) ··· 1138 1138 ), 1139 1139 1140 1140 TP_fast_assign( 1141 - __entry->dev = page_file_mapping(page)->host->i_sb->s_dev; 1142 - __entry->ino = page_file_mapping(page)->host->i_ino; 1143 - __entry->index = page->index; 1141 + __entry->dev = folio->mapping->host->i_sb->s_dev; 1142 + __entry->ino = folio->mapping->host->i_ino; 1143 + __entry->index = folio->index; 1144 1144 __entry->old_blkaddr = fio->old_blkaddr; 1145 1145 __entry->new_blkaddr = fio->new_blkaddr; 1146 1146 __entry->op = fio->op; ··· 1149 1149 __entry->type = fio->type; 1150 1150 ), 1151 1151 1152 - TP_printk("dev = (%d,%d), ino = %lu, page_index = 0x%lx, " 1152 + TP_printk("dev = (%d,%d), ino = %lu, folio_index = 0x%lx, " 1153 1153 "oldaddr = 0x%llx, newaddr = 0x%llx, rw = %s(%s), type = %s_%s", 1154 1154 show_dev_ino(__entry), 1155 1155 (unsigned long)__entry->index, ··· 1160 1160 show_block_type(__entry->type)) 1161 1161 ); 1162 1162 1163 - DEFINE_EVENT_CONDITION(f2fs__submit_page_bio, f2fs_submit_page_bio, 1163 + DEFINE_EVENT_CONDITION(f2fs__submit_folio_bio, f2fs_submit_folio_bio, 1164 1164 1165 - TP_PROTO(struct page *page, struct f2fs_io_info *fio), 1165 + TP_PROTO(struct folio *folio, struct f2fs_io_info *fio), 1166 1166 1167 - TP_ARGS(page, fio), 1167 + TP_ARGS(folio, fio), 1168 1168 1169 - TP_CONDITION(page->mapping) 1169 + TP_CONDITION(folio->mapping) 1170 1170 ); 1171 1171 1172 - DEFINE_EVENT_CONDITION(f2fs__submit_page_bio, f2fs_submit_page_write, 1172 + DEFINE_EVENT_CONDITION(f2fs__submit_folio_bio, f2fs_submit_folio_write, 1173 1173 1174 - TP_PROTO(struct page *page, struct f2fs_io_info *fio), 1174 + TP_PROTO(struct folio *folio, struct f2fs_io_info *fio), 1175 1175 1176 - TP_ARGS(page, fio), 1176 + TP_ARGS(folio, fio), 1177 1177 1178 - TP_CONDITION(page->mapping) 1178 + TP_CONDITION(folio->mapping) 1179 1179 ); 1180 1180 1181 1181 DECLARE_EVENT_CLASS(f2fs__bio, ··· 1322 1322 ), 1323 1323 1324 1324 TP_fast_assign( 1325 - __entry->dev = folio_file_mapping(folio)->host->i_sb->s_dev; 1326 - __entry->ino = folio_file_mapping(folio)->host->i_ino; 1325 + __entry->dev = folio->mapping->host->i_sb->s_dev; 1326 + __entry->ino = folio->mapping->host->i_ino; 1327 1327 __entry->type = type; 1328 - __entry->dir = 1329 - S_ISDIR(folio_file_mapping(folio)->host->i_mode); 1330 - __entry->index = folio_index(folio); 1328 + __entry->dir = S_ISDIR(folio->mapping->host->i_mode); 1329 + __entry->index = folio->index; 1331 1330 __entry->dirty = folio_test_dirty(folio); 1332 1331 __entry->uptodate = folio_test_uptodate(folio); 1333 1332 ),