aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/compression.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-06-04 19:59:57 -0400
committerChris Mason <clm@fb.com>2014-09-17 16:37:17 -0400
commited6078f70335f158ca79790a0d0708ce558a6e9a (patch)
tree636322e2a1e25f7db9f5982204a8fa4bc1bf9cbf /fs/btrfs/compression.c
parent4e54b17ad67a2d0d59bda6edcf725dc5b281c253 (diff)
btrfs: use DIV_ROUND_UP instead of open-coded variants
The form (value + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT is equivalent to (value + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE The rest is a simple subsitution, no difference in the generated assembly code. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r--fs/btrfs/compression.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 1daea0b47187..eeee13842cd0 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -91,8 +91,7 @@ static inline int compressed_bio_size(struct btrfs_root *root,
91 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy); 91 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
92 92
93 return sizeof(struct compressed_bio) + 93 return sizeof(struct compressed_bio) +
94 ((disk_size + root->sectorsize - 1) / root->sectorsize) * 94 (DIV_ROUND_UP(disk_size, root->sectorsize)) * csum_size;
95 csum_size;
96} 95}
97 96
98static struct bio *compressed_bio_alloc(struct block_device *bdev, 97static struct bio *compressed_bio_alloc(struct block_device *bdev,
@@ -615,8 +614,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
615 cb->compress_type = extent_compress_type(bio_flags); 614 cb->compress_type = extent_compress_type(bio_flags);
616 cb->orig_bio = bio; 615 cb->orig_bio = bio;
617 616
618 nr_pages = (compressed_len + PAGE_CACHE_SIZE - 1) / 617 nr_pages = DIV_ROUND_UP(compressed_len, PAGE_CACHE_SIZE);
619 PAGE_CACHE_SIZE;
620 cb->compressed_pages = kzalloc(sizeof(struct page *) * nr_pages, 618 cb->compressed_pages = kzalloc(sizeof(struct page *) * nr_pages,
621 GFP_NOFS); 619 GFP_NOFS);
622 if (!cb->compressed_pages) 620 if (!cb->compressed_pages)
@@ -686,8 +684,8 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
686 comp_bio, sums); 684 comp_bio, sums);
687 BUG_ON(ret); /* -ENOMEM */ 685 BUG_ON(ret); /* -ENOMEM */
688 } 686 }
689 sums += (comp_bio->bi_iter.bi_size + 687 sums += DIV_ROUND_UP(comp_bio->bi_iter.bi_size,
690 root->sectorsize - 1) / root->sectorsize; 688 root->sectorsize);
691 689
692 ret = btrfs_map_bio(root, READ, comp_bio, 690 ret = btrfs_map_bio(root, READ, comp_bio,
693 mirror_num, 0); 691 mirror_num, 0);