diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2013-02-26 12:10:22 +0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-26 20:04:13 +0400 |
commit | fda2832febb1928da0625b2c5d15559b29d7e740 (patch) | |
tree | dac83eff57b657dfc04ba72fa7bcce4b4674b810 /fs/btrfs/extent-tree.c | |
parent | 8c4ce81e911ab6c84e4f75e18d4ceb3fa555c35b (diff) | |
download | linux-fda2832febb1928da0625b2c5d15559b29d7e740.tar.xz |
btrfs: cleanup for open-coded alignment
Though most of the btrfs codes are using ALIGN macro for page alignment,
there are still some codes using open-coded alignment like the
following:
------
u64 mask = ((u64)root->stripesize - 1);
u64 ret = (val + mask) & ~mask;
------
Or even hidden one:
------
num_bytes = (end - start + blocksize) & ~(blocksize - 1);
------
Sometimes these open-coded alignment is not so easy to understand for
newbie like me.
This commit changes the open-coded alignment to the ALIGN macro for a
better readability.
Also there is a previous patch from David Sterba with similar changes,
but the patch is for 3.2 kernel and seems not merged.
http://www.spinics.net/lists/linux-btrfs/msg12747.html
Cc: David Sterba <dave@jikos.cz>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8520354f086e..5681a91ed400 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3431,7 +3431,7 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes) int ret = 0, committed = 0, alloc_chunk = 1; /* make sure bytes are sectorsize aligned */ - bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); + bytes = ALIGN(bytes, root->sectorsize); if (root == root->fs_info->tree_root || BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) { @@ -3526,7 +3526,7 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes) struct btrfs_space_info *data_sinfo; /* make sure bytes are sectorsize aligned */ - bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); + bytes = ALIGN(bytes, root->sectorsize); data_sinfo = root->fs_info->data_sinfo; spin_lock(&data_sinfo->lock); @@ -5607,10 +5607,7 @@ static u64 stripe_align(struct btrfs_root *root, struct btrfs_block_group_cache *cache, u64 val, u64 num_bytes) { - u64 mask; - u64 ret; - mask = ((u64)root->stripesize - 1); - ret = (val + mask) & ~mask; + u64 ret = ALIGN(val, root->stripesize); return ret; } |