public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: add sysfs nodes to get accumulated compression info
@ 2021-03-04  9:33 Daeho Jeong
  2021-03-04 12:25 ` kernel test robot
  2021-03-04 12:31 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Daeho Jeong @ 2021-03-04  9:33 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Added acc_compr_inodes to show accumulated compressed inode count and
acc_compr_blocks to show accumulated secured block count with
compression in sysfs. These can be re-initialized to "0" by writing "0"
value in one of both.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
 Documentation/ABI/testing/sysfs-fs-f2fs | 13 +++++++
 fs/f2fs/checkpoint.c                    |  8 ++++
 fs/f2fs/compress.c                      |  4 +-
 fs/f2fs/data.c                          |  2 +-
 fs/f2fs/f2fs.h                          | 49 ++++++++++++++++++++++++-
 fs/f2fs/file.c                          |  8 ++--
 fs/f2fs/inode.c                         |  1 +
 fs/f2fs/super.c                         | 10 ++++-
 fs/f2fs/sysfs.c                         | 45 +++++++++++++++++++++++
 include/linux/f2fs_fs.h                 |  4 +-
 10 files changed, 134 insertions(+), 10 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index cbeac1bebe2f..f4fc87503754 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -409,3 +409,16 @@ 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>/acc_compr_inodes
+Date:		March 2021
+Contact:	"Daeho Jeong" <daehojeong@google.com>
+Description:	Show accumulated compressed inode count. If you write "0" here,
+		you can initialize acc_compr_inodes and acc_compr_blocks as "0".
+
+What:		/sys/fs/f2fs/<disk>/acc_compr_blocks
+Date:		March 2021
+Contact:	"Daeho Jeong" <daehojeong@google.com>
+Description:	Show accumulated secured block count with compression.
+		If you write "0" here, you can initialize acc_compr_inodes and
+		acc_compr_blocks as "0".
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 174a0819ad96..cd944a569162 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1514,6 +1514,14 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 	seg_i->journal->info.kbytes_written = cpu_to_le64(kbytes_written);
 
 	if (__remain_node_summaries(cpc->reason)) {
+		/* Record compression statistics in the hot node summary */
+		spin_lock(&sbi->acc_compr_lock);
+		seg_i->journal->info.acc_compr_blocks =
+			cpu_to_le64(sbi->acc_compr_blocks);
+		seg_i->journal->info.acc_compr_inodes =
+			cpu_to_le32(sbi->acc_compr_inodes);
+		spin_unlock(&sbi->acc_compr_lock);
+
 		f2fs_write_node_summaries(sbi, start_blk);
 		start_blk += NR_CURSEG_NODE_TYPE;
 	}
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 77fa342de38f..9029e95f4ae4 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1351,8 +1351,8 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
 	}
 
 	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);
+		f2fs_i_compr_blocks_update(inode, fio.compr_blocks - 1, false, true);
+	f2fs_i_compr_blocks_update(inode, cc->nr_cpages, true, true);
 
 	set_inode_flag(cc->inode, FI_APPEND_WRITE);
 	if (cc->cluster_idx == 0)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b9721c8f116c..d3afb9b0090e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2591,7 +2591,7 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio)
 	ClearPageError(page);
 
 	if (fio->compr_blocks && fio->old_blkaddr == COMPRESS_ADDR)
-		f2fs_i_compr_blocks_update(inode, fio->compr_blocks - 1, false);
+		f2fs_i_compr_blocks_update(inode, fio->compr_blocks - 1, false, true);
 
 	/* LFS mode write path */
 	f2fs_outplace_write_data(&dn, fio);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e2d302ae3a46..4351ca77fa13 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1609,6 +1609,11 @@ struct f2fs_sb_info {
 	u64 sectors_written_start;
 	u64 kbytes_written;
 
+	/* For accumulated compression statistics */
+	u64 acc_compr_blocks;
+	u32 acc_compr_inodes;
+	spinlock_t acc_compr_lock;
+
 	/* Reference to checksum algorithm driver via cryptoapi */
 	struct crypto_shash *s_chksum_driver;
 
@@ -3675,10 +3680,46 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
 		if (f2fs_compressed_file(inode))			\
 			(atomic_dec(&F2FS_I_SB(inode)->compr_inode));	\
 	} while (0)
+#define stat_inc_acc_compr_inodes(inode)                                \
+	do {								\
+		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);		\
+		if (f2fs_compressed_file(inode)) {			\
+			spin_lock(&sbi->acc_compr_lock);                \
+			sbi->acc_compr_inodes++;                        \
+			spin_unlock(&sbi->acc_compr_lock);              \
+		}                                                       \
+	} while (0)
+#define stat_dec_acc_compr_inodes(inode)				\
+	do {								\
+		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);		\
+		if (f2fs_compressed_file(inode)) {			\
+			spin_lock(&sbi->acc_compr_lock);		\
+			if (sbi->acc_compr_inodes)			\
+				sbi->acc_compr_inodes--;		\
+			spin_unlock(&sbi->acc_compr_lock);		\
+		}							\
+	} while (0)
 #define stat_add_compr_blocks(inode, blocks)				\
 		(atomic64_add(blocks, &F2FS_I_SB(inode)->compr_blocks))
 #define stat_sub_compr_blocks(inode, blocks)				\
 		(atomic64_sub(blocks, &F2FS_I_SB(inode)->compr_blocks))
+#define stat_add_acc_compr_blocks(inode, blocks)			\
+	do {								\
+		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);		\
+		spin_lock(&sbi->acc_compr_lock);			\
+		sbi->acc_compr_blocks += diff;				\
+		spin_unlock(&sbi->acc_compr_lock);			\
+	} while (0)
+#define stat_sub_acc_compr_blocks(inode, blocks)			\
+	do {								\
+		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);		\
+		spin_lock(&sbi->acc_compr_lock);			\
+		if (sbi->acc_compr_blocks >= diff)			\
+			sbi->acc_compr_blocks -= diff;			\
+		else							\
+			sbi->acc_compr_blocks = 0;			\
+		spin_unlock(&sbi->acc_compr_lock);			\
+	} while (0)
 #define stat_inc_meta_count(sbi, blkaddr)				\
 	do {								\
 		if (blkaddr < SIT_I(sbi)->sit_base_addr)		\
@@ -4006,6 +4047,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);
+	stat_inc_acc_compr_inodes(inode);
 	f2fs_mark_inode_dirty_sync(inode, true);
 }
 
@@ -4021,6 +4063,7 @@ static inline bool f2fs_disable_compressed_file(struct inode *inode)
 
 	fi->i_flags &= ~F2FS_COMPR_FL;
 	stat_dec_compr_inode(inode);
+	stat_dec_acc_compr_inodes(inode);
 	clear_inode_flag(inode, FI_COMPRESSED_FILE);
 	f2fs_mark_inode_dirty_sync(inode, true);
 	return true;
@@ -4114,7 +4157,7 @@ static inline bool f2fs_may_compress(struct inode *inode)
 }
 
 static inline void f2fs_i_compr_blocks_update(struct inode *inode,
-						u64 blocks, bool add)
+					u64 blocks, bool add, bool accumulate)
 {
 	int diff = F2FS_I(inode)->i_cluster_size - blocks;
 	struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -4126,9 +4169,13 @@ static inline void f2fs_i_compr_blocks_update(struct inode *inode,
 	if (add) {
 		atomic_add(diff, &fi->i_compr_blocks);
 		stat_add_compr_blocks(inode, diff);
+		if (accumulate)
+			stat_add_acc_compr_blocks(inode, diff);
 	} else {
 		atomic_sub(diff, &fi->i_compr_blocks);
 		stat_sub_compr_blocks(inode, diff);
+		if (accumulate)
+			stat_sub_acc_compr_blocks(inode, diff);
 	}
 	f2fs_mark_inode_dirty_sync(inode, true);
 }
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index d26ff2ae3f5e..6e704383fe86 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -568,7 +568,7 @@ void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)
 					!(cluster_index & (cluster_size - 1))) {
 			if (compressed_cluster)
 				f2fs_i_compr_blocks_update(dn->inode,
-							valid_blocks, false);
+							valid_blocks, false, true);
 			compressed_cluster = (blkaddr == COMPRESS_ADDR);
 			valid_blocks = 0;
 		}
@@ -597,7 +597,7 @@ void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)
 	}
 
 	if (compressed_cluster)
-		f2fs_i_compr_blocks_update(dn->inode, valid_blocks, false);
+		f2fs_i_compr_blocks_update(dn->inode, valid_blocks, false, true);
 
 	if (nr_free) {
 		pgoff_t fofs;
@@ -3503,7 +3503,7 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
 			f2fs_set_data_blkaddr(dn);
 		}
 
-		f2fs_i_compr_blocks_update(dn->inode, compr_blocks, false);
+		f2fs_i_compr_blocks_update(dn->inode, compr_blocks, false, false);
 		dec_valid_block_count(sbi, dn->inode,
 					cluster_size - compr_blocks);
 
@@ -3675,7 +3675,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
 		if (reserved != cluster_size - compr_blocks)
 			return -ENOSPC;
 
-		f2fs_i_compr_blocks_update(dn->inode, compr_blocks, true);
+		f2fs_i_compr_blocks_update(dn->inode, compr_blocks, true, false);
 
 		reserved_blocks += reserved;
 next:
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 349d9cb933ee..cacbd93e28a7 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -776,6 +776,7 @@ void f2fs_evict_inode(struct inode *inode)
 			set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
 	}
 	sb_end_intwrite(inode->i_sb);
+	stat_dec_acc_compr_inodes(inode);
 no_delete:
 	dquot_drop(inode);
 
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7069793752f1..994895e0d326 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3861,11 +3861,19 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 	/* For write statistics */
 	sbi->sectors_written_start = f2fs_get_sectors_written(sbi);
 
+	/* For accumulated compression statistics */
+	spin_lock_init(&sbi->acc_compr_lock);
+
 	/* Read accumulated write IO statistics if exists */
 	seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
-	if (__exist_node_summaries(sbi))
+	if (__exist_node_summaries(sbi)) {
 		sbi->kbytes_written =
 			le64_to_cpu(seg_i->journal->info.kbytes_written);
+		sbi->acc_compr_blocks =
+			le64_to_cpu(seg_i->journal->info.acc_compr_blocks);
+		sbi->acc_compr_inodes =
+			le32_to_cpu(seg_i->journal->info.acc_compr_inodes);
+	}
 
 	f2fs_build_gc_manager(sbi);
 
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index e38a7f6921dd..cc85a1028e19 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -282,6 +282,32 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
 		return len;
 	}
 
+#ifdef CONFIG_F2FS_FS_COMPRESSION
+	if (!strcmp(a->attr.name, "acc_compr_blocks")) {
+		u64 bcount;
+		int len;
+
+		spin_lock(&sbi->acc_compr_lock);
+		bcount = sbi->acc_compr_blocks;
+		spin_unlock(&sbi->acc_compr_lock);
+
+		len = scnprintf(buf, PAGE_SIZE, "%llu\n", bcount);
+		return len;
+	}
+
+	if (!strcmp(a->attr.name, "acc_compr_inodes")) {
+		u32 icount;
+		int len;
+
+		spin_lock(&sbi->acc_compr_lock);
+		icount = sbi->acc_compr_inodes;
+		spin_unlock(&sbi->acc_compr_lock);
+
+		len = scnprintf(buf, PAGE_SIZE, "%u\n", icount);
+		return len;
+	}
+#endif
+
 	ui = (unsigned int *)(ptr + a->offset);
 
 	return sprintf(buf, "%u\n", *ui);
@@ -458,6 +484,19 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 		return count;
 	}
 
+#ifdef CONFIG_F2FS_FS_COMPRESSION
+	if (!strcmp(a->attr.name, "acc_compr_blocks") ||
+		!strcmp(a->attr.name, "acc_compr_inodes")) {
+		if (t != 0)
+			return -EINVAL;
+		spin_lock(&sbi->acc_compr_lock);
+		sbi->acc_compr_blocks = 0;
+		sbi->acc_compr_inodes = 0;
+		spin_unlock(&sbi->acc_compr_lock);
+		return count;
+	}
+#endif
+
 	*ui = (unsigned int)t;
 
 	return count;
@@ -668,6 +707,8 @@ 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, acc_compr_blocks, acc_compr_blocks);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, acc_compr_inodes, acc_compr_inodes);
 #endif
 
 #define ATTR_LIST(name) (&f2fs_attr_##name.attr)
@@ -730,6 +771,10 @@ 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(acc_compr_blocks),
+	ATTR_LIST(acc_compr_inodes),
 #endif
 	NULL,
 };
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index c6cc0a566ef5..7b707ddeca99 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -429,7 +429,7 @@ struct summary_footer {
 /* Reserved area should make size of f2fs_extra_info equals to
  * that of nat_journal and sit_journal.
  */
-#define EXTRA_INFO_RESERVED	(SUM_JOURNAL_SIZE - 2 - 8)
+#define EXTRA_INFO_RESERVED	(SUM_JOURNAL_SIZE - 2 - 20)
 
 /*
  * frequently updated NAT/SIT entries can be stored in the spare area in
@@ -462,6 +462,8 @@ struct sit_journal {
 
 struct f2fs_extra_info {
 	__le64 kbytes_written;
+	__le64 acc_compr_blocks;
+	__le32 acc_compr_inodes;
 	__u8 reserved[EXTRA_INFO_RESERVED];
 } __packed;
 
-- 
2.30.1.766.gb4fecdf3b7-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: add sysfs nodes to get accumulated compression info
  2021-03-04  9:33 [PATCH] f2fs: add sysfs nodes to get accumulated compression info Daeho Jeong
@ 2021-03-04 12:25 ` kernel test robot
  2021-03-04 12:31 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-03-04 12:25 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

[-- Attachment #1: Type: text/plain, Size: 8551 bytes --]

Hi Daeho,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on linus/master v5.12-rc1]
[cannot apply to linux/master next-20210304]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daeho-Jeong/f2fs-add-sysfs-nodes-to-get-accumulated-compression-info/20210304-173739
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: nios2-randconfig-r011-20210304 (attached as .config)
compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/c1c09c0edfbbbbb5753d532576be053767bbf0ae
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Daeho-Jeong/f2fs-add-sysfs-nodes-to-get-accumulated-compression-info/20210304-173739
        git checkout c1c09c0edfbbbbb5753d532576be053767bbf0ae
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from fs/f2fs/dir.c:13:
   fs/f2fs/f2fs.h: In function 'set_compress_context':
>> fs/f2fs/f2fs.h:4050:2: error: implicit declaration of function 'stat_inc_acc_compr_inodes'; did you mean 'stat_inc_compr_inode'? [-Werror=implicit-function-declaration]
    4050 |  stat_inc_acc_compr_inodes(inode);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~
         |  stat_inc_compr_inode
   fs/f2fs/f2fs.h: In function 'f2fs_disable_compressed_file':
>> fs/f2fs/f2fs.h:4066:2: error: implicit declaration of function 'stat_dec_acc_compr_inodes'; did you mean 'stat_dec_compr_inode'? [-Werror=implicit-function-declaration]
    4066 |  stat_dec_acc_compr_inodes(inode);
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~
         |  stat_dec_compr_inode
   fs/f2fs/f2fs.h: In function 'f2fs_i_compr_blocks_update':
>> fs/f2fs/f2fs.h:4173:4: error: implicit declaration of function 'stat_add_acc_compr_blocks'; did you mean 'stat_add_compr_blocks'? [-Werror=implicit-function-declaration]
    4173 |    stat_add_acc_compr_blocks(inode, diff);
         |    ^~~~~~~~~~~~~~~~~~~~~~~~~
         |    stat_add_compr_blocks
>> fs/f2fs/f2fs.h:4178:4: error: implicit declaration of function 'stat_sub_acc_compr_blocks'; did you mean 'stat_sub_compr_blocks'? [-Werror=implicit-function-declaration]
    4178 |    stat_sub_acc_compr_blocks(inode, diff);
         |    ^~~~~~~~~~~~~~~~~~~~~~~~~
         |    stat_sub_compr_blocks
   cc1: some warnings being treated as errors


vim +4050 fs/f2fs/f2fs.h

  4028	
  4029	static inline void set_compress_context(struct inode *inode)
  4030	{
  4031		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
  4032	
  4033		F2FS_I(inode)->i_compress_algorithm =
  4034				F2FS_OPTION(sbi).compress_algorithm;
  4035		F2FS_I(inode)->i_log_cluster_size =
  4036				F2FS_OPTION(sbi).compress_log_size;
  4037		F2FS_I(inode)->i_compress_flag =
  4038				F2FS_OPTION(sbi).compress_chksum ?
  4039					1 << COMPRESS_CHKSUM : 0;
  4040		F2FS_I(inode)->i_cluster_size =
  4041				1 << F2FS_I(inode)->i_log_cluster_size;
  4042		if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_LZ4 &&
  4043				F2FS_OPTION(sbi).compress_level)
  4044			F2FS_I(inode)->i_compress_flag |=
  4045					F2FS_OPTION(sbi).compress_level <<
  4046					COMPRESS_LEVEL_OFFSET;
  4047		F2FS_I(inode)->i_flags |= F2FS_COMPR_FL;
  4048		set_inode_flag(inode, FI_COMPRESSED_FILE);
  4049		stat_inc_compr_inode(inode);
> 4050		stat_inc_acc_compr_inodes(inode);
  4051		f2fs_mark_inode_dirty_sync(inode, true);
  4052	}
  4053	
  4054	static inline bool f2fs_disable_compressed_file(struct inode *inode)
  4055	{
  4056		struct f2fs_inode_info *fi = F2FS_I(inode);
  4057	
  4058		if (!f2fs_compressed_file(inode))
  4059			return true;
  4060		if (S_ISREG(inode->i_mode) &&
  4061			(get_dirty_pages(inode) || atomic_read(&fi->i_compr_blocks)))
  4062			return false;
  4063	
  4064		fi->i_flags &= ~F2FS_COMPR_FL;
  4065		stat_dec_compr_inode(inode);
> 4066		stat_dec_acc_compr_inodes(inode);
  4067		clear_inode_flag(inode, FI_COMPRESSED_FILE);
  4068		f2fs_mark_inode_dirty_sync(inode, true);
  4069		return true;
  4070	}
  4071	
  4072	#define F2FS_FEATURE_FUNCS(name, flagname) \
  4073	static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
  4074	{ \
  4075		return F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_##flagname); \
  4076	}
  4077	
  4078	F2FS_FEATURE_FUNCS(encrypt, ENCRYPT);
  4079	F2FS_FEATURE_FUNCS(blkzoned, BLKZONED);
  4080	F2FS_FEATURE_FUNCS(extra_attr, EXTRA_ATTR);
  4081	F2FS_FEATURE_FUNCS(project_quota, PRJQUOTA);
  4082	F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);
  4083	F2FS_FEATURE_FUNCS(flexible_inline_xattr, FLEXIBLE_INLINE_XATTR);
  4084	F2FS_FEATURE_FUNCS(quota_ino, QUOTA_INO);
  4085	F2FS_FEATURE_FUNCS(inode_crtime, INODE_CRTIME);
  4086	F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
  4087	F2FS_FEATURE_FUNCS(verity, VERITY);
  4088	F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
  4089	F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
  4090	F2FS_FEATURE_FUNCS(compression, COMPRESSION);
  4091	
  4092	#ifdef CONFIG_BLK_DEV_ZONED
  4093	static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
  4094					    block_t blkaddr)
  4095	{
  4096		unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
  4097	
  4098		return test_bit(zno, FDEV(devi).blkz_seq);
  4099	}
  4100	#endif
  4101	
  4102	static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi)
  4103	{
  4104		return f2fs_sb_has_blkzoned(sbi);
  4105	}
  4106	
  4107	static inline bool f2fs_bdev_support_discard(struct block_device *bdev)
  4108	{
  4109		return blk_queue_discard(bdev_get_queue(bdev)) ||
  4110		       bdev_is_zoned(bdev);
  4111	}
  4112	
  4113	static inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi)
  4114	{
  4115		int i;
  4116	
  4117		if (!f2fs_is_multi_device(sbi))
  4118			return f2fs_bdev_support_discard(sbi->sb->s_bdev);
  4119	
  4120		for (i = 0; i < sbi->s_ndevs; i++)
  4121			if (f2fs_bdev_support_discard(FDEV(i).bdev))
  4122				return true;
  4123		return false;
  4124	}
  4125	
  4126	static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi)
  4127	{
  4128		return (test_opt(sbi, DISCARD) && f2fs_hw_support_discard(sbi)) ||
  4129						f2fs_hw_should_discard(sbi);
  4130	}
  4131	
  4132	static inline bool f2fs_hw_is_readonly(struct f2fs_sb_info *sbi)
  4133	{
  4134		int i;
  4135	
  4136		if (!f2fs_is_multi_device(sbi))
  4137			return bdev_read_only(sbi->sb->s_bdev);
  4138	
  4139		for (i = 0; i < sbi->s_ndevs; i++)
  4140			if (bdev_read_only(FDEV(i).bdev))
  4141				return true;
  4142		return false;
  4143	}
  4144	
  4145	static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
  4146	{
  4147		return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
  4148	}
  4149	
  4150	static inline bool f2fs_may_compress(struct inode *inode)
  4151	{
  4152		if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) ||
  4153					f2fs_is_atomic_file(inode) ||
  4154					f2fs_is_volatile_file(inode))
  4155			return false;
  4156		return S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode);
  4157	}
  4158	
  4159	static inline void f2fs_i_compr_blocks_update(struct inode *inode,
  4160						u64 blocks, bool add, bool accumulate)
  4161	{
  4162		int diff = F2FS_I(inode)->i_cluster_size - blocks;
  4163		struct f2fs_inode_info *fi = F2FS_I(inode);
  4164	
  4165		/* don't update i_compr_blocks if saved blocks were released */
  4166		if (!add && !atomic_read(&fi->i_compr_blocks))
  4167			return;
  4168	
  4169		if (add) {
  4170			atomic_add(diff, &fi->i_compr_blocks);
  4171			stat_add_compr_blocks(inode, diff);
  4172			if (accumulate)
> 4173				stat_add_acc_compr_blocks(inode, diff);
  4174		} else {
  4175			atomic_sub(diff, &fi->i_compr_blocks);
  4176			stat_sub_compr_blocks(inode, diff);
  4177			if (accumulate)
> 4178				stat_sub_acc_compr_blocks(inode, diff);
  4179		}
  4180		f2fs_mark_inode_dirty_sync(inode, true);
  4181	}
  4182	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33046 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: add sysfs nodes to get accumulated compression info
  2021-03-04  9:33 [PATCH] f2fs: add sysfs nodes to get accumulated compression info Daeho Jeong
  2021-03-04 12:25 ` kernel test robot
@ 2021-03-04 12:31 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-03-04 12:31 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team
  Cc: clang-built-linux, Daeho Jeong

[-- Attachment #1: Type: text/plain, Size: 9345 bytes --]

Hi Daeho,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on linus/master v5.12-rc1]
[cannot apply to linux/master next-20210304]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Daeho-Jeong/f2fs-add-sysfs-nodes-to-get-accumulated-compression-info/20210304-173739
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: arm64-randconfig-r021-20210304 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project eec7f8f7b1226be422a76542cb403d02538f453a)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/c1c09c0edfbbbbb5753d532576be053767bbf0ae
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Daeho-Jeong/f2fs-add-sysfs-nodes-to-get-accumulated-compression-info/20210304-173739
        git checkout c1c09c0edfbbbbb5753d532576be053767bbf0ae
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from fs/f2fs/dir.c:13:
>> fs/f2fs/f2fs.h:4050:2: error: implicit declaration of function 'stat_inc_acc_compr_inodes' [-Werror,-Wimplicit-function-declaration]
           stat_inc_acc_compr_inodes(inode);
           ^
>> fs/f2fs/f2fs.h:4066:2: error: implicit declaration of function 'stat_dec_acc_compr_inodes' [-Werror,-Wimplicit-function-declaration]
           stat_dec_acc_compr_inodes(inode);
           ^
>> fs/f2fs/f2fs.h:4173:4: error: implicit declaration of function 'stat_add_acc_compr_blocks' [-Werror,-Wimplicit-function-declaration]
                           stat_add_acc_compr_blocks(inode, diff);
                           ^
>> fs/f2fs/f2fs.h:4178:4: error: implicit declaration of function 'stat_sub_acc_compr_blocks' [-Werror,-Wimplicit-function-declaration]
                           stat_sub_acc_compr_blocks(inode, diff);
                           ^
   4 errors generated.
--
   In file included from fs/f2fs/inode.c:14:
>> fs/f2fs/f2fs.h:4050:2: error: implicit declaration of function 'stat_inc_acc_compr_inodes' [-Werror,-Wimplicit-function-declaration]
           stat_inc_acc_compr_inodes(inode);
           ^
>> fs/f2fs/f2fs.h:4066:2: error: implicit declaration of function 'stat_dec_acc_compr_inodes' [-Werror,-Wimplicit-function-declaration]
           stat_dec_acc_compr_inodes(inode);
           ^
>> fs/f2fs/f2fs.h:4173:4: error: implicit declaration of function 'stat_add_acc_compr_blocks' [-Werror,-Wimplicit-function-declaration]
                           stat_add_acc_compr_blocks(inode, diff);
                           ^
>> fs/f2fs/f2fs.h:4178:4: error: implicit declaration of function 'stat_sub_acc_compr_blocks' [-Werror,-Wimplicit-function-declaration]
                           stat_sub_acc_compr_blocks(inode, diff);
                           ^
>> fs/f2fs/inode.c:779:2: error: implicit declaration of function 'stat_dec_acc_compr_inodes' [-Werror,-Wimplicit-function-declaration]
           stat_dec_acc_compr_inodes(inode);
           ^
   5 errors generated.


vim +/stat_inc_acc_compr_inodes +4050 fs/f2fs/f2fs.h

  4028	
  4029	static inline void set_compress_context(struct inode *inode)
  4030	{
  4031		struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
  4032	
  4033		F2FS_I(inode)->i_compress_algorithm =
  4034				F2FS_OPTION(sbi).compress_algorithm;
  4035		F2FS_I(inode)->i_log_cluster_size =
  4036				F2FS_OPTION(sbi).compress_log_size;
  4037		F2FS_I(inode)->i_compress_flag =
  4038				F2FS_OPTION(sbi).compress_chksum ?
  4039					1 << COMPRESS_CHKSUM : 0;
  4040		F2FS_I(inode)->i_cluster_size =
  4041				1 << F2FS_I(inode)->i_log_cluster_size;
  4042		if (F2FS_I(inode)->i_compress_algorithm == COMPRESS_LZ4 &&
  4043				F2FS_OPTION(sbi).compress_level)
  4044			F2FS_I(inode)->i_compress_flag |=
  4045					F2FS_OPTION(sbi).compress_level <<
  4046					COMPRESS_LEVEL_OFFSET;
  4047		F2FS_I(inode)->i_flags |= F2FS_COMPR_FL;
  4048		set_inode_flag(inode, FI_COMPRESSED_FILE);
  4049		stat_inc_compr_inode(inode);
> 4050		stat_inc_acc_compr_inodes(inode);
  4051		f2fs_mark_inode_dirty_sync(inode, true);
  4052	}
  4053	
  4054	static inline bool f2fs_disable_compressed_file(struct inode *inode)
  4055	{
  4056		struct f2fs_inode_info *fi = F2FS_I(inode);
  4057	
  4058		if (!f2fs_compressed_file(inode))
  4059			return true;
  4060		if (S_ISREG(inode->i_mode) &&
  4061			(get_dirty_pages(inode) || atomic_read(&fi->i_compr_blocks)))
  4062			return false;
  4063	
  4064		fi->i_flags &= ~F2FS_COMPR_FL;
  4065		stat_dec_compr_inode(inode);
> 4066		stat_dec_acc_compr_inodes(inode);
  4067		clear_inode_flag(inode, FI_COMPRESSED_FILE);
  4068		f2fs_mark_inode_dirty_sync(inode, true);
  4069		return true;
  4070	}
  4071	
  4072	#define F2FS_FEATURE_FUNCS(name, flagname) \
  4073	static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
  4074	{ \
  4075		return F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_##flagname); \
  4076	}
  4077	
  4078	F2FS_FEATURE_FUNCS(encrypt, ENCRYPT);
  4079	F2FS_FEATURE_FUNCS(blkzoned, BLKZONED);
  4080	F2FS_FEATURE_FUNCS(extra_attr, EXTRA_ATTR);
  4081	F2FS_FEATURE_FUNCS(project_quota, PRJQUOTA);
  4082	F2FS_FEATURE_FUNCS(inode_chksum, INODE_CHKSUM);
  4083	F2FS_FEATURE_FUNCS(flexible_inline_xattr, FLEXIBLE_INLINE_XATTR);
  4084	F2FS_FEATURE_FUNCS(quota_ino, QUOTA_INO);
  4085	F2FS_FEATURE_FUNCS(inode_crtime, INODE_CRTIME);
  4086	F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
  4087	F2FS_FEATURE_FUNCS(verity, VERITY);
  4088	F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
  4089	F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
  4090	F2FS_FEATURE_FUNCS(compression, COMPRESSION);
  4091	
  4092	#ifdef CONFIG_BLK_DEV_ZONED
  4093	static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
  4094					    block_t blkaddr)
  4095	{
  4096		unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz;
  4097	
  4098		return test_bit(zno, FDEV(devi).blkz_seq);
  4099	}
  4100	#endif
  4101	
  4102	static inline bool f2fs_hw_should_discard(struct f2fs_sb_info *sbi)
  4103	{
  4104		return f2fs_sb_has_blkzoned(sbi);
  4105	}
  4106	
  4107	static inline bool f2fs_bdev_support_discard(struct block_device *bdev)
  4108	{
  4109		return blk_queue_discard(bdev_get_queue(bdev)) ||
  4110		       bdev_is_zoned(bdev);
  4111	}
  4112	
  4113	static inline bool f2fs_hw_support_discard(struct f2fs_sb_info *sbi)
  4114	{
  4115		int i;
  4116	
  4117		if (!f2fs_is_multi_device(sbi))
  4118			return f2fs_bdev_support_discard(sbi->sb->s_bdev);
  4119	
  4120		for (i = 0; i < sbi->s_ndevs; i++)
  4121			if (f2fs_bdev_support_discard(FDEV(i).bdev))
  4122				return true;
  4123		return false;
  4124	}
  4125	
  4126	static inline bool f2fs_realtime_discard_enable(struct f2fs_sb_info *sbi)
  4127	{
  4128		return (test_opt(sbi, DISCARD) && f2fs_hw_support_discard(sbi)) ||
  4129						f2fs_hw_should_discard(sbi);
  4130	}
  4131	
  4132	static inline bool f2fs_hw_is_readonly(struct f2fs_sb_info *sbi)
  4133	{
  4134		int i;
  4135	
  4136		if (!f2fs_is_multi_device(sbi))
  4137			return bdev_read_only(sbi->sb->s_bdev);
  4138	
  4139		for (i = 0; i < sbi->s_ndevs; i++)
  4140			if (bdev_read_only(FDEV(i).bdev))
  4141				return true;
  4142		return false;
  4143	}
  4144	
  4145	static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
  4146	{
  4147		return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
  4148	}
  4149	
  4150	static inline bool f2fs_may_compress(struct inode *inode)
  4151	{
  4152		if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) ||
  4153					f2fs_is_atomic_file(inode) ||
  4154					f2fs_is_volatile_file(inode))
  4155			return false;
  4156		return S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode);
  4157	}
  4158	
  4159	static inline void f2fs_i_compr_blocks_update(struct inode *inode,
  4160						u64 blocks, bool add, bool accumulate)
  4161	{
  4162		int diff = F2FS_I(inode)->i_cluster_size - blocks;
  4163		struct f2fs_inode_info *fi = F2FS_I(inode);
  4164	
  4165		/* don't update i_compr_blocks if saved blocks were released */
  4166		if (!add && !atomic_read(&fi->i_compr_blocks))
  4167			return;
  4168	
  4169		if (add) {
  4170			atomic_add(diff, &fi->i_compr_blocks);
  4171			stat_add_compr_blocks(inode, diff);
  4172			if (accumulate)
> 4173				stat_add_acc_compr_blocks(inode, diff);
  4174		} else {
  4175			atomic_sub(diff, &fi->i_compr_blocks);
  4176			stat_sub_compr_blocks(inode, diff);
  4177			if (accumulate)
> 4178				stat_sub_acc_compr_blocks(inode, diff);
  4179		}
  4180		f2fs_mark_inode_dirty_sync(inode, true);
  4181	}
  4182	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32258 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-04 12:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-04  9:33 [PATCH] f2fs: add sysfs nodes to get accumulated compression info Daeho Jeong
2021-03-04 12:25 ` kernel test robot
2021-03-04 12:31 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox