2022-05-27 02:24:13

by FanJun Kong

[permalink] [raw]
Subject: [PATCH] btrfs: use PAGE_ALIGNED instead of IS_ALIGNED

From: Fanjun Kong <[email protected]>

The <linux/mm.h> already provides the PAGE_ALIGNED macro. Let's
use this macro instead of IS_ALIGNED and passing PAGE_SIZE directly.

Signed-off-by: Fanjun Kong <[email protected]>
---
fs/btrfs/extent_io.c | 2 +-
fs/btrfs/inode.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8f6b544ae616..1f9f31004d60 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -6201,7 +6201,7 @@ static int check_eb_alignment(struct btrfs_fs_info *fs_info, u64 start)
return -EINVAL;
}
if (fs_info->nodesize >= PAGE_SIZE &&
- !IS_ALIGNED(start, PAGE_SIZE)) {
+ !PAGE_ALIGNED(start)) {
btrfs_err(fs_info,
"tree block is not page aligned, start %llu nodesize %u",
start, fs_info->nodesize);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 81737eff92f3..0f6f62fa03c8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -560,8 +560,8 @@ static inline int inode_need_compress(struct btrfs_inode *inode, u64 start,
* will unlock the full page.
*/
if (fs_info->sectorsize < PAGE_SIZE) {
- if (!IS_ALIGNED(start, PAGE_SIZE) ||
- !IS_ALIGNED(end + 1, PAGE_SIZE))
+ if (!PAGE_ALIGNED(start) ||
+ !PAGE_ALIGNED(end + 1))
return 0;
}

@@ -678,8 +678,8 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
* Thus we must also check against @actual_end, not just @end.
*/
if (blocksize < PAGE_SIZE) {
- if (!IS_ALIGNED(start, PAGE_SIZE) ||
- !IS_ALIGNED(round_up(actual_end, blocksize), PAGE_SIZE))
+ if (!PAGE_ALIGNED(start) ||
+ !PAGE_ALIGNED(round_up(actual_end, blocksize)))
goto cleanup_and_bail_uncompressed;
}

--
2.36.0



2022-05-27 09:13:10

by Nikolay Borisov

[permalink] [raw]
Subject: Re: [PATCH] btrfs: use PAGE_ALIGNED instead of IS_ALIGNED



On 26.05.22 г. 17:35 ч., [email protected] wrote:
> From: Fanjun Kong <[email protected]>
>
> The <linux/mm.h> already provides the PAGE_ALIGNED macro. Let's
> use this macro instead of IS_ALIGNED and passing PAGE_SIZE directly.
>
> Signed-off-by: Fanjun Kong <[email protected]>

Reviewed-by: Nikolay Borisov <[email protected]>

2022-05-28 02:53:16

by David Sterba

[permalink] [raw]
Subject: Re: [PATCH] btrfs: use PAGE_ALIGNED instead of IS_ALIGNED

On Thu, May 26, 2022 at 10:35:40PM +0800, [email protected] wrote:
> From: Fanjun Kong <[email protected]>
>
> The <linux/mm.h> already provides the PAGE_ALIGNED macro. Let's
> use this macro instead of IS_ALIGNED and passing PAGE_SIZE directly.
>
> Signed-off-by: Fanjun Kong <[email protected]>

Added to misc-next, thanks.

2022-05-28 20:46:16

by Muchun Song

[permalink] [raw]
Subject: Re: [PATCH] btrfs: use PAGE_ALIGNED instead of IS_ALIGNED

On Thu, May 26, 2022 at 10:36 PM <[email protected]> wrote:
>
> From: Fanjun Kong <[email protected]>
>
> The <linux/mm.h> already provides the PAGE_ALIGNED macro. Let's
> use this macro instead of IS_ALIGNED and passing PAGE_SIZE directly.
>
> Signed-off-by: Fanjun Kong <[email protected]>

Reviewed-by: Muchun Song <[email protected]>