Btrfs: 32 bit compile fixes for the resizer and enospc checks

Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 6137f06..54f2b1d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2501,6 +2501,7 @@
 	u64 nr = 0;
 	u64 cur_byte;
 	u64 old_size;
+	unsigned long rem;
 	struct btrfs_block_group_cache *cache;
 	struct btrfs_block_group_item *item;
 	struct btrfs_fs_info *info = root->fs_info;
@@ -2538,7 +2539,8 @@
 				      struct btrfs_block_group_item);
 
 		btrfs_set_disk_block_group_used(leaf, item, 0);
-		if (nr % 3) {
+		div_long_long_rem(nr, 3, &rem);
+		if (rem) {
 			btrfs_set_disk_block_group_flags(leaf, item,
 						 BTRFS_BLOCK_GROUP_DATA);
 		} else {
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b62f35e..8a2001b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -81,9 +81,11 @@
 	int ret = 0;
 
 	if (for_del)
-		thresh = (total * 90) / 100;
+		thresh = total * 90;
 	else
-		thresh = (total * 85) / 100;
+		thresh = total * 85;
+
+	do_div(thresh, 100);
 
 	spin_lock(&root->fs_info->delalloc_lock);
 	if (used + root->fs_info->delalloc_bytes + num_required > thresh)
@@ -2475,7 +2477,9 @@
 		ret = -EFBIG;
 		goto out_unlock;
 	}
-	new_size = (new_size / root->sectorsize) * root->sectorsize;
+
+	do_div(new_size, root->sectorsize);
+	new_size *= root->sectorsize;
 
 printk("new size is %Lu\n", new_size);
 	if (new_size > old_size) {