* [PATCH] f2fs: fix 32-bit build
@ 2016-11-22 14:20 Arnd Bergmann
2016-11-22 14:27 ` Damien Le Moal
2016-11-23 18:42 ` Jaegeuk Kim
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2016-11-22 14:20 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: Damien Le Moal, Arnd Bergmann, linux-kernel, linux-f2fs-devel
The addition of multiple-device support broke CONFIG_BLK_DEV_ZONED
on 32-bit machines because of a 64-bit division:
fs/f2fs/f2fs.o: In function `__issue_discard_async':
extent_cache.c:(.text.__issue_discard_async+0xd4): undefined reference to `__aeabi_uldivmod'
Unfortunately, the sector number is usually a 64-bit number, and
we probably can't guarantee that bdev_zone_size() returns a
power-of-two number, so we actually have to do the expensive 64-bit
operation to get the remainder.
Fixes: 792b84b74b54 ("f2fs: support multiple devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/f2fs/segment.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 634834e5a232..e4c5497aa172 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -685,6 +685,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
{
sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
sector_t sector;
+ u32 rem;
int devi = 0;
if (sbi->s_ndevs) {
@@ -693,7 +694,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
}
sector = SECTOR_FROM_BLOCK(blkstart);
- if (sector % bdev_zone_size(bdev) || nr_sects != bdev_zone_size(bdev)) {
+ div_u64_rem(sector, bdev_zone_size(bdev), &rem);
+ if (rem || nr_sects != bdev_zone_size(bdev)) {
f2fs_msg(sbi->sb, KERN_INFO,
"(%d) %s: Unaligned discard attempted (block %x + %x)",
devi, sbi->s_ndevs ? FDEV(devi).path: "",
--
2.9.0
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: fix 32-bit build
2016-11-22 14:20 [PATCH] f2fs: fix 32-bit build Arnd Bergmann
@ 2016-11-22 14:27 ` Damien Le Moal
2016-11-23 18:42 ` Jaegeuk Kim
1 sibling, 0 replies; 5+ messages in thread
From: Damien Le Moal @ 2016-11-22 14:27 UTC (permalink / raw)
To: Arnd Bergmann, Jaegeuk Kim
Cc: Chao Yu, Yunlei He, Fan Li, linux-f2fs-devel, linux-kernel
Arnd,
> Unfortunately, the sector number is usually a 64-bit number, and
> we probably can't guarantee that bdev_zone_size() returns a
> power-of-two number, so we actually have to do the expensive 64-bit
> operation to get the remainder.
No, the zone size is guaranteed to be a power of 2. See sd_zbc.c in Jens
linux-block tree, branch for-4.10/block. So it is ok to do a
& (bdev_zone_size() - 1) for the remainder.
That was indeed my mistake in this patch. Modulo should not have been
used in the first place. My bad.
>
> Fixes: 792b84b74b54 ("f2fs: support multiple devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> fs/f2fs/segment.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 634834e5a232..e4c5497aa172 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -685,6 +685,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> {
> sector_t nr_sects = SECTOR_FROM_BLOCK(blklen);
> sector_t sector;
> + u32 rem;
> int devi = 0;
>
> if (sbi->s_ndevs) {
> @@ -693,7 +694,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> }
> sector = SECTOR_FROM_BLOCK(blkstart);
>
> - if (sector % bdev_zone_size(bdev) || nr_sects != bdev_zone_size(bdev)) {
> + div_u64_rem(sector, bdev_zone_size(bdev), &rem);
> + if (rem || nr_sects != bdev_zone_size(bdev)) {
> f2fs_msg(sbi->sb, KERN_INFO,
> "(%d) %s: Unaligned discard attempted (block %x + %x)",
> devi, sbi->s_ndevs ? FDEV(devi).path: "",
Thanks !
Best regards.
--
Damien Le Moal, Ph.D.
Sr Manager, System Software Research Group,
Western Digital
Damien.LeMoal@hgst.com
Tel: (+81) 0466-98-3593 (Ext. 51-3593)
1 kirihara-cho, Fujisawa, Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: fix 32-bit build
2016-11-22 14:20 [PATCH] f2fs: fix 32-bit build Arnd Bergmann
2016-11-22 14:27 ` Damien Le Moal
@ 2016-11-23 18:42 ` Jaegeuk Kim
2016-11-23 21:05 ` Arnd Bergmann
1 sibling, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2016-11-23 18:42 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Chao Yu, Yunlei He, Damien Le Moal, Fan Li, linux-f2fs-devel,
linux-kernel
Hi Arnd,
As Damien mentioned, is this fine to go, if you don't mind?
I've confirmed that sd_zbc.c allows a power-of-two number only.
Thanks,
>From b709ff532daedc42526a46cb26860127f4959e01 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 22 Nov 2016 15:20:16 +0100
Subject: [PATCH] f2fs: fix 32-bit build
The addition of multiple-device support broke CONFIG_BLK_DEV_ZONED
on 32-bit machines because of a 64-bit division:
fs/f2fs/f2fs.o: In function `__issue_discard_async':
extent_cache.c:(.text.__issue_discard_async+0xd4): undefined reference to `__aeabi_uldivmod'
Unfortunately, the sector number is usually a 64-bit number, and
we guarantee that bdev_zone_size() returns a power-of-two number.
Fixes: 792b84b74b54 ("f2fs: support multiple devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/segment.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index eaa0b40..d5141a0 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -693,7 +693,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
}
sector = SECTOR_FROM_BLOCK(blkstart);
- if (sector % bdev_zone_size(bdev) || nr_sects != bdev_zone_size(bdev)) {
+ if (sector & (bdev_zone_size(bdev) - 1) ||
+ nr_sects != bdev_zone_size(bdev)) {
f2fs_msg(sbi->sb, KERN_INFO,
"(%d) %s: Unaligned discard attempted (block %x + %x)",
devi, sbi->s_ndevs ? FDEV(devi).path: "",
--
2.8.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: fix 32-bit build
2016-11-23 18:42 ` Jaegeuk Kim
@ 2016-11-23 21:05 ` Arnd Bergmann
2016-11-23 21:18 ` Jaegeuk Kim
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2016-11-23 21:05 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: Damien Le Moal, linux-kernel, linux-f2fs-devel
On Wednesday, November 23, 2016 10:42:26 AM CET Jaegeuk Kim wrote:
>
> Unfortunately, the sector number is usually a 64-bit number, and
> we guarantee that bdev_zone_size() returns a power-of-two number.
The sentence no longer makes sense. Maybe
Fortunately, bdev_zone_size() is guaranteed to return a power-of-two
number, so we can replace the % operator with a cheaper bit mask.
> @@ -693,7 +693,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> }
> sector = SECTOR_FROM_BLOCK(blkstart);
>
> - if (sector % bdev_zone_size(bdev) || nr_sects != bdev_zone_size(bdev)) {
> + if (sector & (bdev_zone_size(bdev) - 1) ||
>
looks good, thanks for following up!
Arnd
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: fix 32-bit build
2016-11-23 21:05 ` Arnd Bergmann
@ 2016-11-23 21:18 ` Jaegeuk Kim
0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2016-11-23 21:18 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Chao Yu, Yunlei He, Damien Le Moal, Fan Li, linux-f2fs-devel,
linux-kernel
On Wed, Nov 23, 2016 at 10:05:41PM +0100, Arnd Bergmann wrote:
> On Wednesday, November 23, 2016 10:42:26 AM CET Jaegeuk Kim wrote:
> >
> > Unfortunately, the sector number is usually a 64-bit number, and
> > we guarantee that bdev_zone_size() returns a power-of-two number.
>
> The sentence no longer makes sense. Maybe
>
> Fortunately, bdev_zone_size() is guaranteed to return a power-of-two
> number, so we can replace the % operator with a cheaper bit mask.
Got it.
Added it with modifed version.
Thanks,
>
> > @@ -693,7 +693,8 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
> > }
> > sector = SECTOR_FROM_BLOCK(blkstart);
> >
> > - if (sector % bdev_zone_size(bdev) || nr_sects != bdev_zone_size(bdev)) {
> > + if (sector & (bdev_zone_size(bdev) - 1) ||
> >
>
> looks good, thanks for following up!
>
> Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-23 21:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-22 14:20 [PATCH] f2fs: fix 32-bit build Arnd Bergmann
2016-11-22 14:27 ` Damien Le Moal
2016-11-23 18:42 ` Jaegeuk Kim
2016-11-23 21:05 ` Arnd Bergmann
2016-11-23 21:18 ` Jaegeuk Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).