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.

f2fs: Add defrag_blocks sysfs node

Add the defrag_blocks sysfs node to track
the amount of data blocks moved during filesystem
defragmentation.

Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
Signed-off-by: liujinbao1 <liujinbao1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

liujinbao1 and committed by
Jaegeuk Kim
265dccda 68a01789

+25 -1
+6
Documentation/ABI/testing/sysfs-fs-f2fs
··· 407 407 Description: Average number of valid blocks. 408 408 Available when CONFIG_F2FS_STAT_FS=y. 409 409 410 + What: /sys/fs/f2fs/<disk>/defrag_blocks 411 + Date: February 2026 412 + Contact: "Jinbao Liu" <liujinbao1@xiaomi.com> 413 + Description: Number of blocks moved by defragment. 414 + Available when CONFIG_F2FS_STAT_FS=y. 415 + 410 416 What: /sys/fs/f2fs/<disk>/mounted_time_sec 411 417 Date: February 2020 412 418 Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
+1
fs/f2fs/debug.c
··· 659 659 si->bg_node_blks); 660 660 seq_printf(s, "BG skip : IO: %u, Other: %u\n", 661 661 si->io_skip_bggc, si->other_skip_bggc); 662 + seq_printf(s, "defrag blocks : %u\n", si->defrag_blks); 662 663 seq_puts(s, "\nExtent Cache (Read):\n"); 663 664 seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n", 664 665 si->hit_largest, si->hit_cached[EX_READ],
+5
fs/f2fs/f2fs.h
··· 4288 4288 int gc_secs[2][2]; 4289 4289 int tot_blks, data_blks, node_blks; 4290 4290 int bg_data_blks, bg_node_blks; 4291 + unsigned int defrag_blks; 4291 4292 int blkoff[NR_CURSEG_TYPE]; 4292 4293 int curseg[NR_CURSEG_TYPE]; 4293 4294 int cursec[NR_CURSEG_TYPE]; ··· 4423 4422 si->bg_node_blks += ((gc_type) == BG_GC) ? (blks) : 0; \ 4424 4423 } while (0) 4425 4424 4425 + #define stat_inc_defrag_blk_count(sbi, blks) \ 4426 + (F2FS_STAT(sbi)->defrag_blks += (blks)) 4427 + 4426 4428 int f2fs_build_stats(struct f2fs_sb_info *sbi); 4427 4429 void f2fs_destroy_stats(struct f2fs_sb_info *sbi); 4428 4430 void __init f2fs_create_root_stats(void); ··· 4467 4463 #define stat_inc_tot_blk_count(si, blks) do { } while (0) 4468 4464 #define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0) 4469 4465 #define stat_inc_node_blk_count(sbi, blks, gc_type) do { } while (0) 4466 + #define stat_inc_defrag_blk_count(sbi, blks) do { } while (0) 4470 4467 4471 4468 static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; } 4472 4469 static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
+3 -1
fs/f2fs/file.c
··· 3043 3043 clear_inode_flag(inode, FI_OPU_WRITE); 3044 3044 unlock_out: 3045 3045 inode_unlock(inode); 3046 - if (!err) 3046 + if (!err) { 3047 3047 range->len = (u64)total << PAGE_SHIFT; 3048 + stat_inc_defrag_blk_count(sbi, total); 3049 + } 3048 3050 return err; 3049 3051 } 3050 3052
+10
fs/f2fs/sysfs.c
··· 338 338 f2fs_update_sit_info(sbi); 339 339 return sysfs_emit(buf, "%llu\n", (unsigned long long)(si->avg_vblocks)); 340 340 } 341 + 342 + static ssize_t defrag_blocks_show(struct f2fs_attr *a, 343 + struct f2fs_sb_info *sbi, char *buf) 344 + { 345 + struct f2fs_stat_info *si = F2FS_STAT(sbi); 346 + 347 + return sysfs_emit(buf, "%llu\n", (unsigned long long)(si->defrag_blks)); 348 + } 341 349 #endif 342 350 343 351 static ssize_t main_blkaddr_show(struct f2fs_attr *a, ··· 1359 1351 F2FS_GENERAL_RO_ATTR(moved_blocks_background); 1360 1352 F2FS_GENERAL_RO_ATTR(moved_blocks_foreground); 1361 1353 F2FS_GENERAL_RO_ATTR(avg_vblocks); 1354 + F2FS_GENERAL_RO_ATTR(defrag_blocks); 1362 1355 #endif 1363 1356 1364 1357 #ifdef CONFIG_FS_ENCRYPTION ··· 1482 1473 ATTR_LIST(moved_blocks_foreground), 1483 1474 ATTR_LIST(moved_blocks_background), 1484 1475 ATTR_LIST(avg_vblocks), 1476 + ATTR_LIST(defrag_blocks), 1485 1477 #endif 1486 1478 #ifdef CONFIG_BLK_DEV_ZONED 1487 1479 ATTR_LIST(unusable_blocks_per_sec),