btrfs: use PAGE_ALIGNED instead of open-coding it
authorJohannes Thumshirn <jthumshirn@suse.de>
Wed, 5 Dec 2018 14:23:04 +0000 (15:23 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:45 +0000 (14:51 +0100)
When using a 'var & (PAGE_SIZE - 1)' construct one is checking for a page
alignment and thus should use the PAGE_ALIGNED() macro instead of
open-coding it.

Convert all open-coded occurrences of PAGE_ALIGNED().

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/check-integrity.c
fs/btrfs/compression.c
fs/btrfs/inode.c

index d319c3020c09fdfffca1ff598e0a129fc46631bb..84e9729badaa72f43b8ac9939ceeae6c17deb974 100644 (file)
@@ -1601,7 +1601,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
        BUG_ON(block_ctx->datav);
        BUG_ON(block_ctx->pagev);
        BUG_ON(block_ctx->mem_to_free);
-       if (block_ctx->dev_bytenr & ((u64)PAGE_SIZE - 1)) {
+       if (!PAGE_ALIGNED(block_ctx->dev_bytenr)) {
                pr_info("btrfsic: read_block() with unaligned bytenr %llu\n",
                       block_ctx->dev_bytenr);
                return -1;
@@ -1778,7 +1778,7 @@ again:
                                return;
                        }
                        is_metadata = 1;
-                       BUG_ON(BTRFS_SUPER_INFO_SIZE & (PAGE_SIZE - 1));
+                       BUG_ON(!PAGE_ALIGNED(BTRFS_SUPER_INFO_SIZE));
                        processed_len = BTRFS_SUPER_INFO_SIZE;
                        if (state->print_mask &
                            BTRFSIC_PRINT_MASK_TREE_BEFORE_SB_WRITE) {
@@ -2892,12 +2892,12 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
        struct list_head *dev_head = &fs_devices->devices;
        struct btrfs_device *device;
 
-       if (fs_info->nodesize & ((u64)PAGE_SIZE - 1)) {
+       if (!PAGE_ALIGNED(fs_info->nodesize)) {
                pr_info("btrfsic: cannot handle nodesize %d not being a multiple of PAGE_SIZE %ld!\n",
                       fs_info->nodesize, PAGE_SIZE);
                return -1;
        }
-       if (fs_info->sectorsize & ((u64)PAGE_SIZE - 1)) {
+       if (!PAGE_ALIGNED(fs_info->sectorsize)) {
                pr_info("btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_SIZE %ld!\n",
                       fs_info->sectorsize, PAGE_SIZE);
                return -1;
index 2ab5591449f295e1393062b8a85c1089dbe41a5d..d5381f39a9e88dc06d4a932214d1585ac1873bf6 100644 (file)
@@ -301,7 +301,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode *inode, u64 start,
        blk_status_t ret;
        int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
 
-       WARN_ON(start & ((u64)PAGE_SIZE - 1));
+       WARN_ON(!PAGE_ALIGNED(start));
        cb = kmalloc(compressed_bio_size(fs_info, compressed_len), GFP_NOFS);
        if (!cb)
                return BLK_STS_RESOURCE;
index 2d8aacf072c00bc6248fe7f3a229d85b3cc028c6..3c71fcd402d004315737fb07aaa8afc019c6af0d 100644 (file)
@@ -2039,7 +2039,7 @@ int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end,
                              unsigned int extra_bits,
                              struct extent_state **cached_state, int dedupe)
 {
-       WARN_ON((end & (PAGE_SIZE - 1)) == 0);
+       WARN_ON(PAGE_ALIGNED(end));
        return set_extent_delalloc(&BTRFS_I(inode)->io_tree, start, end,
                                   extra_bits, cached_state);
 }