diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2013-02-26 03:10:22 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-26 11:04:13 -0500 |
commit | fda2832febb1928da0625b2c5d15559b29d7e740 (patch) | |
tree | dac83eff57b657dfc04ba72fa7bcce4b4674b810 /fs/btrfs/extent-tree.c | |
parent | 8c4ce81e911ab6c84e4f75e18d4ceb3fa555c35b (diff) |
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) | |||
3431 | int ret = 0, committed = 0, alloc_chunk = 1; | 3431 | int ret = 0, committed = 0, alloc_chunk = 1; |
3432 | 3432 | ||
3433 | /* make sure bytes are sectorsize aligned */ | 3433 | /* make sure bytes are sectorsize aligned */ |
3434 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); | 3434 | bytes = ALIGN(bytes, root->sectorsize); |
3435 | 3435 | ||
3436 | if (root == root->fs_info->tree_root || | 3436 | if (root == root->fs_info->tree_root || |
3437 | BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) { | 3437 | BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) { |
@@ -3526,7 +3526,7 @@ void btrfs_free_reserved_data_space(struct inode *inode, u64 bytes) | |||
3526 | struct btrfs_space_info *data_sinfo; | 3526 | struct btrfs_space_info *data_sinfo; |
3527 | 3527 | ||
3528 | /* make sure bytes are sectorsize aligned */ | 3528 | /* make sure bytes are sectorsize aligned */ |
3529 | bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); | 3529 | bytes = ALIGN(bytes, root->sectorsize); |
3530 | 3530 | ||
3531 | data_sinfo = root->fs_info->data_sinfo; | 3531 | data_sinfo = root->fs_info->data_sinfo; |
3532 | spin_lock(&data_sinfo->lock); | 3532 | spin_lock(&data_sinfo->lock); |
@@ -5607,10 +5607,7 @@ static u64 stripe_align(struct btrfs_root *root, | |||
5607 | struct btrfs_block_group_cache *cache, | 5607 | struct btrfs_block_group_cache *cache, |
5608 | u64 val, u64 num_bytes) | 5608 | u64 val, u64 num_bytes) |
5609 | { | 5609 | { |
5610 | u64 mask; | 5610 | u64 ret = ALIGN(val, root->stripesize); |
5611 | u64 ret; | ||
5612 | mask = ((u64)root->stripesize - 1); | ||
5613 | ret = (val + mask) & ~mask; | ||
5614 | return ret; | 5611 | return ret; |
5615 | } | 5612 | } |
5616 | 5613 | ||