Message ID | 20230324130747.523-1-jyh429@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [f2fs-dev] f2fs: fix align check for npo2 | expand |
On 2023/3/24 21:07, Yohan Joung wrote: > Fix alignment check to be correct in npo2 as well > > Signed-off-by: Yohan Joung <yohan.joung@sk.com> > --- > 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);
> -----Original Message----- > From: Chao Yu [mailto:chao@kernel.org] > Sent: Saturday, April 1, 2023 10:49 AM > To: Yohan Joung; jaegeuk@kernel.org > Cc: lkp@intel.com; linux-kernel@vger.kernel.org; linux-f2fs- > devel@lists.sourceforge.net; oe-kbuild-all@lists.linux.dev > 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 <yohan.joung@sk.com> > > --- > > 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);
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);
Fix alignment check to be correct in npo2 as well Signed-off-by: Yohan Joung <yohan.joung@sk.com> --- fs/f2fs/segment.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)