Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2007361ybi; Thu, 20 Jun 2019 07:38:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/0y5QDJxEB7Ko294zgWE69CxUSriRRWHYCrJDelt5kORbJeDlF/TXgm59ljoeQw3mnB33 X-Received: by 2002:a17:90a:3086:: with SMTP id h6mr24729pjb.14.1561041526886; Thu, 20 Jun 2019 07:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561041526; cv=none; d=google.com; s=arc-20160816; b=xnTuzgv2jq9c23U1ydJFxISKkdrbA192XlVDdJcLKV4DeMeQXFTceUN2qjcIURqCkT N4EH5mltTnRTSHjJPfahnzkOdTZHc2WHpzk2EomuQP46xLU9KHGmnPiMiUFMiZiXU4AB LWJRGQbZjBhQ0XnpPx6/wjgoaC6zxuXlVH3Z7ul0olnPWPuA7XT2ugQjpWg4gT3u9Kjf 7GrmisQFmEk5SdQbV5axzq1Cr8rc8LAYbb5ZTLF1gnckLHh1XtHSNAnWTAyDnRzc+99l NPjTIqxL7CtGZqjzufHI5OfK3OmcejwrEPw9qyYSw/ePaGHXjr97oFXuEC+ji+QmpgVd EE0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=SUanXXN536RfU0n2xDVJxWjxXdMJsAYrWC2IuBtDTGY=; b=m9To782ZQasmDMTncq89Ld2IGOd477GYxY3SUEfevXe3ATHeX5MjF2y4bPvZHYTngf zS2pFM5gDAgJhoPS7OSn/u1m7qbByEIzxCZPKn7R4HzfrrN8ZqC8e/TmlF69khHbj208 pll6FFEqy01DLXFfO7hZ31qiMavDuK2uJ2/36KnBNIWyg7X2LVStOKQwrwYmQfudG5gS 6u5gRJEFBp3L8xHQM/Y5CF65DQ6GYINOi4WdxZ9xaY+0HewZRbizRpVEpu/ZqfybTnnk eqpnu8Zx7C+rkICvnkLx4KSIYqriKKeyByn3JUUBjyMdi41JOmHTGblTN5pU0srWFZBn 9WDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si6018026pgi.341.2019.06.20.07.38.30; Thu, 20 Jun 2019 07:38:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbfFTOiG (ORCPT + 99 others); Thu, 20 Jun 2019 10:38:06 -0400 Received: from xavier.telenet-ops.be ([195.130.132.52]:41808 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbfFTOiG (ORCPT ); Thu, 20 Jun 2019 10:38:06 -0400 Received: from ramsan ([84.194.111.163]) by xavier.telenet-ops.be with bizsmtp id T2e3200063XaVaC012e3bi; Thu, 20 Jun 2019 16:38:03 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1hdyCR-0000xm-0o; Thu, 20 Jun 2019 16:38:03 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1hdyCQ-0005Ng-VN; Thu, 20 Jun 2019 16:38:02 +0200 From: Geert Uytterhoeven To: Qiuyang Sun , Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-next@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH -next] f2fs: Use div_u64*() for 64-bit divisions Date: Thu, 20 Jun 2019 16:38:00 +0200 Message-Id: <20190620143800.20640-1-geert@linux-m68k.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 32-bit (e.g. m68k): fs/f2fs/gc.o: In function `f2fs_resize_fs': gc.c:(.text+0x3056): undefined reference to `__umoddi3' gc.c:(.text+0x30c4): undefined reference to `__udivdi3' Fix this by using div_u64_rem() and div_u64() for 64-by-32 modulo resp. division operations. Reported-by: noreply@ellerman.id.au Fixes: d2ae7494d043bfaf ("f2fs: ioctl for removing a range from F2FS") Signed-off-by: Geert Uytterhoeven --- This assumes BLKS_PER_SEC(sbi) is 32-bit. #define BLKS_PER_SEC(sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg) Notes: 1. f2fs_sb_info.segs_per_sec and f2fs_sb_info.blocks_per_seg are both unsigned int, 2. The multiplication is done in 32-bit arithmetic, hence the result is of type unsigned int. 3. Is it guaranteed that the result will always fit in 32-bit, or can this overflow? 4. fs/f2fs/debug.c:update_sit_info() assigns BLKS_PER_SEC(sbi) to unsigned long long blks_per_sec, anticipating a 64-bit value. --- fs/f2fs/gc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 5b1076505ade9f84..c65f87f11de029f4 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1438,13 +1438,15 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count) unsigned int secs; int gc_mode, gc_type; int err = 0; + __u32 rem; old_block_count = le64_to_cpu(F2FS_RAW_SUPER(sbi)->block_count); if (block_count > old_block_count) return -EINVAL; /* new fs size should align to section size */ - if (block_count % BLKS_PER_SEC(sbi)) + div_u64_rem(block_count, BLKS_PER_SEC(sbi), &rem); + if (rem) return -EINVAL; if (block_count == old_block_count) @@ -1463,7 +1465,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count) freeze_bdev(sbi->sb->s_bdev); shrunk_blocks = old_block_count - block_count; - secs = shrunk_blocks / BLKS_PER_SEC(sbi); + secs = div_u64(shrunk_blocks, BLKS_PER_SEC(sbi)); spin_lock(&sbi->stat_lock); if (shrunk_blocks + valid_user_blocks(sbi) + sbi->current_reserved_blocks + sbi->unusable_block_count + -- 2.17.1