FROMGIT: f2fs: add sysfs nodes to get runtime compression stat
I've added new sysfs nodes to show runtime compression stat since mount. compr_written_block - show the block count written after compression compr_saved_block - show the saved block count with compression compr_new_inode - show the count of inode newly enabled for compression Bug: 173482046 (cherry picked from commit c0b6572dfc3c507a5292f7db01a57bac8f11958d git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Change-Id: I5afcafb709369d4e11e44fc6dc183f1383b2ec51
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
58f0e25d0d
commit
892e618852
@@ -409,3 +409,27 @@ Description: Give a way to change checkpoint merge daemon's io priority.
|
||||
I/O priority "3". We can select the class between "rt" and "be",
|
||||
and set the I/O priority within valid range of it. "," delimiter
|
||||
is necessary in between I/O class and priority number.
|
||||
|
||||
What: /sys/fs/f2fs/<disk>/compr_written_block
|
||||
Date: March 2021
|
||||
Contact: "Daeho Jeong" <daehojeong@google.com>
|
||||
Description: Show the block count written after compression since mount. Note
|
||||
that when the compressed blocks are deleted, this count doesn't
|
||||
decrease. If you write "0" here, you can initialize
|
||||
compr_written_block and compr_saved_block to "0".
|
||||
|
||||
What: /sys/fs/f2fs/<disk>/compr_saved_block
|
||||
Date: March 2021
|
||||
Contact: "Daeho Jeong" <daehojeong@google.com>
|
||||
Description: Show the saved block count with compression since mount. Note
|
||||
that when the compressed blocks are deleted, this count doesn't
|
||||
decrease. If you write "0" here, you can initialize
|
||||
compr_written_block and compr_saved_block to "0".
|
||||
|
||||
What: /sys/fs/f2fs/<disk>/compr_new_inode
|
||||
Date: March 2021
|
||||
Contact: "Daeho Jeong" <daehojeong@google.com>
|
||||
Description: Show the count of inode newly enabled for compression since mount.
|
||||
Note that when the compression is disabled for the files, this count
|
||||
doesn't decrease. If you write "0" here, you can initialize
|
||||
compr_new_inode to "0".
|
||||
|
@@ -1353,6 +1353,7 @@ unlock_continue:
|
||||
if (fio.compr_blocks)
|
||||
f2fs_i_compr_blocks_update(inode, fio.compr_blocks - 1, false);
|
||||
f2fs_i_compr_blocks_update(inode, cc->nr_cpages, true);
|
||||
add_compr_block_stat(inode, cc->nr_cpages);
|
||||
|
||||
set_inode_flag(cc->inode, FI_APPEND_WRITE);
|
||||
if (cc->cluster_idx == 0)
|
||||
|
@@ -1623,6 +1623,11 @@ struct f2fs_sb_info {
|
||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||
struct kmem_cache *page_array_slab; /* page array entry */
|
||||
unsigned int page_array_slab_size; /* default page array slab size */
|
||||
|
||||
/* For runtime compression statistics */
|
||||
u64 compr_written_block;
|
||||
u64 compr_saved_block;
|
||||
u32 compr_new_inode;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -3954,6 +3959,18 @@ int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi);
|
||||
void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi);
|
||||
int __init f2fs_init_compress_cache(void);
|
||||
void f2fs_destroy_compress_cache(void);
|
||||
#define inc_compr_inode_stat(inode) \
|
||||
do { \
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); \
|
||||
sbi->compr_new_inode++; \
|
||||
} while (0)
|
||||
#define add_compr_block_stat(inode, blocks) \
|
||||
do { \
|
||||
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); \
|
||||
int diff = F2FS_I(inode)->i_cluster_size - blocks; \
|
||||
sbi->compr_written_block += blocks; \
|
||||
sbi->compr_saved_block += diff; \
|
||||
} while (0)
|
||||
#else
|
||||
static inline bool f2fs_is_compressed_page(struct page *page) { return false; }
|
||||
static inline bool f2fs_is_compress_backend_ready(struct inode *inode)
|
||||
@@ -3982,6 +3999,7 @@ static inline int f2fs_init_page_array_cache(struct f2fs_sb_info *sbi) { return
|
||||
static inline void f2fs_destroy_page_array_cache(struct f2fs_sb_info *sbi) { }
|
||||
static inline int __init f2fs_init_compress_cache(void) { return 0; }
|
||||
static inline void f2fs_destroy_compress_cache(void) { }
|
||||
#define inc_compr_inode_stat(inode) do { } while (0)
|
||||
#endif
|
||||
|
||||
static inline void set_compress_context(struct inode *inode)
|
||||
@@ -4005,6 +4023,7 @@ static inline void set_compress_context(struct inode *inode)
|
||||
F2FS_I(inode)->i_flags |= F2FS_COMPR_FL;
|
||||
set_inode_flag(inode, FI_COMPRESSED_FILE);
|
||||
stat_inc_compr_inode(inode);
|
||||
inc_compr_inode_stat(inode);
|
||||
f2fs_mark_inode_dirty_sync(inode, true);
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/unicode.h>
|
||||
#include <linux/ioprio.h>
|
||||
#include <linux/sysfs.h>
|
||||
|
||||
#include "f2fs.h"
|
||||
#include "segment.h"
|
||||
@@ -282,6 +283,17 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
|
||||
return len;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||
if (!strcmp(a->attr.name, "compr_written_block"))
|
||||
return sysfs_emit(buf, "%llu\n", sbi->compr_written_block);
|
||||
|
||||
if (!strcmp(a->attr.name, "compr_saved_block"))
|
||||
return sysfs_emit(buf, "%llu\n", sbi->compr_saved_block);
|
||||
|
||||
if (!strcmp(a->attr.name, "compr_new_inode"))
|
||||
return sysfs_emit(buf, "%u\n", sbi->compr_new_inode);
|
||||
#endif
|
||||
|
||||
ui = (unsigned int *)(ptr + a->offset);
|
||||
|
||||
return sprintf(buf, "%u\n", *ui);
|
||||
@@ -458,6 +470,24 @@ out:
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||
if (!strcmp(a->attr.name, "compr_written_block") ||
|
||||
!strcmp(a->attr.name, "compr_saved_block")) {
|
||||
if (t != 0)
|
||||
return -EINVAL;
|
||||
sbi->compr_written_block = 0;
|
||||
sbi->compr_saved_block = 0;
|
||||
return count;
|
||||
}
|
||||
|
||||
if (!strcmp(a->attr.name, "compr_new_inode")) {
|
||||
if (t != 0)
|
||||
return -EINVAL;
|
||||
sbi->compr_new_inode = 0;
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
*ui = (unsigned int)t;
|
||||
|
||||
return count;
|
||||
@@ -668,6 +698,9 @@ F2FS_FEATURE_RO_ATTR(sb_checksum, FEAT_SB_CHECKSUM);
|
||||
F2FS_FEATURE_RO_ATTR(casefold, FEAT_CASEFOLD);
|
||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||
F2FS_FEATURE_RO_ATTR(compression, FEAT_COMPRESSION);
|
||||
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_written_block, compr_written_block);
|
||||
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_saved_block, compr_saved_block);
|
||||
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, compr_new_inode, compr_new_inode);
|
||||
#endif
|
||||
|
||||
#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
|
||||
@@ -730,6 +763,11 @@ static struct attribute *f2fs_attrs[] = {
|
||||
ATTR_LIST(moved_blocks_foreground),
|
||||
ATTR_LIST(moved_blocks_background),
|
||||
ATTR_LIST(avg_vblocks),
|
||||
#endif
|
||||
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
||||
ATTR_LIST(compr_written_block),
|
||||
ATTR_LIST(compr_saved_block),
|
||||
ATTR_LIST(compr_new_inode),
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
Reference in New Issue
Block a user