2018-10-30 12:32:01

by Yunlong Song

[permalink] [raw]
Subject: [PATCH] f2fs: fix get_blocktype_secs bug when segs_per_sec is larger than 1

f2fs_need_SSR uses get_blocktype_secs to calculate needed dirty
sections, however, for the case segs_per_sec > 1, when needed segs are
smaller than segs_per_sec, it will just return 0, so fix it.

Signed-off-by: Yunlong Song <[email protected]>
---
fs/f2fs/f2fs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 56204a8..d47417b 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1842,7 +1842,7 @@ static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
unsigned int segs = (get_pages(sbi, block_type) + pages_per_sec - 1) >>
sbi->log_blocks_per_seg;

- return segs / sbi->segs_per_sec;
+ return (segs / sbi->segs_per_sec + sbi->segs_per_sec - 1) / sbi->segs_per_sec;
}

static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
--
1.8.5.2



2018-10-30 12:47:48

by Yunlong Song

[permalink] [raw]
Subject: [PATCH v2] f2fs: fix get_blocktype_secs bug when segs_per_sec is larger than 1

f2fs_need_SSR uses get_blocktype_secs to calculate needed dirty
sections, however, for the case segs_per_sec > 1, when needed segs are
smaller than segs_per_sec, it will just return 0, so fix it.

Signed-off-by: Yunlong Song <[email protected]>
---
fs/f2fs/f2fs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 56204a8..ef41ea2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1842,7 +1842,7 @@ static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
unsigned int segs = (get_pages(sbi, block_type) + pages_per_sec - 1) >>
sbi->log_blocks_per_seg;

- return segs / sbi->segs_per_sec;
+ return (segs + sbi->segs_per_sec - 1) / sbi->segs_per_sec;
}

static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
--
1.8.5.2


2018-10-31 03:41:41

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH v2] f2fs: fix get_blocktype_secs bug when segs_per_sec is larger than 1

On 2018/10/30 20:46, Yunlong Song wrote:
> f2fs_need_SSR uses get_blocktype_secs to calculate needed dirty
> sections, however, for the case segs_per_sec > 1, when needed segs are
> smaller than segs_per_sec, it will just return 0, so fix it.
>
> Signed-off-by: Yunlong Song <[email protected]>
> ---
> fs/f2fs/f2fs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 56204a8..ef41ea2 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1842,7 +1842,7 @@ static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
> unsigned int segs = (get_pages(sbi, block_type) + pages_per_sec - 1) >>
> sbi->log_blocks_per_seg;
>
> - return segs / sbi->segs_per_sec;
> + return (segs + sbi->segs_per_sec - 1) / sbi->segs_per_sec;

roundup(segs, sbi->segs_per_sec)?

Thanks,

> }
>
> static inline block_t valid_user_blocks(struct f2fs_sb_info *sbi)
>