Skip to contentSkip to conversation

f2fs: fix align check for npo2

PATCH New Yohan Joung 4 participants 7 messages Mar 22, 2023 – Apr 2, 2023 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
index 055e70e77aa2..46458085a8d0 100644
@@ -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 : "",
Signature · 1 line
2.25.1
#1 lore raw
Thank you for the patch! Yet something to improve:

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!
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#2 lore raw

PATCH 1/1 f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
index 055e70e77aa2..46458085a8d0 100644
@@ -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

Signature · 1 line
2.25.1
maintainer
#3 lore raw
Quoted 12 lines · Yohan Joung

Fix alignment check to be correct in npo2 as well

---
 fs/f2fs/segment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +0 -0
index 055e70e77aa2..46458085a8d0 100644

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, · line 1861

Quoted 5 lines
fs/f2fs/segment.c +1 -1
@@ -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()?

Quoted 7 lines
fs/f2fs/segment.c +0 -0
 				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

Signature · 1 line
2.25.1
#4 lore raw

PATCH 1/1 f2fs: fix align check for npo2

Fix alignment check to be correct in npo2 as well

---
 fs/f2fs/segment.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +3 -2
index 055e70e77aa2..f4a22a065277 100644
@@ -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);
Signature · 1 line
2.25.1
maintainer
#5 lore raw
Quoted 20 lines · Yohan Joung

Fix alignment check to be correct in npo2 as well

---
  fs/f2fs/segment.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +1 -0
index 055e70e77aa2..f4a22a065277 100644
@@ -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);

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, · line 1861

Quoted 4 lines
fs/f2fs/segment.c +1 -0
@@ -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,

Quoted 7 lines
fs/f2fs/segment.c +1 -2
-		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);
#6 lore raw
Quoted 39 lines

-----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

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct

Quoted 12 lines · Yohan Joung

Fix alignment check to be correct in npo2 as well

---
  fs/f2fs/segment.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.c index renamed from fs/f2fs/segment.c +0 -0

055e70e77aa2..f4a22a065277 100644

fs/f2fs/segment.c +0 -0
@@ -1842,6 +1842,7 @@ static int __f2fs_issue_discard_zone(struct

f2fs_sb_info *sbi,

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,

Quoted 7 lines
fs/f2fs/segment.c +1 -0
  	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

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, · line 1861

Quoted 5 lines

@@ 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);

fs/f2fs/segment.c +1 -0
+		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.

Quoted 1 line

Thanks,

Upload based on your comments.
Thanks

Quoted 9 lines

fs/f2fs/segment.c static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,

Quoted 6 lines
fs/f2fs/segment.c +1 -2
-		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)",

Quoted 2 lines

devi, sbi->s_ndevs ? FDEV(devi).path : "", blkstart, blklen);