diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2012-11-28 05:28:07 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-12-16 20:46:14 -0500 |
commit | 797f4277113bff142b6c64a55abaef64d7d67d5c (patch) | |
tree | 73f4b8f53e40ee6f7ceefe3d5eec47006fefa4d8 /fs | |
parent | af1be4f851db4f4975f0139211a6561776ef37c0 (diff) |
Btrfs: use existing align macros in btrfs_allocate()
The kernel developers have implemented some often-used align macros, we should
use them instead of the complex code.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/file.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index d415a052ca9a..a43d0aef6ee1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -2054,12 +2054,12 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
2054 | u64 alloc_end; | 2054 | u64 alloc_end; |
2055 | u64 alloc_hint = 0; | 2055 | u64 alloc_hint = 0; |
2056 | u64 locked_end; | 2056 | u64 locked_end; |
2057 | u64 mask = BTRFS_I(inode)->root->sectorsize - 1; | ||
2058 | struct extent_map *em; | 2057 | struct extent_map *em; |
2058 | int blocksize = BTRFS_I(inode)->root->sectorsize; | ||
2059 | int ret; | 2059 | int ret; |
2060 | 2060 | ||
2061 | alloc_start = offset & ~mask; | 2061 | alloc_start = round_down(offset, blocksize); |
2062 | alloc_end = (offset + len + mask) & ~mask; | 2062 | alloc_end = round_up(offset + len, blocksize); |
2063 | 2063 | ||
2064 | /* Make sure we aren't being give some crap mode */ | 2064 | /* Make sure we aren't being give some crap mode */ |
2065 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 2065 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
@@ -2140,7 +2140,7 @@ static long btrfs_fallocate(struct file *file, int mode, | |||
2140 | } | 2140 | } |
2141 | last_byte = min(extent_map_end(em), alloc_end); | 2141 | last_byte = min(extent_map_end(em), alloc_end); |
2142 | actual_end = min_t(u64, extent_map_end(em), offset + len); | 2142 | actual_end = min_t(u64, extent_map_end(em), offset + len); |
2143 | last_byte = (last_byte + mask) & ~mask; | 2143 | last_byte = ALIGN(last_byte, blocksize); |
2144 | 2144 | ||
2145 | if (em->block_start == EXTENT_MAP_HOLE || | 2145 | if (em->block_start == EXTENT_MAP_HOLE || |
2146 | (cur_offset >= inode->i_size && | 2146 | (cur_offset >= inode->i_size && |