linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: idryomov@gmail.com
Subject: [PATCH] Btrfs-progs: allow dup for data chunks in mixed mode
Date: Tue, 13 Mar 2012 22:47:39 +0200	[thread overview]
Message-ID: <1331671659-7721-1-git-send-email-idryomov@gmail.com> (raw)

Before commit a46e7ff2 was merged it was possible to create dup for
data+metadata chunks (mixed mode) by giving -m raid1 -d raid1 -M to
mkfs.  a46e7ff2 purposefully disabled behind the scenes profile
upgrading/downgrading, so give users a chance to pick dup explicitly and
bail if dup for data is requested in normal mode.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 mkfs.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index d3f45bd..6d3ef29 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -258,17 +258,23 @@ static int create_raid_groups(struct btrfs_trans_handle *trans,
 
 	if (metadata_profile & ~allowed) {
 		fprintf(stderr,	"unable to create FS with metadata "
-			"profile %llu (%llu devices)\n", metadata_profile,
+			"profile %llu (have %llu devices)\n", metadata_profile,
 			num_devices);
 		exit(1);
 	}
 	if (data_profile & ~allowed) {
 		fprintf(stderr, "unable to create FS with data "
-			"profile %llu (%llu devices)\n", data_profile,
+			"profile %llu (have %llu devices)\n", data_profile,
 			num_devices);
 		exit(1);
 	}
 
+	/* allow dup'ed data chunks only in mixed mode */
+	if (!mixed && (data_profile & BTRFS_BLOCK_GROUP_DUP)) {
+		fprintf(stderr, "dup for data is allowed only in mixed mode\n");
+		exit(1);
+	}
+
 	if (allowed & metadata_profile) {
 		u64 meta_flags = BTRFS_BLOCK_GROUP_METADATA;
 
@@ -329,7 +335,7 @@ static void print_usage(void)
 	fprintf(stderr, "options:\n");
 	fprintf(stderr, "\t -A --alloc-start the offset to start the FS\n");
 	fprintf(stderr, "\t -b --byte-count total number of bytes in the FS\n");
-	fprintf(stderr, "\t -d --data data profile, raid0, raid1, raid10 or single\n");
+	fprintf(stderr, "\t -d --data data profile, raid0, raid1, raid10, dup or single\n");
 	fprintf(stderr, "\t -l --leafsize size of btree leaves\n");
 	fprintf(stderr, "\t -L --label set a label\n");
 	fprintf(stderr, "\t -m --metadata metadata profile, values like data profile\n");
@@ -355,10 +361,12 @@ static u64 parse_profile(char *s)
 		return BTRFS_BLOCK_GROUP_RAID1;
 	} else if (strcmp(s, "raid10") == 0) {
 		return BTRFS_BLOCK_GROUP_RAID10;
+	} else if (strcmp(s, "dup") == 0) {
+		return BTRFS_BLOCK_GROUP_DUP;
 	} else if (strcmp(s, "single") == 0) {
 		return 0;
 	} else {
-		fprintf(stderr, "Unknown option %s\n", s);
+		fprintf(stderr, "Unknown profile %s\n", s);
 		print_usage();
 	}
 	/* not reached */
-- 
1.7.9.1


                 reply	other threads:[~2012-03-13 20:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1331671659-7721-1-git-send-email-idryomov@gmail.com \
    --to=idryomov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).