All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/5] btrfs-progs: mkfs: Apply the sectorsize user specified on 64k page size system
Date: Fri,  5 Jul 2019 15:26:47 +0800	[thread overview]
Message-ID: <20190705072651.25150-2-wqu@suse.com> (raw)
In-Reply-To: <20190705072651.25150-1-wqu@suse.com>

[BUG]
On aarch64 with 64k page size, mkfs.btrfs -s option doesn't work:
  $ mkfs.btrfs  -s 4096 ~/10G.img  -f
  btrfs-progs v5.1.1
  See http://btrfs.wiki.kernel.org for more information.

  Label:              (null)
  UUID:               c2a09334-aaca-4980-aefa-4b3e27390658
  Node size:          65536
  Sector size:        65536		<< Still 64K, not 4K
  Filesystem size:    10.00GiB
  Block group profiles:
    Data:             single            8.00MiB
    Metadata:         DUP             256.00MiB
    System:           DUP               8.00MiB
  SSD detected:       no
  Incompat features:  extref, skinny-metadata
  Number of devices:  1
  Devices:
     ID        SIZE  PATH
      1    10.00GiB  /home/adam/10G.img

[CAUSE]
This is because we automatically detect sectorsize based on current
system page size, then get the maxium number between user specified -s
parameter and system page size.

It's fine for x86 as it has fixed page size 4K, also the minimium valid
sector size.

But for system like aarch64 or ppc64le, where we can have 64K page size,
and it makes us unable to create a 4k sector sized btrfs.

[FIX]
Only do auto detect when no -s|--sectorsize option is specified.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 mkfs/main.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 8dbec0717b89..26d84e9dafc3 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -817,6 +817,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 	char *source_dir = NULL;
 	bool source_dir_set = false;
 	bool shrink_rootdir = false;
+	bool sectorsize_set = false;
 	u64 source_dir_size = 0;
 	u64 min_dev_size;
 	u64 shrink_size;
@@ -906,6 +907,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 				}
 			case 's':
 				sectorsize = parse_size(optarg);
+				sectorsize_set = true;
 				break;
 			case 'b':
 				block_count = parse_size(optarg);
@@ -943,7 +945,15 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 		printf("See %s for more information.\n\n", PACKAGE_URL);
 	}
 
-	sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
+	if (!sectorsize_set)
+		sectorsize = max(sectorsize, (u32)sysconf(_SC_PAGESIZE));
+	if (!is_power_of_2(sectorsize) || sectorsize < 4096 ||
+	    sectorsize > SZ_64K) {
+		error(
+		"invalid sectorsize: %u, expect either 4k, 8k, 16k, 32k or 64k",
+			sectorsize);
+		goto error;
+	}
 	stripesize = sectorsize;
 	saved_optind = optind;
 	dev_cnt = argc - optind;
-- 
2.22.0


  reply	other threads:[~2019-07-05  7:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05  7:26 [PATCH 0/5] btrfs-progs: tests: Make 64K page size system happier Qu Wenruo
2019-07-05  7:26 ` Qu Wenruo [this message]
2019-07-05  7:45   ` [PATCH 1/5] btrfs-progs: mkfs: Apply the sectorsize user specified on 64k page size system Nikolay Borisov
2019-07-05  8:38     ` Qu Wenruo
2019-07-05  7:26 ` [PATCH 2/5] btrfs-progs: fsck-tests: Check if current kernel can mount fs with specified sector size Qu Wenruo
2019-07-22 17:07   ` David Sterba
2019-07-23  1:05     ` Qu Wenruo
2019-07-05  7:26 ` [PATCH 3/5] btrfs-progs: mkfs-tests: Skip 010-minimal-size if we can't mount with 4k " Qu Wenruo
2019-07-22 17:15   ` David Sterba
2019-07-23  1:08     ` Qu Wenruo
2019-07-05  7:26 ` [PATCH 4/5] btrfs-progs: misc-tests: Make test cases work or skipped on 64K page size system Qu Wenruo
2019-07-05  7:26 ` [PATCH 5/5] btrfs-progs: convert-tests: Skip tests if kernel doesn't support subpage sized sector size Qu Wenruo
2019-07-22 17:39   ` David Sterba
2019-07-22 16:49 ` [PATCH 0/5] btrfs-progs: tests: Make 64K page size system happier David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190705072651.25150-2-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.