All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build
@ 2021-10-05  9:34 Geert Uytterhoeven
  2021-10-05  9:41 ` Qu Wenruo
  2021-10-05 23:23 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2021-10-05  9:34 UTC (permalink / raw)
  To: Qu Wenruo, Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, Geert Uytterhoeven, noreply

On 32-bit builds (e.g. m68k):

    ERROR: modpost: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!

"cur_in - start" is 64-bit, while sectorsize is u32.

As sectorsize is always a power of two, the 64-by-32 modulo operation
can be replaced by a much cheaper bitwise AND with "sectorsize - 1".

Fixes: 0078783c7089fc83 ("btrfs: rework lzo_compress_pages() to make it subpage compatible")
Reported-by: noreply@ellerman.id.au
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
Compile-tested only.
---
 fs/btrfs/lzo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index 47003cec4046f13e..d08f9eba49dab3cd 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -211,7 +211,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 	 */
 	cur_out += LZO_LEN;
 	while (cur_in < start + len) {
-		u32 sector_off = (cur_in - start) % sectorsize;
+		u32 sector_off = (cur_in - start) & (sectorsize - 1);
 		u32 in_len;
 		size_t out_len;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build
  2021-10-05  9:34 [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build Geert Uytterhoeven
@ 2021-10-05  9:41 ` Qu Wenruo
  2021-10-05 23:23 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2021-10-05  9:41 UTC (permalink / raw)
  To: Geert Uytterhoeven, Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, noreply



On 2021/10/5 17:34, Geert Uytterhoeven wrote:
> On 32-bit builds (e.g. m68k):
> 
>      ERROR: modpost: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!
> 
> "cur_in - start" is 64-bit, while sectorsize is u32.
> 
> As sectorsize is always a power of two, the 64-by-32 modulo operation
> can be replaced by a much cheaper bitwise AND with "sectorsize - 1".
> 
> Fixes: 0078783c7089fc83 ("btrfs: rework lzo_compress_pages() to make it subpage compatible")
> Reported-by: noreply@ellerman.id.au
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Oh, thanks for catching this.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
> Compile-tested only.
> ---
>   fs/btrfs/lzo.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
> index 47003cec4046f13e..d08f9eba49dab3cd 100644
> --- a/fs/btrfs/lzo.c
> +++ b/fs/btrfs/lzo.c
> @@ -211,7 +211,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
>   	 */
>   	cur_out += LZO_LEN;
>   	while (cur_in < start + len) {
> -		u32 sector_off = (cur_in - start) % sectorsize;
> +		u32 sector_off = (cur_in - start) & (sectorsize - 1);
>   		u32 in_len;
>   		size_t out_len;
>   
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build
  2021-10-05  9:34 [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build Geert Uytterhoeven
  2021-10-05  9:41 ` Qu Wenruo
@ 2021-10-05 23:23 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-10-05 23:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Qu Wenruo, Chris Mason, Josef Bacik, David Sterba, linux-btrfs,
	linux-kernel, noreply

On Tue, Oct 05, 2021 at 11:34:06AM +0200, Geert Uytterhoeven wrote:
> On 32-bit builds (e.g. m68k):
> 
>     ERROR: modpost: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!
> 
> "cur_in - start" is 64-bit, while sectorsize is u32.
> 
> As sectorsize is always a power of two, the 64-by-32 modulo operation
> can be replaced by a much cheaper bitwise AND with "sectorsize - 1".
> 
> Fixes: 0078783c7089fc83 ("btrfs: rework lzo_compress_pages() to make it subpage compatible")
> Reported-by: noreply@ellerman.id.au
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thanks. Folded to the patch as it's still in the devel queue.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-05 23:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05  9:34 [PATCH -next] btrfs: lzo: Mask instead of divide to fix 32-bit build Geert Uytterhoeven
2021-10-05  9:41 ` Qu Wenruo
2021-10-05 23:23 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.