Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp957478ybi; Fri, 21 Jun 2019 11:04:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy5ZeGJcTUo+n1JycSIrwFMGODBI3p06GjY59oHQrkBv86O0BxXIHx2GbIyxuadsucyVgCX X-Received: by 2002:a17:90a:8a8e:: with SMTP id x14mr8034547pjn.103.1561140241938; Fri, 21 Jun 2019 11:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561140241; cv=none; d=google.com; s=arc-20160816; b=q9MJ7+XbErD1x6l4ly86q5h+o3OXTTW3i0iODMtN1uiEfGR11/RLgm3o4Ex5M8DaIX MDEQXeahWcuDRb5dJrUeXXfsf3bb2YdgQgv0Jyk6L2qoP2di0papCujsOLALxbvAn0Av kpmaHp/e7dX1C0xg2vFaH5psMLDoC913QsaotpnzU25U1vjiAStP6MO+mJI1oMrouKoy mfPMOeKO58AHU5X++aMt9DT0B/JL1SdfRrr1J2cuZK3wwFTnG0VwvU22hkXr1Csms+T2 iXoCj4pzeawDdROH1Kkl6UMIbbumbBJv8N/iOdiqLtegjUUjZoePEffYco9//Pc71dJl ABYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KrN/4zvbMDNzNKRbUOzOL3VD5uHXWiiSKaTL/UiG/NY=; b=hlSH7CZ7bYXRAyq1Zasp5OSZXgFfCUOvIBmjcBrlDs2R7aKncQix0dlQYPGKyR72yd T6gs6UFKxIgfBEl2UnracDxDa4wJbWapJ3uEwq03qKScFMo2UoFwy+9zHTf9QR0YTSPw zozrjUZ++rqM2v/qq09EtF3ujzAxn1vfZP4wJQ6JD0iP2iCdM0KYldHU3a8KJgQyt4JQ /0eQhKU/GlLyD0T83xtkOaRg0dFfUw0YPb/DCLaGb/5XgJyytsbLiOPwOox5xIznqMVc 71pOo7nL0qSuJtqHWnpo4jBLp6+oIAwjpI9uzNiuZNTrNfJiNYK2lJOIg65McT2pPt/X Td+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ox4m1w+P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h32si3470379pld.402.2019.06.21.11.03.46; Fri, 21 Jun 2019 11:04:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ox4m1w+P; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726383AbfFUSCI (ORCPT + 99 others); Fri, 21 Jun 2019 14:02:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbfFUSCI (ORCPT ); Fri, 21 Jun 2019 14:02:08 -0400 Received: from localhost (unknown [104.132.1.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1BA22070B; Fri, 21 Jun 2019 18:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561140126; bh=g79cNV6mf95ZmNPYnM1FB01DX5LPgZqiGUD7akF6G6E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ox4m1w+PS7vUV8r9TxOITAt1Szi7NPEgyksJHkf2lyp999RYb4j+gqL+htr6gvvTW QazJsF8LbXmELHinQXJOlt0BjQSv+FOidYA2eimQ2cMJWFn7R/Qa6tTaSNx+f4o0tA wDn4Za7mziYVpYox27i7qI7VGqf3WHjWxwylpif8= Date: Fri, 21 Jun 2019 11:02:06 -0700 From: Jaegeuk Kim To: Geert Uytterhoeven Cc: Chao Yu , Qiuyang Sun , linux-f2fs-devel@lists.sourceforge.net, Linux-Next , Linux Kernel Mailing List Subject: Re: [PATCH -next] f2fs: Use div_u64*() for 64-bit divisions Message-ID: <20190621180206.GD79502@jaegeuk-macbookpro.roam.corp.google.com> References: <20190620143800.20640-1-geert@linux-m68k.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/21, Geert Uytterhoeven wrote: > Hi Chao, > > On Fri, Jun 21, 2019 at 11:54 AM Chao Yu wrote: > > Since the original patch hasn't been merged to upstream, I think we can merge > > this into original patch, how do you think? > > Thanks, that's fine for me. Merged the fix. Thank you so much. > > > On 2019/6/20 22:38, Geert Uytterhoeven wrote: > > > 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 + > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds