diff mbox series

[f2fs-dev] f2fs: fix to convert log type to segment data type correctly

Message ID 20241018092200.2792472-1-chao@kernel.org (mailing list archive)
State Superseded
Headers show
Series [f2fs-dev] f2fs: fix to convert log type to segment data type correctly | expand

Commit Message

Chao Yu Oct. 18, 2024, 9:22 a.m. UTC
This patch introduces a new helper log_type_to_seg_type() to convert
log type to segment data type, and uses it to clean up opened codes
in build_curseg(), and also it fixes to convert log type before use
in do_write_page().

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/segment.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

Comments

kernel test robot Oct. 19, 2024, 12:59 p.m. UTC | #1
Hi Chao,

kernel test robot noticed the following build errors:

[auto build test ERROR on jaegeuk-f2fs/dev-test]
[also build test ERROR on jaegeuk-f2fs/dev linus/master v6.12-rc3 next-20241018]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-fix-to-convert-log-type-to-segment-data-type-correctly/20241018-172401
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link:    https://lore.kernel.org/r/20241018092200.2792472-1-chao%40kernel.org
patch subject: [PATCH] f2fs: fix to convert log type to segment data type correctly
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241019/202410192028.vIwx2fbN-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241019/202410192028.vIwx2fbN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410192028.vIwx2fbN-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> fs/f2fs/segment.c:3818:38: warning: 'enum log_type' declared inside parameter list will not be visible outside of this definition or declaration
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                      ^~~~~~~~
>> fs/f2fs/segment.c:3818:47: error: parameter 1 ('type') has incomplete type
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                 ~~~~~~~~~~~~~~^~~~
>> fs/f2fs/segment.c:3818:12: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    3818 | static int log_type_to_seg_type(enum log_type type)
         |            ^~~~~~~~~~~~~~~~~~~~
   fs/f2fs/segment.c: In function 'do_write_page':
>> fs/f2fs/segment.c:3843:14: error: variable 'type' has initializer but incomplete type
    3843 |         enum log_type type = __get_segment_type(fio);
         |              ^~~~~~~~
>> fs/f2fs/segment.c:3843:23: error: storage size of 'type' isn't known
    3843 |         enum log_type type = __get_segment_type(fio);
         |                       ^~~~
>> fs/f2fs/segment.c:3843:23: warning: unused variable 'type' [-Wunused-variable]
   cc1: some warnings being treated as errors


vim +3818 fs/f2fs/segment.c

  3817	
> 3818	static int log_type_to_seg_type(enum log_type type)
  3819	{
  3820		int seg_type = CURSEG_COLD_DATA;
  3821	
  3822		switch (type) {
  3823		case CURSEG_HOT_DATA:
  3824		case CURSEG_WARM_DATA:
  3825		case CURSEG_COLD_DATA:
  3826		case CURSEG_HOT_NODE:
  3827		case CURSEG_WARM_NODE:
  3828		case CURSEG_COLD_NODE:
  3829			seg_type = (int)type;
  3830			break;
  3831		case CURSEG_COLD_DATA_PINNED:
  3832		case CURSEG_ALL_DATA_ATGC:
  3833			seg_type = CURSEG_COLD_DATA;
  3834			break;
  3835		default:
  3836			break;
  3837		}
  3838		return seg_type;
  3839	}
  3840	
  3841	static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
  3842	{
> 3843		enum log_type type = __get_segment_type(fio);
  3844		int seg_type = log_type_to_seg_type(type);
  3845		bool keep_order = (f2fs_lfs_mode(fio->sbi) &&
  3846					seg_type == CURSEG_COLD_DATA);
  3847	
  3848		if (keep_order)
  3849			f2fs_down_read(&fio->sbi->io_order_lock);
  3850	
  3851		if (f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr,
  3852				&fio->new_blkaddr, sum, type, fio)) {
  3853			if (fscrypt_inode_uses_fs_layer_crypto(fio->page->mapping->host))
  3854				fscrypt_finalize_bounce_page(&fio->encrypted_page);
  3855			end_page_writeback(fio->page);
  3856			if (f2fs_in_warm_node_list(fio->sbi, fio->page))
  3857				f2fs_del_fsync_node_entry(fio->sbi, fio->page);
  3858			goto out;
  3859		}
  3860		if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO)
  3861			f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr);
  3862	
  3863		/* writeout dirty page into bdev */
  3864		f2fs_submit_page_write(fio);
  3865	
  3866		f2fs_update_device_state(fio->sbi, fio->ino, fio->new_blkaddr, 1);
  3867	out:
  3868		if (keep_order)
  3869			f2fs_up_read(&fio->sbi->io_order_lock);
  3870	}
  3871
kernel test robot Oct. 19, 2024, 9:57 p.m. UTC | #2
Hi Chao,

kernel test robot noticed the following build errors:

[auto build test ERROR on jaegeuk-f2fs/dev-test]
[also build test ERROR on jaegeuk-f2fs/dev linus/master v6.12-rc3 next-20241018]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-fix-to-convert-log-type-to-segment-data-type-correctly/20241018-172401
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link:    https://lore.kernel.org/r/20241018092200.2792472-1-chao%40kernel.org
patch subject: [PATCH] f2fs: fix to convert log type to segment data type correctly
config: i386-buildonly-randconfig-002-20241019 (https://download.01.org/0day-ci/archive/20241020/202410200521.Mc4H4BHm-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241020/202410200521.Mc4H4BHm-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410200521.Mc4H4BHm-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> fs/f2fs/segment.c:3818:38: warning: declaration of 'enum log_type' will not be visible outside of this function [-Wvisibility]
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                      ^
>> fs/f2fs/segment.c:3818:47: error: variable has incomplete type 'enum log_type'
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                               ^
   fs/f2fs/segment.c:3818:38: note: forward declaration of 'enum log_type'
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                      ^
   fs/f2fs/segment.c:3843:16: error: variable has incomplete type 'enum log_type'
    3843 |         enum log_type type = __get_segment_type(fio);
         |                       ^
   fs/f2fs/segment.c:3843:7: note: forward declaration of 'enum log_type'
    3843 |         enum log_type type = __get_segment_type(fio);
         |              ^
>> fs/f2fs/segment.c:4828:44: error: argument type 'enum log_type' is incomplete
    4828 |                 array[i].seg_type = log_type_to_seg_type(i);
         |                                                          ^
   fs/f2fs/segment.c:3818:38: note: forward declaration of 'enum log_type'
    3818 | static int log_type_to_seg_type(enum log_type type)
         |                                      ^
   1 warning and 3 errors generated.


vim +3818 fs/f2fs/segment.c

  3817	
> 3818	static int log_type_to_seg_type(enum log_type type)
  3819	{
  3820		int seg_type = CURSEG_COLD_DATA;
  3821	
  3822		switch (type) {
  3823		case CURSEG_HOT_DATA:
  3824		case CURSEG_WARM_DATA:
  3825		case CURSEG_COLD_DATA:
  3826		case CURSEG_HOT_NODE:
  3827		case CURSEG_WARM_NODE:
  3828		case CURSEG_COLD_NODE:
  3829			seg_type = (int)type;
  3830			break;
  3831		case CURSEG_COLD_DATA_PINNED:
  3832		case CURSEG_ALL_DATA_ATGC:
  3833			seg_type = CURSEG_COLD_DATA;
  3834			break;
  3835		default:
  3836			break;
  3837		}
  3838		return seg_type;
  3839	}
  3840
Chao Yu Oct. 22, 2024, 2:08 a.m. UTC | #3
Hi,

Thanks for the report, I rebased this patch on top of
https://lore.kernel.org/linux-f2fs-devel/20241017012932.1570038-1-chao@kernel.org,
so there will be dependency in between these two patch.

Thanks,

On 2024/10/20 5:57, kernel test robot wrote:
> Hi Chao,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on jaegeuk-f2fs/dev-test]
> [also build test ERROR on jaegeuk-f2fs/dev linus/master v6.12-rc3 next-20241018]
> [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#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Chao-Yu/f2fs-fix-to-convert-log-type-to-segment-data-type-correctly/20241018-172401
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
> patch link:    https://lore.kernel.org/r/20241018092200.2792472-1-chao%40kernel.org
> patch subject: [PATCH] f2fs: fix to convert log type to segment data type correctly
> config: i386-buildonly-randconfig-002-20241019 (https://download.01.org/0day-ci/archive/20241020/202410200521.Mc4H4BHm-lkp@intel.com/config)
> compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241020/202410200521.Mc4H4BHm-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202410200521.Mc4H4BHm-lkp@intel.com/
> 
> All error/warnings (new ones prefixed by >>):
> 
>>> fs/f2fs/segment.c:3818:38: warning: declaration of 'enum log_type' will not be visible outside of this function [-Wvisibility]
>      3818 | static int log_type_to_seg_type(enum log_type type)
>           |                                      ^
>>> fs/f2fs/segment.c:3818:47: error: variable has incomplete type 'enum log_type'
>      3818 | static int log_type_to_seg_type(enum log_type type)
>           |                                               ^
>     fs/f2fs/segment.c:3818:38: note: forward declaration of 'enum log_type'
>      3818 | static int log_type_to_seg_type(enum log_type type)
>           |                                      ^
>     fs/f2fs/segment.c:3843:16: error: variable has incomplete type 'enum log_type'
>      3843 |         enum log_type type = __get_segment_type(fio);
>           |                       ^
>     fs/f2fs/segment.c:3843:7: note: forward declaration of 'enum log_type'
>      3843 |         enum log_type type = __get_segment_type(fio);
>           |              ^
>>> fs/f2fs/segment.c:4828:44: error: argument type 'enum log_type' is incomplete
>      4828 |                 array[i].seg_type = log_type_to_seg_type(i);
>           |                                                          ^
>     fs/f2fs/segment.c:3818:38: note: forward declaration of 'enum log_type'
>      3818 | static int log_type_to_seg_type(enum log_type type)
>           |                                      ^
>     1 warning and 3 errors generated.
> 
> 
> vim +3818 fs/f2fs/segment.c
> 
>    3817	
>> 3818	static int log_type_to_seg_type(enum log_type type)
>    3819	{
>    3820		int seg_type = CURSEG_COLD_DATA;
>    3821	
>    3822		switch (type) {
>    3823		case CURSEG_HOT_DATA:
>    3824		case CURSEG_WARM_DATA:
>    3825		case CURSEG_COLD_DATA:
>    3826		case CURSEG_HOT_NODE:
>    3827		case CURSEG_WARM_NODE:
>    3828		case CURSEG_COLD_NODE:
>    3829			seg_type = (int)type;
>    3830			break;
>    3831		case CURSEG_COLD_DATA_PINNED:
>    3832		case CURSEG_ALL_DATA_ATGC:
>    3833			seg_type = CURSEG_COLD_DATA;
>    3834			break;
>    3835		default:
>    3836			break;
>    3837		}
>    3838		return seg_type;
>    3839	}
>    3840	
>
diff mbox series

Patch

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index a1806976f4ad..e172b3d0aec3 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3836,10 +3836,35 @@  void f2fs_update_device_state(struct f2fs_sb_info *sbi, nid_t ino,
 	}
 }
 
+static int log_type_to_seg_type(enum log_type type)
+{
+	int seg_type = CURSEG_COLD_DATA;
+
+	switch (type) {
+	case CURSEG_HOT_DATA:
+	case CURSEG_WARM_DATA:
+	case CURSEG_COLD_DATA:
+	case CURSEG_HOT_NODE:
+	case CURSEG_WARM_NODE:
+	case CURSEG_COLD_NODE:
+		seg_type = (int)type;
+		break;
+	case CURSEG_COLD_DATA_PINNED:
+	case CURSEG_ALL_DATA_ATGC:
+		seg_type = CURSEG_COLD_DATA;
+		break;
+	default:
+		break;
+	}
+	return seg_type;
+}
+
 static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
 {
-	int type = __get_segment_type(fio);
-	bool keep_order = (f2fs_lfs_mode(fio->sbi) && type == CURSEG_COLD_DATA);
+	enum log_type type = __get_segment_type(fio);
+	int seg_type = log_type_to_seg_type(type);
+	bool keep_order = (f2fs_lfs_mode(fio->sbi) &&
+				seg_type == CURSEG_COLD_DATA);
 
 	if (keep_order)
 		f2fs_down_read(&fio->sbi->io_order_lock);
@@ -4845,12 +4870,7 @@  static int build_curseg(struct f2fs_sb_info *sbi)
 				sizeof(struct f2fs_journal), GFP_KERNEL);
 		if (!array[i].journal)
 			return -ENOMEM;
-		if (i < NR_PERSISTENT_LOG)
-			array[i].seg_type = CURSEG_HOT_DATA + i;
-		else if (i == CURSEG_COLD_DATA_PINNED)
-			array[i].seg_type = CURSEG_COLD_DATA;
-		else if (i == CURSEG_ALL_DATA_ATGC)
-			array[i].seg_type = CURSEG_COLD_DATA;
+		array[i].seg_type = log_type_to_seg_type(i);
 		reset_curseg_fields(&array[i]);
 	}
 	return restore_curseg_summaries(sbi);