linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type
@ 2023-03-21 23:11 Jaegeuk Kim
  2023-03-21 23:35 ` Jaegeuk Kim
  2023-03-27 16:00 ` patchwork-bot+f2fs
  0 siblings, 2 replies; 4+ messages in thread
From: Jaegeuk Kim @ 2023-03-21 23:11 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

If we manage the zone capacity per zone type, it'll break the GC assumption.
And, the current logic complains valid block count mismatch.
Let's apply zone capacity to all zone type, if specified.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c | 65 +++--------------------------------------------
 fs/f2fs/segment.h |  3 +++
 2 files changed, 7 insertions(+), 61 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 055e70e77aa2..6c11789da884 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4999,48 +4999,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)
 	return 0;
 }
 
-static bool is_conv_zone(struct f2fs_sb_info *sbi, unsigned int zone_idx,
-						unsigned int dev_idx)
-{
-	if (!bdev_is_zoned(FDEV(dev_idx).bdev))
-		return true;
-	return !test_bit(zone_idx, FDEV(dev_idx).blkz_seq);
-}
-
-/* Return the zone index in the given device */
-static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno,
-					int dev_idx)
-{
-	block_t sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
-
-	return (sec_start_blkaddr - FDEV(dev_idx).start_blk) >>
-						sbi->log_blocks_per_blkz;
-}
-
-/*
- * Return the usable segments in a section based on the zone's
- * corresponding zone capacity. Zone is equal to a section.
- */
-static inline unsigned int f2fs_usable_zone_segs_in_sec(
-		struct f2fs_sb_info *sbi, unsigned int segno)
-{
-	unsigned int dev_idx, zone_idx;
-
-	dev_idx = f2fs_target_device_index(sbi, START_BLOCK(sbi, segno));
-	zone_idx = get_zone_idx(sbi, GET_SEC_FROM_SEG(sbi, segno), dev_idx);
-
-	/* Conventional zone's capacity is always equal to zone size */
-	if (is_conv_zone(sbi, zone_idx, dev_idx))
-		return sbi->segs_per_sec;
-
-	if (!sbi->unusable_blocks_per_sec)
-		return sbi->segs_per_sec;
-
-	/* Get the segment count beyond zone capacity block */
-	return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >>
-						sbi->log_blocks_per_seg);
-}
-
 /*
  * Return the number of usable blocks in a segment. The number of blocks
  * returned is always equal to the number of blocks in a segment for
@@ -5053,23 +5011,13 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(
 			struct f2fs_sb_info *sbi, unsigned int segno)
 {
 	block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr;
-	unsigned int zone_idx, dev_idx, secno;
-
-	secno = GET_SEC_FROM_SEG(sbi, segno);
-	seg_start = START_BLOCK(sbi, segno);
-	dev_idx = f2fs_target_device_index(sbi, seg_start);
-	zone_idx = get_zone_idx(sbi, secno, dev_idx);
-
-	/*
-	 * Conventional zone's capacity is always equal to zone size,
-	 * so, blocks per segment is unchanged.
-	 */
-	if (is_conv_zone(sbi, zone_idx, dev_idx))
-		return sbi->blocks_per_seg;
+	unsigned int secno;
 
 	if (!sbi->unusable_blocks_per_sec)
 		return sbi->blocks_per_seg;
 
+	secno = GET_SEC_FROM_SEG(sbi, segno);
+	seg_start = START_BLOCK(sbi, segno);
 	sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
 	sec_cap_blkaddr = sec_start_blkaddr + CAP_BLKS_PER_SEC(sbi);
 
@@ -5103,11 +5051,6 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi
 	return 0;
 }
 
-static inline unsigned int f2fs_usable_zone_segs_in_sec(struct f2fs_sb_info *sbi,
-							unsigned int segno)
-{
-	return 0;
-}
 #endif
 unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
 					unsigned int segno)
@@ -5122,7 +5065,7 @@ unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
 					unsigned int segno)
 {
 	if (f2fs_sb_has_blkzoned(sbi))
-		return f2fs_usable_zone_segs_in_sec(sbi, segno);
+		return CAP_SEGS_PER_SEC(sbi);
 
 	return sbi->segs_per_sec;
 }
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index efdb7fc3b797..babb29a1c034 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -104,6 +104,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
 #define CAP_BLKS_PER_SEC(sbi)					\
 	((sbi)->segs_per_sec * (sbi)->blocks_per_seg -		\
 	 (sbi)->unusable_blocks_per_sec)
+#define CAP_SEGS_PER_SEC(sbi)					\
+	((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\
+	(sbi)->log_blocks_per_seg))
 #define GET_SEC_FROM_SEG(sbi, segno)				\
 	(((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)
 #define GET_SEG_FROM_SEC(sbi, secno)				\
-- 
2.40.0.rc1.284.g88254d51c5-goog



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type
  2023-03-21 23:11 [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type Jaegeuk Kim
@ 2023-03-21 23:35 ` Jaegeuk Kim
  2023-03-26  3:53   ` Chao Yu
  2023-03-27 16:00 ` patchwork-bot+f2fs
  1 sibling, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2023-03-21 23:35 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel

On 03/21, Jaegeuk Kim wrote:
> If we manage the zone capacity per zone type, it'll break the GC assumption.
> And, the current logic complains valid block count mismatch.
> Let's apply zone capacity to all zone type, if specified.
> 

Added:

Fixes: de881df97768 ("f2fs: support zone capacity less than zone size")

> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c | 65 +++--------------------------------------------
>  fs/f2fs/segment.h |  3 +++
>  2 files changed, 7 insertions(+), 61 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 055e70e77aa2..6c11789da884 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4999,48 +4999,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)
>  	return 0;
>  }
>  
> -static bool is_conv_zone(struct f2fs_sb_info *sbi, unsigned int zone_idx,
> -						unsigned int dev_idx)
> -{
> -	if (!bdev_is_zoned(FDEV(dev_idx).bdev))
> -		return true;
> -	return !test_bit(zone_idx, FDEV(dev_idx).blkz_seq);
> -}
> -
> -/* Return the zone index in the given device */
> -static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno,
> -					int dev_idx)
> -{
> -	block_t sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
> -
> -	return (sec_start_blkaddr - FDEV(dev_idx).start_blk) >>
> -						sbi->log_blocks_per_blkz;
> -}
> -
> -/*
> - * Return the usable segments in a section based on the zone's
> - * corresponding zone capacity. Zone is equal to a section.
> - */
> -static inline unsigned int f2fs_usable_zone_segs_in_sec(
> -		struct f2fs_sb_info *sbi, unsigned int segno)
> -{
> -	unsigned int dev_idx, zone_idx;
> -
> -	dev_idx = f2fs_target_device_index(sbi, START_BLOCK(sbi, segno));
> -	zone_idx = get_zone_idx(sbi, GET_SEC_FROM_SEG(sbi, segno), dev_idx);
> -
> -	/* Conventional zone's capacity is always equal to zone size */
> -	if (is_conv_zone(sbi, zone_idx, dev_idx))
> -		return sbi->segs_per_sec;
> -
> -	if (!sbi->unusable_blocks_per_sec)
> -		return sbi->segs_per_sec;
> -
> -	/* Get the segment count beyond zone capacity block */
> -	return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >>
> -						sbi->log_blocks_per_seg);
> -}
> -
>  /*
>   * Return the number of usable blocks in a segment. The number of blocks
>   * returned is always equal to the number of blocks in a segment for
> @@ -5053,23 +5011,13 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(
>  			struct f2fs_sb_info *sbi, unsigned int segno)
>  {
>  	block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr;
> -	unsigned int zone_idx, dev_idx, secno;
> -
> -	secno = GET_SEC_FROM_SEG(sbi, segno);
> -	seg_start = START_BLOCK(sbi, segno);
> -	dev_idx = f2fs_target_device_index(sbi, seg_start);
> -	zone_idx = get_zone_idx(sbi, secno, dev_idx);
> -
> -	/*
> -	 * Conventional zone's capacity is always equal to zone size,
> -	 * so, blocks per segment is unchanged.
> -	 */
> -	if (is_conv_zone(sbi, zone_idx, dev_idx))
> -		return sbi->blocks_per_seg;
> +	unsigned int secno;
>  
>  	if (!sbi->unusable_blocks_per_sec)
>  		return sbi->blocks_per_seg;
>  
> +	secno = GET_SEC_FROM_SEG(sbi, segno);
> +	seg_start = START_BLOCK(sbi, segno);
>  	sec_start_blkaddr = START_BLOCK(sbi, GET_SEG_FROM_SEC(sbi, secno));
>  	sec_cap_blkaddr = sec_start_blkaddr + CAP_BLKS_PER_SEC(sbi);
>  
> @@ -5103,11 +5051,6 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi
>  	return 0;
>  }
>  
> -static inline unsigned int f2fs_usable_zone_segs_in_sec(struct f2fs_sb_info *sbi,
> -							unsigned int segno)
> -{
> -	return 0;
> -}
>  #endif
>  unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi,
>  					unsigned int segno)
> @@ -5122,7 +5065,7 @@ unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi,
>  					unsigned int segno)
>  {
>  	if (f2fs_sb_has_blkzoned(sbi))
> -		return f2fs_usable_zone_segs_in_sec(sbi, segno);
> +		return CAP_SEGS_PER_SEC(sbi);
>  
>  	return sbi->segs_per_sec;
>  }
> diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
> index efdb7fc3b797..babb29a1c034 100644
> --- a/fs/f2fs/segment.h
> +++ b/fs/f2fs/segment.h
> @@ -104,6 +104,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
>  #define CAP_BLKS_PER_SEC(sbi)					\
>  	((sbi)->segs_per_sec * (sbi)->blocks_per_seg -		\
>  	 (sbi)->unusable_blocks_per_sec)
> +#define CAP_SEGS_PER_SEC(sbi)					\
> +	((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\
> +	(sbi)->log_blocks_per_seg))
>  #define GET_SEC_FROM_SEG(sbi, segno)				\
>  	(((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)
>  #define GET_SEG_FROM_SEC(sbi, secno)				\
> -- 
> 2.40.0.rc1.284.g88254d51c5-goog


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type
  2023-03-21 23:35 ` Jaegeuk Kim
@ 2023-03-26  3:53   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2023-03-26  3:53 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel

On 2023/3/22 7:35, Jaegeuk Kim wrote:
> On 03/21, Jaegeuk Kim wrote:
>> If we manage the zone capacity per zone type, it'll break the GC assumption.
>> And, the current logic complains valid block count mismatch.
>> Let's apply zone capacity to all zone type, if specified.
>>
> 
> Added:
> 
> Fixes: de881df97768 ("f2fs: support zone capacity less than zone size")
> 
>> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type
  2023-03-21 23:11 [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type Jaegeuk Kim
  2023-03-21 23:35 ` Jaegeuk Kim
@ 2023-03-27 16:00 ` patchwork-bot+f2fs
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+f2fs @ 2023-03-27 16:00 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Tue, 21 Mar 2023 16:11:57 -0700 you wrote:
> If we manage the zone capacity per zone type, it'll break the GC assumption.
> And, the current logic complains valid block count mismatch.
> Let's apply zone capacity to all zone type, if specified.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c | 65 +++--------------------------------------------
>  fs/f2fs/segment.h |  3 +++
>  2 files changed, 7 insertions(+), 61 deletions(-)

Here is the summary with links:
  - [f2fs-dev] f2fs: apply zone capacity to all zone type
    https://git.kernel.org/jaegeuk/f2fs/c/0b7d8adb1ba1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2023-03-27 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 23:11 [f2fs-dev] [PATCH] f2fs: apply zone capacity to all zone type Jaegeuk Kim
2023-03-21 23:35 ` Jaegeuk Kim
2023-03-26  3:53   ` Chao Yu
2023-03-27 16:00 ` patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).