Skip to contentSkip to conversation

Btrfs-progs: restriper interface

RFC PATCH New Ilya Dryomov 1 participant 2 messages Aug 23, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Btrfs-progs: restriper interface

Hello,

This is a RFC, man pages are absent and just one big commit. Here are some specs for the new interface:

./btrfs fi restripe start [-d[filters]] [-m[filters]] [-s[filters]]

    [-vf] <path>

where 'filters' is comma-separated list of filters (comma == AND):

o profiles={profiles mask} - profiles filter

    profiles mask is '|'-separated list ('|' == OR) of profiles

o usage={percentage} - usage filter

o devid={devid} - devid filter

o drange={start..end} - devid subset filter, it's tied to devid filter:
we say balance out range [start..end) on a particular devid. These are also acceptable:

drange=start.. - [start..end of device)
drange=..end - [start of device..end)

o vrange={start..end} - virtual address space subset filter. Same forms as above are acceptable.

Convert (profile changing) is specified as follows:

o convert={profile},[soft]

soft parameter makes sense only for convert option. It turns on
"soft" mode for profile changing, see the kernel patch.

Each chunk type can be either balanced or converted to some new profile. By specifying some filters w/o convert option we balance chunks that passed all filters (remember, comma == AND). If only convert parameter is specified we convert all chunks of that type. If both convert and filters are specified restriper filters out chunks according to the given filters and then converts everything that passed through all the filters.

Some examples:

o ./btrfs fi restripe start <path>

will balance everything (what ./btrfs fi balance <path> would do)

o ./btrfs fi restripe start -d

will balance only data chunks

o ./btrfs fi restripe start -d -s

will balance all data and system chunks, won't touch meta chunks

o ./btrfs fi restripe start -dprofiles=raid1\|raid0

\ - shell escape, will balance only data chunks that have raid1 or raid0 profile

o ./btrfs fi restripe start -mprofiles=raid1\|raid0,devid=2

will balance meta chunks that have raid1 or raid0 profile and at least one stripe located on device with devid 2

o ./btrfs fi restripe start -s -musage=80,profiles=dup

will balance all system chunks and dup'ed metadata chunks which are less than 80% full

o ./btrfs fi restripe start -s -mprofiles=dup,convert=raid1

will *balance* all system chunks and *convert* dup meta chunks to raid1

o ./btrfs fi restripe start -dvrange=100..803337011,convert=raid0,soft

will soft-convert chunks in that virtual address space range to raid0

Note that you can't put a space between e.g. -m and a list of filters because of the way getopt(3) works. There are also long options, if you prefer (--data, --metadata, --system), e.g:

    ./btrfs fi restripe start --data=profiles=raid1\|raid0

All permutations are possible, restriper doesn't care about the order in which options are given, all settings are per-chunk-type, and what you do with one chunk type is completely independent of what you do with the other.

The -f (--force) flag has to be given if you want to "downgrade" the profile. By downgrading I mean reducing the number of copies, so raid10->raid1 can be done w/o this flag, while raid1->raid0 cannot.

And the management commands:

./btrfs fi restripe cancel <path>
./btrfs fi restripe pause <path>
./btrfs fi restripe resume <path>

Any suggestions on the interface are welcome. Patch is on top of tmp branch of cmason's repo, available at:

git://github.com/idryomov/btrfs-progs.git restriper-rfc

Thanks,

Ilya

Ilya Dryomov (1):
Btrfs-progs: add restriper commands

 btrfs.c      |   25 +++-
 btrfs_cmds.c |  508 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 btrfs_cmds.h |    5 +
 ctree.h      |    9 +
 ioctl.h      |   44 +++++
 print-tree.c |    3 +
 volumes.h    |   42 +++++
 7 files changed, 632 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 Btrfs-progs: add restriper commands

---
 btrfs.c      |   25 +++-
 btrfs_cmds.c |  508 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 btrfs_cmds.h |    5 +
 ctree.h      |    9 +
 ioctl.h      |   44 +++++
 print-tree.c |    3 +
 volumes.h    |   42 +++++
 7 files changed, 632 insertions(+), 4 deletions(-)
btrfs.c +23 -2
index 4cd4210..ae088f5 100644
@@ -95,8 +95,29 @@ static struct Command commands[] = {
 	  "filesystem balance", "<path>\n"
 		"Balance the chunks across the device."
 	},
-	{ do_scan, 999, 
-	  "device scan", "[<device>...]\n"
+	{ do_restripe, -1,
+	  "filesystem restripe start", "[-d [filters]] [-m [filters]] "
+	  "[-s [filters]] [-vf] <path>\n"
+		"Start restriper."
+	},
+	{ do_restripe_cancel, 1,
+	  "filesystem restripe cancel", "<path>\n"
+		"Cancel restriper."
+	},
+	{ do_restripe_pause, 1,
+	  "filesystem restripe pause", "<path>\n"
+		"Pause restriper."
+	},
+	{ do_restripe_resume, 1,
+	  "filesystem restripe resume", "<path>\n"
+		"Resume interrupted restripe operation."
+	},
+	{ do_restripe_progress, -1,
+	  "filesystem restripe status", "[-v] <path>\n"
+		"Show status of running or paused restripe operation."
+	},
+	{ do_scan,
+	  999, "device scan", "[<device> [<device>..]\n"
 		"Scan all device for or the passed device for a btrfs\n"
 		"filesystem."
 	},
btrfs_cmds.c +506 -2

525 lines not on this page · raw message

btrfs_cmds.h +5 -0
index ab722d4..de09b65 100644
@@ -23,6 +23,11 @@ int do_defrag(int argc, char **argv);
 int do_show_filesystem(int nargs, char **argv);
 int do_add_volume(int nargs, char **args);
 int do_balance(int nargs, char **argv);
+int do_restripe(int ac, char **av);
+int do_restripe_cancel(int ac, char **av);
+int do_restripe_pause(int ac, char **av);
+int do_restripe_resume(int ac, char **av);
+int do_restripe_progress(int ac, char **av);
 int do_remove_volume(int nargs, char **args);
 int do_scan(int nargs, char **argv);
 int do_resize(int nargs, char **argv);
ctree.h +9 -0
index 61eb639..46bb860 100644
@@ -60,6 +60,9 @@ struct btrfs_trans_handle;
 #define BTRFS_CSUM_TREE_OBJECTID 7ULL
 
 
+/* for storing restripe params in the root tree */
+#define BTRFS_RESTRIPE_OBJECTID -4ULL
+
 /* oprhan objectid for tracking unlinked/truncated files */
 #define BTRFS_ORPHAN_OBJECTID -5ULL
 
@@ -651,6 +654,12 @@ struct btrfs_csum_item {
 #define BTRFS_BLOCK_GROUP_DUP	   (1 << 5)
 #define BTRFS_BLOCK_GROUP_RAID10   (1 << 6)
 
+/*
+ * to avoid troubles..
+ */
+#define BTRFS_AVAIL_ALLOC_BIT_SINGLE	(1 << 7)
+#define BTRFS_BLOCK_GROUP_RESERVED	(1 << 7)
+
 struct btrfs_block_group_item {
 	__le64 used;
 	__le64 chunk_objectid;
ioctl.h +44 -0

54 lines not on this page · raw message

print-tree.c +3 -0
index ac575d5..14480d6 100644
@@ -391,6 +391,9 @@ static void print_objectid(unsigned long long objectid, u8 type)
 	case BTRFS_CSUM_TREE_OBJECTID:
 		printf("CSUM_TREE");
 		break;
+	case BTRFS_RESTRIPE_OBJECTID:
+		printf("RESTRIPE");
+		break;
 	case BTRFS_ORPHAN_OBJECTID:
 		printf("ORPHAN");
 		break;
volumes.h +42 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.5.4