Description: Average number of valid blocks.
Available when CONFIG_F2FS_STAT_FS=y.
+What: /sys/fs/f2fs/<disk>/defrag_blocks
+Date: February 2026
+Contact: "Jinbao Liu" <liujinbao1@xiaomi.com>
+Description: Number of blocks moved by defragment.
+ Available when CONFIG_F2FS_STAT_FS=y.
+
What: /sys/fs/f2fs/<disk>/mounted_time_sec
Date: February 2020
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
si->bg_node_blks);
seq_printf(s, "BG skip : IO: %u, Other: %u\n",
si->io_skip_bggc, si->other_skip_bggc);
+ seq_printf(s, "defrag blocks : %u\n", si->defrag_blks);
seq_puts(s, "\nExtent Cache (Read):\n");
seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n",
si->hit_largest, si->hit_cached[EX_READ],
int gc_secs[2][2];
int tot_blks, data_blks, node_blks;
int bg_data_blks, bg_node_blks;
+ unsigned int defrag_blks;
int blkoff[NR_CURSEG_TYPE];
int curseg[NR_CURSEG_TYPE];
int cursec[NR_CURSEG_TYPE];
si->bg_node_blks += ((gc_type) == BG_GC) ? (blks) : 0; \
} while (0)
+#define stat_inc_defrag_blk_count(sbi, blks) \
+ (F2FS_STAT(sbi)->defrag_blks += (blks))
+
int f2fs_build_stats(struct f2fs_sb_info *sbi);
void f2fs_destroy_stats(struct f2fs_sb_info *sbi);
void __init f2fs_create_root_stats(void);
#define stat_inc_tot_blk_count(si, blks) do { } while (0)
#define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0)
#define stat_inc_node_blk_count(sbi, blks, gc_type) do { } while (0)
+#define stat_inc_defrag_blk_count(sbi, blks) do { } while (0)
static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
clear_inode_flag(inode, FI_OPU_WRITE);
unlock_out:
inode_unlock(inode);
- if (!err)
+ if (!err) {
range->len = (u64)total << PAGE_SHIFT;
+ stat_inc_defrag_blk_count(sbi, total);
+ }
return err;
}
f2fs_update_sit_info(sbi);
return sysfs_emit(buf, "%llu\n", (unsigned long long)(si->avg_vblocks));
}
+
+static ssize_t defrag_blocks_show(struct f2fs_attr *a,
+ struct f2fs_sb_info *sbi, char *buf)
+{
+ struct f2fs_stat_info *si = F2FS_STAT(sbi);
+
+ return sysfs_emit(buf, "%llu\n", (unsigned long long)(si->defrag_blks));
+}
#endif
static ssize_t main_blkaddr_show(struct f2fs_attr *a,
F2FS_GENERAL_RO_ATTR(moved_blocks_background);
F2FS_GENERAL_RO_ATTR(moved_blocks_foreground);
F2FS_GENERAL_RO_ATTR(avg_vblocks);
+F2FS_GENERAL_RO_ATTR(defrag_blocks);
#endif
#ifdef CONFIG_FS_ENCRYPTION
ATTR_LIST(moved_blocks_foreground),
ATTR_LIST(moved_blocks_background),
ATTR_LIST(avg_vblocks),
+ ATTR_LIST(defrag_blocks),
#endif
#ifdef CONFIG_BLK_DEV_ZONED
ATTR_LIST(unusable_blocks_per_sec),