All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: mkfs: follow sectorsize for mixed mode
@ 2021-05-17  9:55 Qu Wenruo
  2021-07-01 19:41 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2021-05-17  9:55 UTC (permalink / raw)
  To: linux-btrfs

[BUG]
When running fstests with 4K sectorsize and 64K page size (aka subpage
support), the following tests failed:

  $ sudo ./check generic/416 generic/619
  FSTYP         -- btrfs
  PLATFORM      -- Linux/aarch64 rockpi4 5.12.0-rc8-custom+ #9 SMP Tue Apr 27 12:49:52 CST 2021
  MKFS_OPTIONS  -- -s 4k /dev/mapper/arm_nvme-scratch1
  MOUNT_OPTIONS -- /dev/mapper/arm_nvme-scratch1 /mnt/scratch

  generic/416     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/416.out.bad)
     QA output created by 416
    -wrote 16777216/16777216 bytes at offset 0
    -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
    +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
    +mount failed
    +(see ~/xfstests-dev/results//generic/416.full for details)
    ...
    (Run 'diff -u ~/xfstests-dev/tests/generic/416.out ~/xfstests-dev/results//generic/416.out.bad'  to see the entire diff)
  generic/619     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/619.out.bad)
     QA output created by 619
    -Silence is golden
    +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
    +mount failed
    +(see ~/xfstests-dev/results//generic/619.full for details)
    ...
    (Run 'diff -u ~/xfstests-dev/tests/generic/619.out ~/xfstests-dev/results//generic/619.out.bad'  to see the entire diff)
  Ran: generic/416 generic/619
  Failures: generic/416 generic/619
  Failed 2 of 2 tests

[CAUSE]
Those two tests call _scratch_mkfs_sized to create a small fs, all of them
are smaller than the 256M.

Since the fs is small, fstests choose to pass -M to make a mixed btrfs.
(Let's just ignore whether we should pass -M here).

Then on 64K page size system, "mkfs.btrfs -s 4K -M -b 128M $dev" will fail
with the following error message:

  btrfs-progs v5.11
  See http://btrfs.wiki.kernel.org for more information.

  ERROR: illegal nodesize 65536 (not equal to 4096 for mixed block group)

This is caused by the nodesize selection, which always try to choose the
larger value between pagesize and sectorsize.

This hardcoded PAGESIZE usage in mkfs.btrfs makes us to choose 64K
nodesize even we specified to use 4K sectorsize.

[FIX]
Just use sectorsize as nodesize when -M is specified.

With this fix, above two tests now pass for btrfs subpage case.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mkfs/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index c910369cbf94..81241054f6c8 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1177,8 +1177,6 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 			data_profile = tmp;
 		}
 	} else {
-		u32 best_nodesize = max_t(u32, sysconf(_SC_PAGESIZE), sectorsize);
-
 		if (metadata_profile_opt || data_profile_opt) {
 			if (metadata_profile != data_profile) {
 				error(
@@ -1188,7 +1186,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 		}
 
 		if (!nodesize_forced)
-			nodesize = best_nodesize;
+			nodesize = sectorsize;
 	}
 
 	/*
-- 
2.31.1


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

* Re: [PATCH] btrfs-progs: mkfs: follow sectorsize for mixed mode
  2021-05-17  9:55 [PATCH] btrfs-progs: mkfs: follow sectorsize for mixed mode Qu Wenruo
@ 2021-07-01 19:41 ` David Sterba
  2021-07-01 22:30   ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2021-07-01 19:41 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Mon, May 17, 2021 at 05:55:16PM +0800, Qu Wenruo wrote:
> [BUG]
> When running fstests with 4K sectorsize and 64K page size (aka subpage
> support), the following tests failed:
> 
>   $ sudo ./check generic/416 generic/619
>   FSTYP         -- btrfs
>   PLATFORM      -- Linux/aarch64 rockpi4 5.12.0-rc8-custom+ #9 SMP Tue Apr 27 12:49:52 CST 2021
>   MKFS_OPTIONS  -- -s 4k /dev/mapper/arm_nvme-scratch1
>   MOUNT_OPTIONS -- /dev/mapper/arm_nvme-scratch1 /mnt/scratch
> 
>   generic/416     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/416.out.bad)
>      QA output created by 416
>     -wrote 16777216/16777216 bytes at offset 0
>     -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>     +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
>     +mount failed
>     +(see ~/xfstests-dev/results//generic/416.full for details)
>     ...
>     (Run 'diff -u ~/xfstests-dev/tests/generic/416.out ~/xfstests-dev/results//generic/416.out.bad'  to see the entire diff)
>   generic/619     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/619.out.bad)
>      QA output created by 619
>     -Silence is golden
>     +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
>     +mount failed
>     +(see ~/xfstests-dev/results//generic/619.full for details)
>     ...
>     (Run 'diff -u ~/xfstests-dev/tests/generic/619.out ~/xfstests-dev/results//generic/619.out.bad'  to see the entire diff)
>   Ran: generic/416 generic/619
>   Failures: generic/416 generic/619
>   Failed 2 of 2 tests
> 
> [CAUSE]
> Those two tests call _scratch_mkfs_sized to create a small fs, all of them
> are smaller than the 256M.
> 
> Since the fs is small, fstests choose to pass -M to make a mixed btrfs.
> (Let's just ignore whether we should pass -M here).

I think this is actually the problem, this should be fixed in fstests.

> 
> Then on 64K page size system, "mkfs.btrfs -s 4K -M -b 128M $dev" will fail

When --mixed is used, use both --sectorsize and --nodesize.

> with the following error message:
> 
>   btrfs-progs v5.11
>   See http://btrfs.wiki.kernel.org for more information.
> 
>   ERROR: illegal nodesize 65536 (not equal to 4096 for mixed block group)
> 
> This is caused by the nodesize selection, which always try to choose the
> larger value between pagesize and sectorsize.
> 
> This hardcoded PAGESIZE usage in mkfs.btrfs makes us to choose 64K
> nodesize even we specified to use 4K sectorsize.
> 
> [FIX]
> Just use sectorsize as nodesize when -M is specified.
> 
> With this fix, above two tests now pass for btrfs subpage case.

This is changing the mkfs behaviour for everybody just to fix a fstests
test case. I disagree to do that. Fstests get weekly releases so if the
test is failing now, it won't next week once a patch is applied.

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

* Re: [PATCH] btrfs-progs: mkfs: follow sectorsize for mixed mode
  2021-07-01 19:41 ` David Sterba
@ 2021-07-01 22:30   ` Qu Wenruo
  0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2021-07-01 22:30 UTC (permalink / raw)
  To: dsterba, linux-btrfs



On 2021/7/2 上午3:41, David Sterba wrote:
> On Mon, May 17, 2021 at 05:55:16PM +0800, Qu Wenruo wrote:
>> [BUG]
>> When running fstests with 4K sectorsize and 64K page size (aka subpage
>> support), the following tests failed:
>>
>>    $ sudo ./check generic/416 generic/619
>>    FSTYP         -- btrfs
>>    PLATFORM      -- Linux/aarch64 rockpi4 5.12.0-rc8-custom+ #9 SMP Tue Apr 27 12:49:52 CST 2021
>>    MKFS_OPTIONS  -- -s 4k /dev/mapper/arm_nvme-scratch1
>>    MOUNT_OPTIONS -- /dev/mapper/arm_nvme-scratch1 /mnt/scratch
>>
>>    generic/416     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/416.out.bad)
>>       QA output created by 416
>>      -wrote 16777216/16777216 bytes at offset 0
>>      -XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>>      +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
>>      +mount failed
>>      +(see ~/xfstests-dev/results//generic/416.full for details)
>>      ...
>>      (Run 'diff -u ~/xfstests-dev/tests/generic/416.out ~/xfstests-dev/results//generic/416.out.bad'  to see the entire diff)
>>    generic/619     [failed, exit status 1]- output mismatch (see ~/xfstests-dev/results//generic/619.out.bad)
>>       QA output created by 619
>>      -Silence is golden
>>      +mount: /mnt/scratch: wrong fs type, bad option, bad superblock on /dev/mapper/arm_nvme-scratch1, missing codepage or helper program, or other error.
>>      +mount failed
>>      +(see ~/xfstests-dev/results//generic/619.full for details)
>>      ...
>>      (Run 'diff -u ~/xfstests-dev/tests/generic/619.out ~/xfstests-dev/results//generic/619.out.bad'  to see the entire diff)
>>    Ran: generic/416 generic/619
>>    Failures: generic/416 generic/619
>>    Failed 2 of 2 tests
>>
>> [CAUSE]
>> Those two tests call _scratch_mkfs_sized to create a small fs, all of them
>> are smaller than the 256M.
>>
>> Since the fs is small, fstests choose to pass -M to make a mixed btrfs.
>> (Let's just ignore whether we should pass -M here).
> 
> I think this is actually the problem, this should be fixed in fstests.

Yeah, but this still expose a problem.

When -s is specified, why nodesize is not chosen automatically when -M 
is also specified.

For current -s 4k specification, nodesize is chosen automatically by the 
16K default value, not the PAGE_SIZE anymore.

But with -s 4K and -M together, we go 64K as default nodesize which is 
totally wrong.
> 
>>
>> Then on 64K page size system, "mkfs.btrfs -s 4K -M -b 128M $dev" will fail
> 
> When --mixed is used, use both --sectorsize and --nodesize.

Nope, on 4K systems, when -s 4k and -M is specififed, nodesize is 
automatically chosen as 4K.

No need to specify the nodesize.

In fact, when possible the nodesize should be automatically chosen.

Thus this is the problem I am going to solve.
The fstest failure is just an easy way to expose the bug.

Thanks,
Qu

> 
>> with the following error message:
>>
>>    btrfs-progs v5.11
>>    See http://btrfs.wiki.kernel.org for more information.
>>
>>    ERROR: illegal nodesize 65536 (not equal to 4096 for mixed block group)
>>
>> This is caused by the nodesize selection, which always try to choose the
>> larger value between pagesize and sectorsize.
>>
>> This hardcoded PAGESIZE usage in mkfs.btrfs makes us to choose 64K
>> nodesize even we specified to use 4K sectorsize.
>>
>> [FIX]
>> Just use sectorsize as nodesize when -M is specified.
>>
>> With this fix, above two tests now pass for btrfs subpage case.
> 
> This is changing the mkfs behaviour for everybody just to fix a fstests
> test case. I disagree to do that. Fstests get weekly releases so if the
> test is failing now, it won't next week once a patch is applied.
> 


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

end of thread, other threads:[~2021-07-01 22:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  9:55 [PATCH] btrfs-progs: mkfs: follow sectorsize for mixed mode Qu Wenruo
2021-07-01 19:41 ` David Sterba
2021-07-01 22:30   ` Qu Wenruo

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.