2023-03-22 13:15:08

by Yohan Joung

[permalink] [raw]
Subject: [PATCH] f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

Signed-off-by: Yohan Joung <[email protected]>
---
fs/f2fs/segment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 055e70e77aa2..46458085a8d0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1858,7 +1858,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
sector = SECTOR_FROM_BLOCK(blkstart);
nr_sects = SECTOR_FROM_BLOCK(blklen);

- if (sector & (bdev_zone_sectors(bdev) - 1) ||
+ if (sector % bdev_zone_sectors(bdev) ||
nr_sects != bdev_zone_sectors(bdev)) {
f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
devi, sbi->s_ndevs ? FDEV(devi).path : "",
--
2.25.1


2023-03-23 02:42:15

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] f2fs: fix align check for npo2

Hi Yohan,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on jaegeuk-f2fs/dev-test]
[also build test ERROR on jaegeuk-f2fs/dev]
[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/Yohan-Joung/f2fs-fix-align-check-for-npo2/20230322-211529
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
patch link: https://lore.kernel.org/r/20230322131408.1192-1-jyh429%40gmail.com
patch subject: [PATCH] f2fs: fix align check for npo2
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20230323/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/3531dd5850533df89bd45af9fd59ed4693d6d5aa
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Yohan-Joung/f2fs-fix-align-check-for-npo2/20230322-211529
git checkout 3531dd5850533df89bd45af9fd59ed4693d6d5aa
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "__umoddi3" [fs/f2fs/f2fs.ko] undefined!
>> ERROR: modpost: "__moddi3" [fs/f2fs/f2fs.ko] undefined!

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-03-23 07:25:31

by Yohan Joung

[permalink] [raw]
Subject: [PATCH] f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

Signed-off-by: Yohan Joung <[email protected]>
---
fs/f2fs/segment.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 055e70e77aa2..46458085a8d0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1858,7 +1858,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
sector = SECTOR_FROM_BLOCK(blkstart);
nr_sects = SECTOR_FROM_BLOCK(blklen);

- if (sector & (bdev_zone_sectors(bdev) - 1) ||
+ if (sector % bdev_zone_sectors(bdev) ||
nr_sects != bdev_zone_sectors(bdev)) {
f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
devi, sbi->s_ndevs ? FDEV(devi).path : "",

base-commit: d15180a8d1d72c7bddcb700d2c9ffdab7d2b9481
--
2.25.1

2023-03-23 23:50:18

by Jaegeuk Kim

[permalink] [raw]
Subject: Re: [PATCH] f2fs: fix align check for npo2

On 03/23, Yohan Joung wrote:
> Fix alignment check to be correct in npo2 as well
>
> Signed-off-by: Yohan Joung <[email protected]>
> ---
> fs/f2fs/segment.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 055e70e77aa2..46458085a8d0 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1858,7 +1858,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> sector = SECTOR_FROM_BLOCK(blkstart);
> nr_sects = SECTOR_FROM_BLOCK(blklen);
>
> - if (sector & (bdev_zone_sectors(bdev) - 1) ||
> + if (sector % bdev_zone_sectors(bdev) ||

Need to use div_u64_rem()?

> nr_sects != bdev_zone_sectors(bdev)) {
> f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
> devi, sbi->s_ndevs ? FDEV(devi).path : "",
>
> base-commit: d15180a8d1d72c7bddcb700d2c9ffdab7d2b9481
> --
> 2.25.1

2023-03-24 13:14:47

by Yohan Joung

[permalink] [raw]
Subject: [PATCH] f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

Signed-off-by: Yohan Joung <[email protected]>
---
fs/f2fs/segment.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 055e70e77aa2..f4a22a065277 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1842,6 +1842,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
sector_t sector, nr_sects;
block_t lblkstart = blkstart;
int devi = 0;
+ u32 remainder = 0;

if (f2fs_is_multi_device(sbi)) {
devi = f2fs_target_device_index(sbi, blkstart);
@@ -1857,9 +1858,9 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
if (f2fs_blkz_is_seq(sbi, devi, blkstart)) {
sector = SECTOR_FROM_BLOCK(blkstart);
nr_sects = SECTOR_FROM_BLOCK(blklen);
+ div_u64_rem(sector, bdev_zone_sectors(bdev), &remainder);

- if (sector & (bdev_zone_sectors(bdev) - 1) ||
- nr_sects != bdev_zone_sectors(bdev)) {
+ if (remainder || nr_sects != bdev_zone_sectors(bdev)) {
f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
devi, sbi->s_ndevs ? FDEV(devi).path : "",
blkstart, blklen);
--
2.25.1

2023-04-01 01:58:22

by Chao Yu

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix align check for npo2

On 2023/3/24 21:07, Yohan Joung wrote:
> Fix alignment check to be correct in npo2 as well
>
> Signed-off-by: Yohan Joung <[email protected]>
> ---
> fs/f2fs/segment.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 055e70e77aa2..f4a22a065277 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1842,6 +1842,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> sector_t sector, nr_sects;
> block_t lblkstart = blkstart;
> int devi = 0;
> + u32 remainder = 0;
>
> if (f2fs_is_multi_device(sbi)) {
> devi = f2fs_target_device_index(sbi, blkstart);
> @@ -1857,9 +1858,9 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> if (f2fs_blkz_is_seq(sbi, devi, blkstart)) {
> sector = SECTOR_FROM_BLOCK(blkstart);
> nr_sects = SECTOR_FROM_BLOCK(blklen);
> + div_u64_rem(sector, bdev_zone_sectors(bdev), &remainder);

Should use div64_u64_rem()? As both sector and return value of bdev_zone_sectors()
are u64.

Thanks,

>
> - if (sector & (bdev_zone_sectors(bdev) - 1) ||
> - nr_sects != bdev_zone_sectors(bdev)) {
> + if (remainder || nr_sects != bdev_zone_sectors(bdev)) {
> f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted (block %x + %x)",
> devi, sbi->s_ndevs ? FDEV(devi).path : "",
> blkstart, blklen);

2023-04-02 03:49:56

by Yohan Joung

[permalink] [raw]
Subject: RE: [f2fs-dev] [PATCH] f2fs: fix align check for npo2

> -----Original Message-----
> From: Chao Yu [mailto:[email protected]]
> Sent: Saturday, April 1, 2023 10:49 AM
> To: Yohan Joung; [email protected]
> Cc: [email protected]; [email protected]; linux-f2fs-
> [email protected]; [email protected]
> Subject: Re: [f2fs-dev] [PATCH] f2fs: fix align check for npo2
>
> On 2023/3/24 21:07, Yohan Joung wrote:
> > Fix alignment check to be correct in npo2 as well
> >
> > Signed-off-by: Yohan Joung <[email protected]>
> > ---
> > fs/f2fs/segment.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index
> > 055e70e77aa2..f4a22a065277 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -1842,6 +1842,7 @@ static int __f2fs_issue_discard_zone(struct
> f2fs_sb_info *sbi,
> > sector_t sector, nr_sects;
> > block_t lblkstart = blkstart;
> > int devi = 0;
> > + u32 remainder = 0;
> >
> > if (f2fs_is_multi_device(sbi)) {
> > devi = f2fs_target_device_index(sbi, blkstart); @@ -1857,9
> +1858,9
> > @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> > if (f2fs_blkz_is_seq(sbi, devi, blkstart)) {
> > sector = SECTOR_FROM_BLOCK(blkstart);
> > nr_sects = SECTOR_FROM_BLOCK(blklen);
> > + div_u64_rem(sector, bdev_zone_sectors(bdev), &remainder);
>
> Should use div64_u64_rem()? As both sector and return value of
> bdev_zone_sectors() are u64.
>
> Thanks,
Upload based on your comments.
Thanks
>
> >
> > - if (sector & (bdev_zone_sectors(bdev) - 1) ||
> > - nr_sects != bdev_zone_sectors(bdev)) {
> > + if (remainder || nr_sects != bdev_zone_sectors(bdev)) {
> > f2fs_err(sbi, "(%d) %s: Unaligned zone reset attempted
> (block %x + %x)",
> > devi, sbi->s_ndevs ? FDEV(devi).path : "",
> > blkstart, blklen);