mirror of
https://github.com/torvalds/linux.git
synced 2025-11-03 01:59:51 +02:00
btrfs: use PAGE_{ALIGN, ALIGNED, ALIGN_DOWN} macro
The header file linux/mm.h provides PAGE_ALIGN, PAGE_ALIGNED, PAGE_ALIGN_DOWN macros. Use these macros to make code more concise. Signed-off-by: Yushan Zhou <katrinzhou@tencent.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d31de37850
commit
ce394a7f39
6 changed files with 8 additions and 9 deletions
|
|
@ -1609,7 +1609,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
|
||||||
index_end = end >> PAGE_SHIFT;
|
index_end = end >> PAGE_SHIFT;
|
||||||
|
|
||||||
/* Don't miss unaligned end */
|
/* Don't miss unaligned end */
|
||||||
if (!IS_ALIGNED(end, PAGE_SIZE))
|
if (!PAGE_ALIGNED(end))
|
||||||
index_end++;
|
index_end++;
|
||||||
|
|
||||||
curr_sample_pos = 0;
|
curr_sample_pos = 0;
|
||||||
|
|
|
||||||
|
|
@ -999,7 +999,7 @@ static int defrag_collect_targets(struct btrfs_inode *inode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CLUSTER_SIZE (SZ_256K)
|
#define CLUSTER_SIZE (SZ_256K)
|
||||||
static_assert(IS_ALIGNED(CLUSTER_SIZE, PAGE_SIZE));
|
static_assert(PAGE_ALIGNED(CLUSTER_SIZE));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defrag one contiguous target range.
|
* Defrag one contiguous target range.
|
||||||
|
|
|
||||||
|
|
@ -10995,9 +10995,8 @@ static int btrfs_add_swap_extent(struct swap_info_struct *sis,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
max_pages = sis->max - bsi->nr_pages;
|
max_pages = sis->max - bsi->nr_pages;
|
||||||
first_ppage = ALIGN(bsi->block_start, PAGE_SIZE) >> PAGE_SHIFT;
|
first_ppage = PAGE_ALIGN(bsi->block_start) >> PAGE_SHIFT;
|
||||||
next_ppage = ALIGN_DOWN(bsi->block_start + bsi->block_len,
|
next_ppage = PAGE_ALIGN_DOWN(bsi->block_start + bsi->block_len) >> PAGE_SHIFT;
|
||||||
PAGE_SIZE) >> PAGE_SHIFT;
|
|
||||||
|
|
||||||
if (first_ppage >= next_ppage)
|
if (first_ppage >= next_ppage)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have reached page boundary */
|
/* Check if we have reached page boundary */
|
||||||
if (IS_ALIGNED(cur_in, PAGE_SIZE)) {
|
if (PAGE_ALIGNED(cur_in)) {
|
||||||
put_page(page_in);
|
put_page(page_in);
|
||||||
page_in = NULL;
|
page_in = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2825,7 +2825,7 @@ static noinline_for_stack int prealloc_file_extent_cluster(
|
||||||
*
|
*
|
||||||
* Here we have to manually invalidate the range (i_size, PAGE_END + 1).
|
* Here we have to manually invalidate the range (i_size, PAGE_END + 1).
|
||||||
*/
|
*/
|
||||||
if (!IS_ALIGNED(i_size, PAGE_SIZE)) {
|
if (!PAGE_ALIGNED(i_size)) {
|
||||||
struct address_space *mapping = inode->vfs_inode.i_mapping;
|
struct address_space *mapping = inode->vfs_inode.i_mapping;
|
||||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||||
const u32 sectorsize = fs_info->sectorsize;
|
const u32 sectorsize = fs_info->sectorsize;
|
||||||
|
|
|
||||||
|
|
@ -5633,7 +5633,7 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path,
|
||||||
* boundary in the send buffer. This means that there may be a gap
|
* boundary in the send buffer. This means that there may be a gap
|
||||||
* between the beginning of the command and the file data.
|
* between the beginning of the command and the file data.
|
||||||
*/
|
*/
|
||||||
data_offset = ALIGN(sctx->send_size, PAGE_SIZE);
|
data_offset = PAGE_ALIGN(sctx->send_size);
|
||||||
if (data_offset > sctx->send_max_size ||
|
if (data_offset > sctx->send_max_size ||
|
||||||
sctx->send_max_size - data_offset < disk_num_bytes) {
|
sctx->send_max_size - data_offset < disk_num_bytes) {
|
||||||
ret = -EOVERFLOW;
|
ret = -EOVERFLOW;
|
||||||
|
|
@ -5757,7 +5757,7 @@ static int send_extent_data(struct send_ctx *sctx, struct btrfs_path *path,
|
||||||
sent += size;
|
sent += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sctx->clean_page_cache && IS_ALIGNED(end, PAGE_SIZE)) {
|
if (sctx->clean_page_cache && PAGE_ALIGNED(end)) {
|
||||||
/*
|
/*
|
||||||
* Always operate only on ranges that are a multiple of the page
|
* Always operate only on ranges that are a multiple of the page
|
||||||
* size. This is not only to prevent zeroing parts of a page in
|
* size. This is not only to prevent zeroing parts of a page in
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue