Skip to contentSkip to conversation

brtfs: use PAGE_ALIGNED macro

PATCH Superseded [email protected] 2 participants 5 messages Dec 28, 2022 – Jan 3, 2023 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brtfs: use PAGE_ALIGNED macro

From: Yushan Zhou <[email protected]>

The header file linux/mm.h provides the PAGE_ALIGNED macro to test whether an address is aligned to PAGE_SIZE. Use it instead of IS_ALIGNED.

---
 fs/btrfs/lzo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/lzo.c +1 -1
index d5e78cbc8fbc..71f6d8302d50 100644
@@ -280,7 +280,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 		}
 
 		/* Check if we have reached page boundary */
-		if (IS_ALIGNED(cur_in, PAGE_SIZE)) {
+		if (PAGE_ALIGNED(cur_in)) {
 			put_page(page_in);
 			page_in = NULL;
 		}
Signature · 1 line
2.27.0
#1 lore raw
Quoted 5 lines · On Wed, Dec 28, 2022 at 12:04:47PM +0800, [email protected] wrote:

From: Yushan Zhou <[email protected]>

The header file linux/mm.h provides the PAGE_ALIGNED macro to test whether an address is aligned to PAGE_SIZE. Use it instead of IS_ALIGNED.

There are about 8 such conversions in fs/btrfs/, please fix them all. Thanks.

author
#2 lore raw

I will send a new version soon. But I only find 5 such conversions in fs/btrfs. Could you please check it?

Best,
Katrin

Quoted 10 lines · David Sterba
Quoted 5 lines · On Wed, Dec 28, 2022 at 12:04:47PM +0800, [email protected] wrote:

From: Yushan Zhou <[email protected]>

The header file linux/mm.h provides the PAGE_ALIGNED macro to test whether an address is aligned to PAGE_SIZE. Use it instead of IS_ALIGNED.

There are about 8 such conversions in fs/btrfs/, please fix them all. Thanks.

#3 lore raw

PATCH v2 1/1 brtfs: use PAGE_ALIGNED macro

In reply to David Sterba

From: Yushan Zhou <[email protected]>

The header file linux/mm.h provides the PAGE_ALIGNED macro to test whether an address is aligned to PAGE_SIZE. Use it instead of IS_ALIGNED.

---
 fs/btrfs/compression.c | 2 +-
 fs/btrfs/defrag.c      | 2 +-
 fs/btrfs/lzo.c         | 2 +-
 fs/btrfs/relocation.c  | 2 +-
 fs/btrfs/send.c        | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/compression.c +1 -1
index 5122ca79f7ea..4a5aeb8dd479 100644
@@ -1609,7 +1609,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
 	index_end = end >> PAGE_SHIFT;
 
 	/* Don't miss unaligned end */
-	if (!IS_ALIGNED(end, PAGE_SIZE))
+	if (!PAGE_ALIGNED(end))
 		index_end++;
 
 	curr_sample_pos = 0;
fs/btrfs/defrag.c +1 -1
index 0a3c261b69c9..130de66839c1 100644
@@ -997,7 +997,7 @@ static int defrag_collect_targets(struct btrfs_inode *inode,
 }
 
 #define CLUSTER_SIZE	(SZ_256K)
-static_assert(IS_ALIGNED(CLUSTER_SIZE, PAGE_SIZE));
+static_assert(PAGE_ALIGNED(CLUSTER_SIZE));
 
 /*
  * Defrag one contiguous target range.
fs/btrfs/lzo.c +1 -1
index d5e78cbc8fbc..71f6d8302d50 100644
@@ -280,7 +280,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 		}
 
 		/* Check if we have reached page boundary */
-		if (IS_ALIGNED(cur_in, PAGE_SIZE)) {
+		if (PAGE_ALIGNED(cur_in)) {
 			put_page(page_in);
 			page_in = NULL;
 		}
fs/btrfs/relocation.c +1 -1
index 31ec4a7658ce..ef13a9d4e370 100644
@@ -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).
 	 */
-	if (!IS_ALIGNED(i_size, PAGE_SIZE)) {
+	if (!PAGE_ALIGNED(i_size)) {
 		struct address_space *mapping = inode->vfs_inode.i_mapping;
 		struct btrfs_fs_info *fs_info = inode->root->fs_info;
 		const u32 sectorsize = fs_info->sectorsize;
fs/btrfs/send.c +1 -1
index e65e6b6600a7..bab0ba3e6542 100644
@@ -5759,7 +5759,7 @@ static int send_extent_data(struct send_ctx *sctx, struct btrfs_path *path,
 		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
 		 * size. This is not only to prevent zeroing parts of a page in
Signature · 1 line
2.27.0
author
#4 lore raw
In reply to David Sterba

The macro ALIGN(addr, PAGE_SIZE) can be replaced by PAGE_ALIGN(addr), and the same as PAGE_ALIGNED_DOWN.
Do you mean that? I will send the third version and modify the commit message a bit.

Best,
Katrin

Quoted 10 lines · David Sterba
Quoted 5 lines · On Wed, Dec 28, 2022 at 12:04:47PM +0800, [email protected] wrote:

From: Yushan Zhou <[email protected]>

The header file linux/mm.h provides the PAGE_ALIGNED macro to test whether an address is aligned to PAGE_SIZE. Use it instead of IS_ALIGNED.

There are about 8 such conversions in fs/btrfs/, please fix them all. Thanks.