brtfs: use PAGE_ALIGNED macro

Message ID 20221228040447.3566246-1-zys.zljxml@gmail.com
State New
Headers
Series brtfs: use PAGE_ALIGNED macro |

Commit Message

Katrin Jo Dec. 28, 2022, 4:04 a.m. UTC
  From: Yushan Zhou <katrinzhou@tencent.com>

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.

Signed-off-by: Yushan Zhou <katrinzhou@tencent.com>
---
 fs/btrfs/lzo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

David Sterba Jan. 2, 2023, 3:03 p.m. UTC | #1
On Wed, Dec 28, 2022 at 12:04:47PM +0800, zys.zljxml@gmail.com wrote:
> From: Yushan Zhou <katrinzhou@tencent.com>
> 
> 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.
  
Katrin Jo Jan. 3, 2023, 2:42 a.m. UTC | #2
I will send a new version soon. But I only find 5 such conversions in
fs/btrfs. Could you please check it?

Best,
Katrin

On Mon, Jan 2, 2023 at 11:09 PM David Sterba <dsterba@suse.cz> wrote:
>
> On Wed, Dec 28, 2022 at 12:04:47PM +0800, zys.zljxml@gmail.com wrote:
> > From: Yushan Zhou <katrinzhou@tencent.com>
> >
> > 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.
  
Katrin Jo Jan. 3, 2023, 2:56 a.m. UTC | #3
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

On Mon, Jan 2, 2023 at 11:09 PM David Sterba <dsterba@suse.cz> wrote:
>
> On Wed, Dec 28, 2022 at 12:04:47PM +0800, zys.zljxml@gmail.com wrote:
> > From: Yushan Zhou <katrinzhou@tencent.com>
> >
> > 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.
  

Patch

diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index d5e78cbc8fbc..71f6d8302d50 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -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;
 		}