All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
@ 2021-05-11  4:25 Su Yue
  2021-05-12 14:01 ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Su Yue @ 2021-05-11  4:25 UTC (permalink / raw)
  To: linux-btrfs; +Cc: l

Commit 8ef9313cf298 ("btrfs-progs: zoned: implement log-structured
superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to device.
The before num of bytes to be written is sectorsize.
It causes mkfs.btrfs failed on my 16k pagesize kvm:

  $ /usr/bin/mkfs.btrfs -s 16k -f -mraid0 /dev/vdb2 /dev/vdb3
  btrfs-progs v5.12
  See http://btrfs.wiki.kernel.org for more information.

  ERROR: superblock magic doesn't match
  ERROR: superblock magic doesn't match
  common/device-scan.c:195: btrfs_add_to_fsid: BUG_ON `ret != sectorsize`
  triggered, value 1
  /usr/bin/mkfs.btrfs(btrfs_add_to_fsid+0x274)[0xaaab4fe8a5fc]
  /usr/bin/mkfs.btrfs(main+0x1188)[0xaaab4fe4dc8c]
  /usr/lib/libc.so.6(__libc_start_main+0xe8)[0xffff7223c538]
  /usr/bin/mkfs.btrfs(+0xc558)[0xaaab4fe4c558]

  [1]    225842 abort (core dumped)  /usr/bin/mkfs.btrfs -s 16k -f -mraid0
  /dev/vdb2 /dev/vdb3

btrfs_add_to_fsid() now always calls sbwrite() to write
BTRFS_SUPER_INFO_SIZE bytes to device, so change condition of
the BUG_ON().
Also add comments for sbread() and sbwrite().

Signed-off-by: Su Yue <l@damenly.su>
---
 common/device-scan.c  |  4 ++--
 kernel-shared/zoned.h | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/common/device-scan.c b/common/device-scan.c
index 07cda0c9..6a3bd098 100644
--- a/common/device-scan.c
+++ b/common/device-scan.c
@@ -192,8 +192,8 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
 	memcpy(&dev_item->uuid, device->uuid, BTRFS_UUID_SIZE);
 
 	ret = sbwrite(fd, buf, BTRFS_SUPER_INFO_OFFSET);
-	BUG_ON(ret != sectorsize);
-
+	/* ensure super block was written to the device */
+	BUG_ON(ret != BTRFS_SUPER_INFO_SIZE);
 	free(buf);
 	list_add(&device->dev_list, &fs_info->fs_devices->devices);
 	device->fs_devices = fs_info->fs_devices;
diff --git a/kernel-shared/zoned.h b/kernel-shared/zoned.h
index a246e161..47129f92 100644
--- a/kernel-shared/zoned.h
+++ b/kernel-shared/zoned.h
@@ -51,11 +51,29 @@ int btrfs_check_zoned_mode(struct btrfs_fs_info *fs_info);
 #ifdef BTRFS_ZONED
 size_t btrfs_sb_io(int fd, void *buf, off_t offset, int rw);
 
+/*
+ * sbread - read BTRFS_SUPER_INFO_SIZE bytes from fd to buf
+ *
+ * @fd		fd of the device to be read from
+ * @buf:	buffer contains a super block
+ * @offset:	offset of the superblock
+ *
+ * Return count of bytes successfully read.
+ */
 static inline size_t sbread(int fd, void *buf, off_t offset)
 {
 	return btrfs_sb_io(fd, buf, offset, READ);
 }
 
+/*
+ * sbwrite - write BTRFS_SUPER_INFO_SIZE bytes from buf to fd
+ *
+ * @fd		fd of the device to be written to
+ * @buf:	buffer contains a super block
+ * @offset:	offset of the superblock
+ *
+ * Return count of bytes successfully written.
+ */
 static inline size_t sbwrite(int fd, void *buf, off_t offset)
 {
 	return btrfs_sb_io(fd, buf, offset, WRITE);
-- 
2.31.1


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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-11  4:25 [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock Su Yue
@ 2021-05-12 14:01 ` David Sterba
  2021-05-13  0:37   ` Su Yue
  0 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2021-05-12 14:01 UTC (permalink / raw)
  To: Su Yue; +Cc: linux-btrfs

On Tue, May 11, 2021 at 12:25:01PM +0800, Su Yue wrote:
> Commit 8ef9313cf298 ("btrfs-progs: zoned: implement log-structured
> superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to device.
> The before num of bytes to be written is sectorsize.
> It causes mkfs.btrfs failed on my 16k pagesize kvm:

What architecture is that?

> 
>   $ /usr/bin/mkfs.btrfs -s 16k -f -mraid0 /dev/vdb2 /dev/vdb3
>   btrfs-progs v5.12
>   See http://btrfs.wiki.kernel.org for more information.
> 
>   ERROR: superblock magic doesn't match
>   ERROR: superblock magic doesn't match
>   common/device-scan.c:195: btrfs_add_to_fsid: BUG_ON `ret != sectorsize`
>   triggered, value 1
>   /usr/bin/mkfs.btrfs(btrfs_add_to_fsid+0x274)[0xaaab4fe8a5fc]
>   /usr/bin/mkfs.btrfs(main+0x1188)[0xaaab4fe4dc8c]
>   /usr/lib/libc.so.6(__libc_start_main+0xe8)[0xffff7223c538]
>   /usr/bin/mkfs.btrfs(+0xc558)[0xaaab4fe4c558]
> 
>   [1]    225842 abort (core dumped)  /usr/bin/mkfs.btrfs -s 16k -f -mraid0
>   /dev/vdb2 /dev/vdb3
> 
> btrfs_add_to_fsid() now always calls sbwrite() to write
> BTRFS_SUPER_INFO_SIZE bytes to device, so change condition of
> the BUG_ON().
> Also add comments for sbread() and sbwrite().
> 
> Signed-off-by: Su Yue <l@damenly.su>

Added to devel, thanks.

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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-12 14:01 ` David Sterba
@ 2021-05-13  0:37   ` Su Yue
  2021-05-14 11:22     ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Su Yue @ 2021-05-13  0:37 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs


On Wed 12 May 2021 at 22:01, David Sterba <dsterba@suse.cz> wrote:

> On Tue, May 11, 2021 at 12:25:01PM +0800, Su Yue wrote:
>> Commit 8ef9313cf298 ("btrfs-progs: zoned: implement 
>> log-structured
>> superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to 
>> device.
>> The before num of bytes to be written is sectorsize.
>> It causes mkfs.btrfs failed on my 16k pagesize kvm:
>
> What architecture is that?
>
The host chip is Apple m1 so it's arm64 but only supporting 16k 
and 4k
pagesize. Since btrfs subpage work cares 64k pagesize for now, I 
usually
run xfstests with 16k pagesize and 16k sectorsize. So far, so 
good.

--
Su

>>
>>   $ /usr/bin/mkfs.btrfs -s 16k -f -mraid0 /dev/vdb2 /dev/vdb3
>>   btrfs-progs v5.12
>>   See http://btrfs.wiki.kernel.org for more information.
>>
>>   ERROR: superblock magic doesn't match
>>   ERROR: superblock magic doesn't match
>>   common/device-scan.c:195: btrfs_add_to_fsid: BUG_ON `ret != 
>>   sectorsize`
>>   triggered, value 1
>>   /usr/bin/mkfs.btrfs(btrfs_add_to_fsid+0x274)[0xaaab4fe8a5fc]
>>   /usr/bin/mkfs.btrfs(main+0x1188)[0xaaab4fe4dc8c]
>>   /usr/lib/libc.so.6(__libc_start_main+0xe8)[0xffff7223c538]
>>   /usr/bin/mkfs.btrfs(+0xc558)[0xaaab4fe4c558]
>>
>>   [1]    225842 abort (core dumped)  /usr/bin/mkfs.btrfs -s 16k 
>>   -f -mraid0
>>   /dev/vdb2 /dev/vdb3
>>
>> btrfs_add_to_fsid() now always calls sbwrite() to write
>> BTRFS_SUPER_INFO_SIZE bytes to device, so change condition of
>> the BUG_ON().
>> Also add comments for sbread() and sbwrite().
>>
>> Signed-off-by: Su Yue <l@damenly.su>
>
> Added to devel, thanks.


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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-13  0:37   ` Su Yue
@ 2021-05-14 11:22     ` David Sterba
  2021-05-14 13:23       ` Su Yue
  0 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2021-05-14 11:22 UTC (permalink / raw)
  To: Su Yue; +Cc: linux-btrfs

On Thu, May 13, 2021 at 08:37:29AM +0800, Su Yue wrote:
> 
> On Wed 12 May 2021 at 22:01, David Sterba <dsterba@suse.cz> wrote:
> 
> > On Tue, May 11, 2021 at 12:25:01PM +0800, Su Yue wrote:
> >> Commit 8ef9313cf298 ("btrfs-progs: zoned: implement 
> >> log-structured
> >> superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to 
> >> device.
> >> The before num of bytes to be written is sectorsize.
> >> It causes mkfs.btrfs failed on my 16k pagesize kvm:
> >
> > What architecture is that?
> >
> The host chip is Apple m1 so it's arm64 but only supporting 16k and 4k
> pagesize. Since btrfs subpage work cares 64k pagesize for now, I
> usually run xfstests with 16k pagesize and 16k sectorsize. So far, so
> good.

Interesting, what's the distro? I haven't found one that would be
pre-built with 16k pages so I assume it's built from scratch. Among all
the page sizes we've seen so far 4k is almost everywhere, 64k is ppc and
arm (both native), and sparc has 8k. 16k is a new one, though I don't
think it would catch something we haven't seen so far it adds a bit to
the CPU capabilities coverage.

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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-14 11:22     ` David Sterba
@ 2021-05-14 13:23       ` Su Yue
  2021-05-14 13:50         ` Qu Wenruo
  0 siblings, 1 reply; 7+ messages in thread
From: Su Yue @ 2021-05-14 13:23 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs


On Fri 14 May 2021 at 19:22, David Sterba <dsterba@suse.cz> wrote:

> On Thu, May 13, 2021 at 08:37:29AM +0800, Su Yue wrote:
>>
>> On Wed 12 May 2021 at 22:01, David Sterba <dsterba@suse.cz> 
>> wrote:
>>
>> > On Tue, May 11, 2021 at 12:25:01PM +0800, Su Yue wrote:
>> >> Commit 8ef9313cf298 ("btrfs-progs: zoned: implement
>> >> log-structured
>> >> superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to
>> >> device.
>> >> The before num of bytes to be written is sectorsize.
>> >> It causes mkfs.btrfs failed on my 16k pagesize kvm:
>> >
>> > What architecture is that?
>> >
>> The host chip is Apple m1 so it's arm64 but only supporting 16k 
>> and 4k
>> pagesize. Since btrfs subpage work cares 64k pagesize for now, 
>> I
>> usually run xfstests with 16k pagesize and 16k sectorsize. So 
>> far, so
>> good.
>
> Interesting, what's the distro? I haven't found one that would 
> be
> pre-built with 16k pages so I assume it's built from scratch. 
> Among all
>

Right, I initially booted the kvm using Ubuntu kernel built with 
4k
pages then compiled 16k pagesize kernel manully.

--
Su
> the page sizes we've seen so far 4k is almost everywhere, 64k is 
> ppc and
> arm (both native), and sparc has 8k. 16k is a new one, though I 
> don't
> think it would catch something we haven't seen so far it adds a 
> bit to
> the CPU capabilities coverage.
>


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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-14 13:23       ` Su Yue
@ 2021-05-14 13:50         ` Qu Wenruo
  2021-05-14 14:28           ` David Sterba
  0 siblings, 1 reply; 7+ messages in thread
From: Qu Wenruo @ 2021-05-14 13:50 UTC (permalink / raw)
  To: Su Yue, dsterba; +Cc: linux-btrfs



On 2021/5/14 下午9:23, Su Yue wrote:
>
> On Fri 14 May 2021 at 19:22, David Sterba <dsterba@suse.cz> wrote:
>
>> On Thu, May 13, 2021 at 08:37:29AM +0800, Su Yue wrote:
>>>
>>> On Wed 12 May 2021 at 22:01, David Sterba <dsterba@suse.cz> wrote:
>>>
>>> > On Tue, May 11, 2021 at 12:25:01PM +0800, Su Yue wrote:
>>> >> Commit 8ef9313cf298 ("btrfs-progs: zoned: implement
>>> >> log-structured
>>> >> superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to
>>> >> device.
>>> >> The before num of bytes to be written is sectorsize.
>>> >> It causes mkfs.btrfs failed on my 16k pagesize kvm:
>>> >
>>> > What architecture is that?
>>> >
>>> The host chip is Apple m1 so it's arm64 but only supporting 16k and 4k
>>> pagesize. Since btrfs subpage work cares 64k pagesize for now, I
>>> usually run xfstests with 16k pagesize and 16k sectorsize. So far, so
>>> good.
>>
>> Interesting, what's the distro? I haven't found one that would be
>> pre-built with 16k pages so I assume it's built from scratch. Among all
>>
>
> Right, I initially booted the kvm using Ubuntu kernel built with 4k
> pages then compiled 16k pagesize kernel manully.

Are you sure it's really no 64K page support?

For example, maybe it's the fault of the VM UEFI you're using doesn't
support 64K page size?

Thanks,
Qu
>
> --
> Su
>> the page sizes we've seen so far 4k is almost everywhere, 64k is ppc and
>> arm (both native), and sparc has 8k. 16k is a new one, though I don't
>> think it would catch something we haven't seen so far it adds a bit to
>> the CPU capabilities coverage.
>>
>

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

* Re: [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
  2021-05-14 13:50         ` Qu Wenruo
@ 2021-05-14 14:28           ` David Sterba
  0 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2021-05-14 14:28 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: Su Yue, linux-btrfs

On Fri, May 14, 2021 at 09:50:00PM +0800, Qu Wenruo wrote:
> > Right, I initially booted the kvm using Ubuntu kernel built with 4k
> > pages then compiled 16k pagesize kernel manully.
> 
> Are you sure it's really no 64K page support?
> 
> For example, maybe it's the fault of the VM UEFI you're using doesn't
> support 64K page size?

It's been said on various sites that analyzed the chip that it's 16k and
there's not much official specs. Here's the most specific number
regarding page size and also effects on caches (and other perf
characteristics).

https://www.anandtech.com/show/16226/apple-silicon-m1-a14-deep-dive/2

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

end of thread, other threads:[~2021-05-14 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  4:25 [PATCH] btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock Su Yue
2021-05-12 14:01 ` David Sterba
2021-05-13  0:37   ` Su Yue
2021-05-14 11:22     ` David Sterba
2021-05-14 13:23       ` Su Yue
2021-05-14 13:50         ` Qu Wenruo
2021-05-14 14:28           ` David Sterba

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.