summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-11-28 10:28:07 +0000
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:14 -0500
commit797f4277113bff142b6c64a55abaef64d7d67d5c (patch)
tree73f4b8f53e40ee6f7ceefe3d5eec47006fefa4d8 /fs/btrfs
parentaf1be4f851db4f4975f0139211a6561776ef37c0 (diff)
downloadop-kernel-dev-797f4277113bff142b6c64a55abaef64d7d67d5c.zip
op-kernel-dev-797f4277113bff142b6c64a55abaef64d7d67d5c.tar.gz
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/btrfs')
-rw-r--r--fs/btrfs/file.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d415a05..a43d0ae 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2054,12 +2054,12 @@ static long btrfs_fallocate(struct file *file, int mode,
u64 alloc_end;
u64 alloc_hint = 0;
u64 locked_end;
- u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
struct extent_map *em;
+ int blocksize = BTRFS_I(inode)->root->sectorsize;
int ret;
- alloc_start = offset & ~mask;
- alloc_end = (offset + len + mask) & ~mask;
+ alloc_start = round_down(offset, blocksize);
+ alloc_end = round_up(offset + len, blocksize);
/* Make sure we aren't being give some crap mode */
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
@@ -2140,7 +2140,7 @@ static long btrfs_fallocate(struct file *file, int mode,
}
last_byte = min(extent_map_end(em), alloc_end);
actual_end = min_t(u64, extent_map_end(em), offset + len);
- last_byte = (last_byte + mask) & ~mask;
+ last_byte = ALIGN(last_byte, blocksize);
if (em->block_start == EXTENT_MAP_HOLE ||
(cur_offset >= inode->i_size &&
OpenPOWER on IntegriCloud