From patchwork Sat Aug 20 02:17:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liubo X-Patchwork-Id: 1082212 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7K2J46v019039 for ; Sat, 20 Aug 2011 02:19:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753820Ab1HTCS0 (ORCPT ); Fri, 19 Aug 2011 22:18:26 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:52975 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751462Ab1HTCS0 (ORCPT ); Fri, 19 Aug 2011 22:18:26 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 97AF4170044; Sat, 20 Aug 2011 10:18:24 +0800 (CST) Received: from mailserver.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id p7K2IOxc006269; Sat, 20 Aug 2011 10:18:24 +0800 Received: from localhost.localdomain ([10.167.225.27]) by mailserver.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011082010171199-62386 ; Sat, 20 Aug 2011 10:17:11 +0800 From: Liu Bo To: Cc: , , , , , , Subject: [PATCH v2] Btrfs: use do_div to avoid compile errors on 32bit box Date: Sat, 20 Aug 2011 10:17:47 +0800 Message-Id: <1313806667-30495-1-git-send-email-liubo2009@cn.fujitsu.com> X-Mailer: git-send-email 1.6.5.2 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-20 10:17:11, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-08-20 10:17:12, Serialize complete at 2011-08-20 10:17:12 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 20 Aug 2011 02:19:04 +0000 (UTC) When doing div operation of u64 type, we need to be careful and use do_div to avoid compile ERROR on 32bit box: "ERROR: "__udivdi3" [fs/btrfs/btrfs.ko] undefined! make[1]: *** [__modpost] Error 1 v1->v2: - fix stupid do_div() with type "signed integer". Signed-off-by: Liu Bo --- fs/btrfs/extent-tree.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 80d6148..e43e4f1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -6735,9 +6735,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; struct btrfs_device *device; u64 min_free; + u32 dev_min = 1; + u32 dev_nr = 0; + u32 dup = 2; int index; - int dev_nr = 0; - int dev_min = 1; int full = 0; int ret = 0; @@ -6796,14 +6797,14 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr) index = get_block_group_index(block_group); if (index == 0) { dev_min = 4; - min_free /= 2; + do_div(min_free, dup); } else if (index == 1) { dev_min = 2; } else if (index == 2) { - min_free *= 2; + min_free *= dup; } else if (index == 3) { dev_min = fs_devices->rw_devices; - min_free /= dev_min; + do_div(min_free, dev_min); } mutex_lock(&root->fs_info->chunk_mutex);