All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix missing endianess conversion in sb_write_pointer
@ 2022-11-14  9:35 Christoph Hellwig
  2022-11-14 10:15 ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-11-14  9:35 UTC (permalink / raw)
  To: clm, josef, dsterba, naohiro.aota; +Cc: linux-btrfs

generation is an on-disk __le64 value, so use le64_to_cpu to convert
it to host endian before comparing it.

Fixes: 12659251ca5d ("btrfs: implement log-structured superblock for ZONED mode")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/zoned.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 57aae7694f12c..a055b10c6c884 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -136,7 +136,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
 			super[i] = page_address(page[i]);
 		}
 
-		if (super[0]->generation > super[1]->generation)
+		if (le64_to_cpu(super[0]->generation) >
+		    le64_to_cpu(super[1]->generation))
 			sector = zones[1].start;
 		else
 			sector = zones[0].start;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix missing endianess conversion in sb_write_pointer
  2022-11-14  9:35 [PATCH] btrfs: fix missing endianess conversion in sb_write_pointer Christoph Hellwig
@ 2022-11-14 10:15 ` Qu Wenruo
  2022-11-14 12:14   ` Johannes Thumshirn
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2022-11-14 10:15 UTC (permalink / raw)
  To: Christoph Hellwig, clm, josef, dsterba, naohiro.aota; +Cc: linux-btrfs



On 2022/11/14 17:35, Christoph Hellwig wrote:
> generation is an on-disk __le64 value, so use le64_to_cpu to convert
> it to host endian before comparing it.
> 
> Fixes: 12659251ca5d ("btrfs: implement log-structured superblock for ZONED mode")
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Shouldn't we use btrfs_super_generation() helper?
Just need a type conversion to btrfs_super_block pointer.

Thanks,
Qu
> ---
>   fs/btrfs/zoned.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 57aae7694f12c..a055b10c6c884 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -136,7 +136,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
>   			super[i] = page_address(page[i]);
>   		}
>   
> -		if (super[0]->generation > super[1]->generation)
> +		if (le64_to_cpu(super[0]->generation) >
> +		    le64_to_cpu(super[1]->generation))
>   			sector = zones[1].start;
>   		else
>   			sector = zones[0].start;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: fix missing endianess conversion in sb_write_pointer
  2022-11-14 10:15 ` Qu Wenruo
@ 2022-11-14 12:14   ` Johannes Thumshirn
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2022-11-14 12:14 UTC (permalink / raw)
  To: Qu Wenruo, Christoph Hellwig, clm, josef, dsterba, Naohiro Aota
  Cc: linux-btrfs

On 14.11.22 11:17, Qu Wenruo wrote:
> 
> 
> On 2022/11/14 17:35, Christoph Hellwig wrote:
>> generation is an on-disk __le64 value, so use le64_to_cpu to convert
>> it to host endian before comparing it.
>>
>> Fixes: 12659251ca5d ("btrfs: implement log-structured superblock for ZONED mode")
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Shouldn't we use btrfs_super_generation() helper?
> Just need a type conversion to btrfs_super_block pointer.

'super' is already a btrfs_super_block pointer (or better an array of)
so btrfs_super_generation() will work without any problems here.

But agreed, this should use the helper.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-14 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14  9:35 [PATCH] btrfs: fix missing endianess conversion in sb_write_pointer Christoph Hellwig
2022-11-14 10:15 ` Qu Wenruo
2022-11-14 12:14   ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.