2021-02-27 12:06:54

by Huang Jianan

[permalink] [raw]
Subject: [PATCH 2/3] f2fs: fix last_lblock check in check_swap_activate_fast

Because page_no < sis->max guarantees that the while loop break out
normally, the wrong check contidion here doesn't cause a problem.

Signed-off-by: Huang Jianan <[email protected]>
Signed-off-by: Guo Weichao <[email protected]>
---
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a1498a1a345c..4dbc1cafc55d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3804,7 +3804,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
last_lblock = bytes_to_blks(inode, i_size_read(inode));
len = i_size_read(inode);

- while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
+ while (cur_lblock + 1 <= last_lblock && cur_lblock < sis->max) {
struct f2fs_map_blocks map;
pgoff_t next_pgofs;

--
2.25.1


2021-03-01 03:19:38

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH 2/3] f2fs: fix last_lblock check in check_swap_activate_fast

On 2021/2/27 20:02, Huang Jianan via Linux-f2fs-devel wrote:
> Because page_no < sis->max guarantees that the while loop break out
> normally, the wrong check contidion here doesn't cause a problem.
>
> Signed-off-by: Huang Jianan <[email protected]>
> Signed-off-by: Guo Weichao <[email protected]>
> ---
> fs/f2fs/data.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index a1498a1a345c..4dbc1cafc55d 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3804,7 +3804,7 @@ static int check_swap_activate_fast(struct swap_info_struct *sis,
> last_lblock = bytes_to_blks(inode, i_size_read(inode));
> len = i_size_read(inode);
>
> - while (cur_lblock <= last_lblock && cur_lblock < sis->max) {
> + while (cur_lblock + 1 <= last_lblock && cur_lblock < sis->max) {

while (cur_lblock < last_lblock && cur_lblock < sis->max) {

It's nitpick, if necessary, I guess Jaegeuk could help to change this
while merging.

Reviewed-by: Chao Yu <[email protected]>

Thanks,

> struct f2fs_map_blocks map;
> pgoff_t next_pgofs;
>
>