Accepting request 76976 from filesystems
- remove debugging printf from 0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch (forwarded request 76766 from dsterba) OBS-URL: https://build.opensuse.org/request/show/76976 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=22
This commit is contained in:
parent
86841e311e
commit
114572d558
157
0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch
Normal file
157
0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
From 70c6c10134b502fa69955746554031939b85fb0c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chris Mason <chris.mason@oracle.com>
|
||||||
|
Date: Thu, 9 Dec 2010 16:36:29 -0500
|
||||||
|
Subject: [PATCH 01/15] Btrfs-progs: add a btrfs-select-super command to
|
||||||
|
overwrite the super
|
||||||
|
|
||||||
|
Btrfs stores multiple copies of the superblock, and for common power-failure
|
||||||
|
crashes where barriers were not in use, one of the super copies is often
|
||||||
|
valid while the first copy is not.
|
||||||
|
|
||||||
|
This adds a btrfs-select-super -s N /dev/xxx command, which can
|
||||||
|
overwrite all the super blocks with a copy that you have already
|
||||||
|
determined is valid with btrfsck -s
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
Makefile | 3 ++
|
||||||
|
btrfs-select-super.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
disk-io.c | 2 +-
|
||||||
|
disk-io.h | 1 +
|
||||||
|
4 files changed, 104 insertions(+), 1 deletions(-)
|
||||||
|
create mode 100644 btrfs-select-super.c
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index 6e6f6c6..d65f6a2 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -62,6 +62,9 @@ btrfs-debug-tree: $(objects) debug-tree.o
|
||||||
|
btrfs-zero-log: $(objects) btrfs-zero-log.o
|
||||||
|
gcc $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
+btrfs-select-super: $(objects) btrfs-select-super.o
|
||||||
|
+ gcc $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS)
|
||||||
|
+
|
||||||
|
btrfstune: $(objects) btrfstune.o
|
||||||
|
gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..f12f36c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/btrfs-select-super.c
|
||||||
|
@@ -0,0 +1,99 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2007 Oracle. All rights reserved.
|
||||||
|
+ *
|
||||||
|
+ * This program is free software; you can redistribute it and/or
|
||||||
|
+ * modify it under the terms of the GNU General Public
|
||||||
|
+ * License v2 as published by the Free Software Foundation.
|
||||||
|
+ *
|
||||||
|
+ * This program is distributed in the hope that it will be useful,
|
||||||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
+ * General Public License for more details.
|
||||||
|
+ *
|
||||||
|
+ * You should have received a copy of the GNU General Public
|
||||||
|
+ * License along with this program; if not, write to the
|
||||||
|
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
+ * Boston, MA 021110-1307, USA.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#define _XOPEN_SOURCE 500
|
||||||
|
+#define _GNU_SOURCE 1
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+#include <fcntl.h>
|
||||||
|
+#include <sys/stat.h>
|
||||||
|
+#include "kerncompat.h"
|
||||||
|
+#include "ctree.h"
|
||||||
|
+#include "disk-io.h"
|
||||||
|
+#include "print-tree.h"
|
||||||
|
+#include "transaction.h"
|
||||||
|
+#include "list.h"
|
||||||
|
+#include "version.h"
|
||||||
|
+#include "utils.h"
|
||||||
|
+
|
||||||
|
+static void print_usage(void)
|
||||||
|
+{
|
||||||
|
+ fprintf(stderr, "usage: btrfs-select-super -s number dev\n");
|
||||||
|
+ fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
||||||
|
+ exit(1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int main(int ac, char **av)
|
||||||
|
+{
|
||||||
|
+ struct btrfs_root *root;
|
||||||
|
+ int ret;
|
||||||
|
+ int num;
|
||||||
|
+ u64 bytenr = 0;
|
||||||
|
+
|
||||||
|
+ while(1) {
|
||||||
|
+ int c;
|
||||||
|
+ c = getopt(ac, av, "s:");
|
||||||
|
+ if (c < 0)
|
||||||
|
+ break;
|
||||||
|
+ switch(c) {
|
||||||
|
+ case 's':
|
||||||
|
+ num = atol(optarg);
|
||||||
|
+ bytenr = btrfs_sb_offset(num);
|
||||||
|
+ printf("using SB copy %d, bytenr %llu\n", num,
|
||||||
|
+ (unsigned long long)bytenr);
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ print_usage();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ ac = ac - optind;
|
||||||
|
+
|
||||||
|
+ if (ac != 1)
|
||||||
|
+ print_usage();
|
||||||
|
+
|
||||||
|
+ if (bytenr == 0) {
|
||||||
|
+ fprintf(stderr, "Please select the super copy with -s\n");
|
||||||
|
+ print_usage();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ radix_tree_init();
|
||||||
|
+
|
||||||
|
+ if((ret = check_mounted(av[optind])) < 0) {
|
||||||
|
+ fprintf(stderr, "Could not check mount status: %s\n", strerror(ret));
|
||||||
|
+ return ret;
|
||||||
|
+ } else if(ret) {
|
||||||
|
+ fprintf(stderr, "%s is currently mounted. Aborting.\n", av[optind]);
|
||||||
|
+ return -EBUSY;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ root = open_ctree(av[optind], bytenr, 1);
|
||||||
|
+
|
||||||
|
+ if (root == NULL)
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+ /* make the super writing code think we've read the first super */
|
||||||
|
+ root->fs_info->super_bytenr = BTRFS_SUPER_INFO_OFFSET;
|
||||||
|
+ ret = write_all_supers(root);
|
||||||
|
+
|
||||||
|
+ /* we don't close the ctree or anything, because we don't want a real
|
||||||
|
+ * transaction commit. We just want the super copy we pulled off the
|
||||||
|
+ * disk to overwrite all the other copies
|
||||||
|
+ */
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
diff --git a/disk-io.h b/disk-io.h
|
||||||
|
index 49e5692..7ebec24 100644
|
||||||
|
--- a/disk-io.h
|
||||||
|
+++ b/disk-io.h
|
||||||
|
@@ -47,6 +47,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes);
|
||||||
|
struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
|
||||||
|
int writes);
|
||||||
|
int close_ctree(struct btrfs_root *root);
|
||||||
|
+int write_all_supers(struct btrfs_root *root);
|
||||||
|
int write_ctree_super(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root);
|
||||||
|
int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
151
0002-Btrfs-progs-use-safe-string-manipulation-functions.patch
Normal file
151
0002-Btrfs-progs-use-safe-string-manipulation-functions.patch
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
From 2636bf1da17720fc99b14cf4db33f1d1a4c9e0ee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Eduardo Silva <eduardo.silva@oracle.com>
|
||||||
|
Date: Mon, 7 Feb 2011 08:55:04 -0300
|
||||||
|
Subject: [PATCH 02/15] Btrfs-progs use safe string manipulation functions
|
||||||
|
|
||||||
|
Signed-off-by: Eduardo Silva <eduardo.silva@oracle.com>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs_cmds.c | 14 +++++++-------
|
||||||
|
btrfsctl.c | 2 +-
|
||||||
|
convert.c | 2 +-
|
||||||
|
utils.c | 9 +++++----
|
||||||
|
4 files changed, 14 insertions(+), 13 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 8031c58..fffb423 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -375,7 +375,7 @@ int do_clone(int argc, char **argv)
|
||||||
|
printf("Create a snapshot of '%s' in '%s/%s'\n",
|
||||||
|
subvol, dstdir, newname);
|
||||||
|
args.fd = fd;
|
||||||
|
- strcpy(args.name, newname);
|
||||||
|
+ strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
@@ -436,7 +436,7 @@ int do_delete_subvolume(int argc, char **argv)
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Delete subvolume '%s/%s'\n", dname, vname);
|
||||||
|
- strcpy(args.name, vname);
|
||||||
|
+ strncpy(args.name, vname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
@@ -490,7 +490,7 @@ int do_create_subvol(int argc, char **argv)
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Create subvolume '%s/%s'\n", dstdir, newname);
|
||||||
|
- strcpy(args.name, newname);
|
||||||
|
+ strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args);
|
||||||
|
|
||||||
|
close(fddst);
|
||||||
|
@@ -553,7 +553,7 @@ int do_scan(int argc, char **argv)
|
||||||
|
|
||||||
|
printf("Scanning for Btrfs filesystems in '%s'\n", argv[i]);
|
||||||
|
|
||||||
|
- strcpy(args.name, argv[i]);
|
||||||
|
+ strncpy(args.name, argv[i], BTRFS_PATH_NAME_MAX);
|
||||||
|
/*
|
||||||
|
* FIXME: which are the error code returned by this ioctl ?
|
||||||
|
* it seems that is impossible to understand if there no is
|
||||||
|
@@ -593,7 +593,7 @@ int do_resize(int argc, char **argv)
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Resize '%s' of '%s'\n", path, amount);
|
||||||
|
- strcpy(args.name, amount);
|
||||||
|
+ strncpy(args.name, amount, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fd, BTRFS_IOC_RESIZE, &args);
|
||||||
|
close(fd);
|
||||||
|
if( res < 0 ){
|
||||||
|
@@ -736,7 +736,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
}
|
||||||
|
close(devfd);
|
||||||
|
|
||||||
|
- strcpy(ioctl_args.name, args[i]);
|
||||||
|
+ strncpy(ioctl_args.name, args[i], BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
|
||||||
|
if(res<0){
|
||||||
|
fprintf(stderr, "ERROR: error adding the device '%s'\n", args[i]);
|
||||||
|
@@ -792,7 +792,7 @@ int do_remove_volume(int nargs, char **args)
|
||||||
|
struct btrfs_ioctl_vol_args arg;
|
||||||
|
int res;
|
||||||
|
|
||||||
|
- strcpy(arg.name, args[i]);
|
||||||
|
+ strncpy(arg.name, args[i], BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
|
||||||
|
if(res<0){
|
||||||
|
fprintf(stderr, "ERROR: error removing the device '%s'\n", args[i]);
|
||||||
|
diff --git a/btrfsctl.c b/btrfsctl.c
|
||||||
|
index 92bdf39..adfa519 100644
|
||||||
|
--- a/btrfsctl.c
|
||||||
|
+++ b/btrfsctl.c
|
||||||
|
@@ -237,7 +237,7 @@ int main(int ac, char **av)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
- strcpy(args.name, name);
|
||||||
|
+ strncpy(args.name, name, BTRFS_PATH_NAME_MAX + 1);
|
||||||
|
else
|
||||||
|
args.name[0] = '\0';
|
||||||
|
|
||||||
|
diff --git a/convert.c b/convert.c
|
||||||
|
index d037c98..fbcf4a3 100644
|
||||||
|
--- a/convert.c
|
||||||
|
+++ b/convert.c
|
||||||
|
@@ -857,7 +857,7 @@ static int copy_single_xattr(struct btrfs_trans_handle *trans,
|
||||||
|
data = databuf;
|
||||||
|
datalen = bufsize;
|
||||||
|
}
|
||||||
|
- strcpy(namebuf, xattr_prefix_table[name_index]);
|
||||||
|
+ strncpy(namebuf, xattr_prefix_table[name_index], XATTR_NAME_MAX);
|
||||||
|
strncat(namebuf, EXT2_EXT_ATTR_NAME(entry), entry->e_name_len);
|
||||||
|
if (name_len + datalen > BTRFS_LEAF_DATA_SIZE(root) -
|
||||||
|
sizeof(struct btrfs_item) - sizeof(struct btrfs_dir_item)) {
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index fd894f3..96ef94d 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -108,7 +108,7 @@ int make_btrfs(int fd, const char *device, const char *label,
|
||||||
|
btrfs_set_super_csum_type(&super, BTRFS_CSUM_TYPE_CRC32);
|
||||||
|
btrfs_set_super_chunk_root_generation(&super, 1);
|
||||||
|
if (label)
|
||||||
|
- strcpy(super.label, label);
|
||||||
|
+ strncpy(super.label, label, BTRFS_LABEL_SIZE - 1);
|
||||||
|
|
||||||
|
buf = malloc(sizeof(*buf) + max(sectorsize, leafsize));
|
||||||
|
|
||||||
|
@@ -828,7 +828,7 @@ void btrfs_register_one_device(char *fname)
|
||||||
|
"skipping device registration\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- strcpy(args.name, fname);
|
||||||
|
+ strncpy(args.name, fname, BTRFS_PATH_NAME_MAX);
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
@@ -971,6 +971,7 @@ static char *size_strs[] = { "", "KB", "MB", "GB", "TB",
|
||||||
|
char *pretty_sizes(u64 size)
|
||||||
|
{
|
||||||
|
int num_divs = 0;
|
||||||
|
+ int pretty_len = 16;
|
||||||
|
u64 last_size = size;
|
||||||
|
u64 fract_size = size;
|
||||||
|
float fraction;
|
||||||
|
@@ -988,8 +989,8 @@ char *pretty_sizes(u64 size)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
fraction = (float)fract_size / 1024;
|
||||||
|
- pretty = malloc(16);
|
||||||
|
- sprintf(pretty, "%.2f%s", fraction, size_strs[num_divs-1]);
|
||||||
|
+ pretty = malloc(pretty_len);
|
||||||
|
+ snprintf(pretty, pretty_len, "%.2f%s", fraction, size_strs[num_divs-1]);
|
||||||
|
return pretty;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
36
0003-Btrfs-progs-utils-Informative-errors.patch
Normal file
36
0003-Btrfs-progs-utils-Informative-errors.patch
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
From ac1a80f52434d05230f9933d8f68e28cc09e10b0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goldwyn Rodrigues <rgoldwyn@gmail.com>
|
||||||
|
Date: Mon, 7 Feb 2011 07:34:36 +0000
|
||||||
|
Subject: [PATCH 03/15] Btrfs-progs utils Informative errors
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
utils.c | 5 +++--
|
||||||
|
1 files changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 96ef94d..d8c3dcc 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -867,7 +867,7 @@ again:
|
||||||
|
}
|
||||||
|
dirp = opendir(dirname);
|
||||||
|
if (!dirp) {
|
||||||
|
- fprintf(stderr, "Unable to open /sys/block for scanning\n");
|
||||||
|
+ fprintf(stderr, "Unable to open %s for scanning\n", dirname);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
while(1) {
|
||||||
|
@@ -902,7 +902,8 @@ again:
|
||||||
|
}
|
||||||
|
fd = open(fullpath, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
- fprintf(stderr, "failed to read %s\n", fullpath);
|
||||||
|
+ fprintf(stderr, "failed to read %s: %s\n", fullpath,
|
||||||
|
+ strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,98 @@
|
|||||||
|
From 0a63a11c3d3bbb7e061daad28435b5eef91a947d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Date: Sun, 23 Jan 2011 15:31:07 +0000
|
||||||
|
Subject: [PATCH 04/15] update man page to new defragment command interface
|
||||||
|
|
||||||
|
Update
|
||||||
|
|
||||||
|
btrfs filesystem defragment
|
||||||
|
|
||||||
|
command explanation. Add explanation of advanced parameters and notes
|
||||||
|
about general usage.
|
||||||
|
|
||||||
|
Add few notes about the
|
||||||
|
|
||||||
|
btrfs <command> --help
|
||||||
|
|
||||||
|
usage, fix related grammar.
|
||||||
|
|
||||||
|
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
man/btrfs.8.in | 33 ++++++++++++++++++++++++++-------
|
||||||
|
1 files changed, 26 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index 26ef982..cba2de1 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -15,7 +15,7 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBsubvolume set-default\fP\fI <id> <path>\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBfilesystem defrag\fP\fI <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
+\fBbtrfs\fP \fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP
|
||||||
|
.PP
|
||||||
|
@@ -34,6 +34,8 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
||||||
|
.PP
|
||||||
|
+\fBbtrfs\fP \fB<command> \-\-help \fP\fI\fP
|
||||||
|
+.PP
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B btrfs
|
||||||
|
is used to control the filesystem and the files and directories stored. It is
|
||||||
|
@@ -60,12 +62,12 @@ returns an error.
|
||||||
|
|
||||||
|
If a command is terminated by
|
||||||
|
.I --help
|
||||||
|
-, the relevant help is showed. If the passed command matches more commands,
|
||||||
|
-the help of all the matched commands are showed. For example
|
||||||
|
+, the detailed help is showed. If the passed command matches more commands,
|
||||||
|
+detailed help of all the matched commands is showed. For example
|
||||||
|
.I btrfs dev --help
|
||||||
|
shows the help of all
|
||||||
|
.I device*
|
||||||
|
-command.
|
||||||
|
+commands.
|
||||||
|
|
||||||
|
.SH COMMANDS
|
||||||
|
.TP
|
||||||
|
@@ -98,12 +100,29 @@ mount time via the \fIsubvol=\fR option.
|
||||||
|
|
||||||
|
\fBsubvolume set-default\fR\fI <id> <path>\fR
|
||||||
|
Set the subvolume of the filesystem \fI<path>\fR which is mounted as
|
||||||
|
-\fIdefault\fR. The subvolume is identified by \fB<id>\fR, which
|
||||||
|
+\fIdefault\fR. The subvolume is identified by \fI<id>\fR, which
|
||||||
|
is returned by the \fBsubvolume list\fR command.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBfilesystem defragment\fP\fI <file>|<dir> [<file>|<dir>...]\fR
|
||||||
|
-Defragment files and/or directories.
|
||||||
|
+\fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fR
|
||||||
|
+Defragment file data and/or directory metadata. To defragment all files in a
|
||||||
|
+directory you have to specify each one on its own or use your shell wildcards.
|
||||||
|
+
|
||||||
|
+\fB-v\fP be verbose
|
||||||
|
+
|
||||||
|
+\fB-c\fP compress file contents while defragmenting
|
||||||
|
+
|
||||||
|
+\fB-f\fP flush filesystem after defragmenting
|
||||||
|
+
|
||||||
|
+\fB-s start\fP defragment only from byte \fIstart\fR onward
|
||||||
|
+
|
||||||
|
+\fB-l len\fP defragment only up to \fIlen\fR bytes
|
||||||
|
+
|
||||||
|
+\fB-t size\fP defragment only files at least \fIsize\fR bytes big
|
||||||
|
+
|
||||||
|
+NOTE: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of data, don't
|
||||||
|
+use it if you use snapshots, have de-duplicated your data or made copies with
|
||||||
|
+\fBcp --reflink\fP.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
\fBdevice scan\fR \fI[<device> [<device>..]]\fR
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
509
0005-Improve-error-handling-in-the-btrfs-command.patch
Normal file
509
0005-Improve-error-handling-in-the-btrfs-command.patch
Normal file
@ -0,0 +1,509 @@
|
|||||||
|
From b3007332100e01ca84c161b6c75f0a414ab4611b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goffredo Baroncelli <kreijack@libero.it>
|
||||||
|
Date: Mon, 20 Dec 2010 20:06:19 +0000
|
||||||
|
Subject: [PATCH 05/15] Improve error handling in the btrfs command
|
||||||
|
|
||||||
|
Hi Chris,
|
||||||
|
|
||||||
|
below is enclosed a trivial patch, which has the aim to improve the error
|
||||||
|
reporting of the "btrfs" command.
|
||||||
|
|
||||||
|
You can pull from
|
||||||
|
|
||||||
|
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
|
||||||
|
|
||||||
|
branch
|
||||||
|
|
||||||
|
strerror
|
||||||
|
|
||||||
|
I changed every printf("some-error") to something like:
|
||||||
|
|
||||||
|
e = errno;
|
||||||
|
fprintf(stderr, "ERROR: .... - %s", strerror(e));
|
||||||
|
|
||||||
|
so:
|
||||||
|
|
||||||
|
1) all the error are reported to standard error
|
||||||
|
2) At the end of the message is printed the error as returned by the system.
|
||||||
|
|
||||||
|
The change is quite simple, I replaced every printf("some-error") to the line
|
||||||
|
above. I don't touched anything other.
|
||||||
|
I also integrated a missing "printf" on the basis of the Ben patch.
|
||||||
|
|
||||||
|
This patch leads the btrfs command to be more "user friendly" :-)
|
||||||
|
|
||||||
|
Regards
|
||||||
|
G.Baroncelli
|
||||||
|
|
||||||
|
btrfs-list.c | 40 ++++++++++++++++++++++--------
|
||||||
|
btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++-----------------
|
||||||
|
utils.c | 6 ++++
|
||||||
|
3 files changed, 89 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs-list.c | 40 ++++++++++++++++++++++--------
|
||||||
|
btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++-----------------
|
||||||
|
utils.c | 6 ++++
|
||||||
|
3 files changed, 89 insertions(+), 34 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-list.c b/btrfs-list.c
|
||||||
|
index 93766a8..abcc2f4 100644
|
||||||
|
--- a/btrfs-list.c
|
||||||
|
+++ b/btrfs-list.c
|
||||||
|
@@ -265,7 +265,7 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri)
|
||||||
|
static int lookup_ino_path(int fd, struct root_info *ri)
|
||||||
|
{
|
||||||
|
struct btrfs_ioctl_ino_lookup_args args;
|
||||||
|
- int ret;
|
||||||
|
+ int ret, e;
|
||||||
|
|
||||||
|
if (ri->path)
|
||||||
|
return 0;
|
||||||
|
@@ -275,9 +275,11 @@ static int lookup_ino_path(int fd, struct root_info *ri)
|
||||||
|
args.objectid = ri->dir_id;
|
||||||
|
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret) {
|
||||||
|
- fprintf(stderr, "ERROR: Failed to lookup path for root %llu\n",
|
||||||
|
- (unsigned long long)ri->ref_tree);
|
||||||
|
+ fprintf(stderr, "ERROR: Failed to lookup path for root %llu - %s\n",
|
||||||
|
+ (unsigned long long)ri->ref_tree,
|
||||||
|
+ strerror(e));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -320,15 +322,18 @@ static u64 find_root_gen(int fd)
|
||||||
|
unsigned long off = 0;
|
||||||
|
u64 max_found = 0;
|
||||||
|
int i;
|
||||||
|
+ int e;
|
||||||
|
|
||||||
|
memset(&ino_args, 0, sizeof(ino_args));
|
||||||
|
ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
||||||
|
|
||||||
|
/* this ioctl fills in ino_args->treeid */
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret) {
|
||||||
|
- fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n",
|
||||||
|
- (unsigned long long)BTRFS_FIRST_FREE_OBJECTID);
|
||||||
|
+ fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n",
|
||||||
|
+ (unsigned long long)BTRFS_FIRST_FREE_OBJECTID,
|
||||||
|
+ strerror(e));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -351,8 +356,10 @@ static u64 find_root_gen(int fd)
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret < 0) {
|
||||||
|
- fprintf(stderr, "ERROR: can't perform the search\n");
|
||||||
|
+ fprintf(stderr, "ERROR: can't perform the search - %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* the ioctl returns the number of item it found in nr_items */
|
||||||
|
@@ -407,14 +414,16 @@ static char *__ino_resolve(int fd, u64 dirid)
|
||||||
|
struct btrfs_ioctl_ino_lookup_args args;
|
||||||
|
int ret;
|
||||||
|
char *full;
|
||||||
|
+ int e;
|
||||||
|
|
||||||
|
memset(&args, 0, sizeof(args));
|
||||||
|
args.objectid = dirid;
|
||||||
|
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret) {
|
||||||
|
- fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n",
|
||||||
|
- (unsigned long long)dirid);
|
||||||
|
+ fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n",
|
||||||
|
+ (unsigned long long)dirid, strerror(e) );
|
||||||
|
return ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -472,6 +481,7 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name)
|
||||||
|
struct btrfs_ioctl_search_header *sh;
|
||||||
|
unsigned long off = 0;
|
||||||
|
int namelen;
|
||||||
|
+ int e;
|
||||||
|
|
||||||
|
memset(&args, 0, sizeof(args));
|
||||||
|
|
||||||
|
@@ -490,8 +500,10 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name)
|
||||||
|
sk->nr_items = 1;
|
||||||
|
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret < 0) {
|
||||||
|
- fprintf(stderr, "ERROR: can't perform the search\n");
|
||||||
|
+ fprintf(stderr, "ERROR: can't perform the search - %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* the ioctl returns the number of item it found in nr_items */
|
||||||
|
@@ -550,6 +562,7 @@ int list_subvols(int fd)
|
||||||
|
char *name;
|
||||||
|
u64 dir_id;
|
||||||
|
int i;
|
||||||
|
+ int e;
|
||||||
|
|
||||||
|
root_lookup_init(&root_lookup);
|
||||||
|
|
||||||
|
@@ -578,8 +591,10 @@ int list_subvols(int fd)
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret < 0) {
|
||||||
|
- fprintf(stderr, "ERROR: can't perform the search\n");
|
||||||
|
+ fprintf(stderr, "ERROR: can't perform the search - %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/* the ioctl returns the number of item it found in nr_items */
|
||||||
|
@@ -747,6 +762,7 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen)
|
||||||
|
u64 found_gen;
|
||||||
|
u64 max_found = 0;
|
||||||
|
int i;
|
||||||
|
+ int e;
|
||||||
|
u64 cache_dirid = 0;
|
||||||
|
u64 cache_ino = 0;
|
||||||
|
char *cache_dir_name = NULL;
|
||||||
|
@@ -773,8 +789,10 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen)
|
||||||
|
max_found = find_root_gen(fd);
|
||||||
|
while(1) {
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret < 0) {
|
||||||
|
- fprintf(stderr, "ERROR: can't perform the search\n");
|
||||||
|
+ fprintf(stderr, "ERROR: can't perform the search- %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
/* the ioctl returns the number of item it found in nr_items */
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index fffb423..775bfe1 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -156,6 +156,7 @@ int do_defrag(int ac, char **av)
|
||||||
|
int verbose = 0;
|
||||||
|
int fancy_ioctl = 0;
|
||||||
|
struct btrfs_ioctl_defrag_range_args range;
|
||||||
|
+ int e=0;
|
||||||
|
|
||||||
|
optind = 1;
|
||||||
|
while(1) {
|
||||||
|
@@ -219,19 +220,21 @@ int do_defrag(int ac, char **av)
|
||||||
|
}
|
||||||
|
if (!fancy_ioctl) {
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_DEFRAG, NULL);
|
||||||
|
+ e=errno;
|
||||||
|
} else {
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE, &range);
|
||||||
|
if (ret && errno == ENOTTY) {
|
||||||
|
- fprintf(stderr, "defrag range ioctl not "
|
||||||
|
+ fprintf(stderr, "ERROR: defrag range ioctl not "
|
||||||
|
"supported in this kernel, please try "
|
||||||
|
"without any options.\n");
|
||||||
|
errors++;
|
||||||
|
+ close(fd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret) {
|
||||||
|
- fprintf(stderr, "ioctl failed on %s ret %d errno %d\n",
|
||||||
|
- av[i], ret, errno);
|
||||||
|
+ fprintf(stderr, "ERROR: defrag failed on %s - %s\n",
|
||||||
|
+ av[i], strerror(e));
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
@@ -310,7 +313,7 @@ int do_subvol_list(int argc, char **argv)
|
||||||
|
int do_clone(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *subvol, *dst;
|
||||||
|
- int res, fd, fddst, len;
|
||||||
|
+ int res, fd, fddst, len, e;
|
||||||
|
char *newname;
|
||||||
|
char *dstdir;
|
||||||
|
|
||||||
|
@@ -377,12 +380,14 @@ int do_clone(int argc, char **argv)
|
||||||
|
args.fd = fd;
|
||||||
|
strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args);
|
||||||
|
+ e = errno;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
close(fddst);
|
||||||
|
|
||||||
|
if(res < 0 ){
|
||||||
|
- fprintf( stderr, "ERROR: cannot snapshot '%s'\n",subvol);
|
||||||
|
+ fprintf( stderr, "ERROR: cannot snapshot '%s' - %s\n",
|
||||||
|
+ subvol, strerror(e));
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -392,7 +397,7 @@ int do_clone(int argc, char **argv)
|
||||||
|
|
||||||
|
int do_delete_subvolume(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- int res, fd, len;
|
||||||
|
+ int res, fd, len, e;
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
char *dname, *vname, *cpath;
|
||||||
|
char *path = argv[1];
|
||||||
|
@@ -438,11 +443,13 @@ int do_delete_subvolume(int argc, char **argv)
|
||||||
|
printf("Delete subvolume '%s/%s'\n", dname, vname);
|
||||||
|
strncpy(args.name, vname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args);
|
||||||
|
+ e = errno;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if(res < 0 ){
|
||||||
|
- fprintf( stderr, "ERROR: cannot delete '%s/%s'\n",dname, vname);
|
||||||
|
+ fprintf( stderr, "ERROR: cannot delete '%s/%s' - %s\n",
|
||||||
|
+ dname, vname, strerror(e));
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -452,7 +459,7 @@ int do_delete_subvolume(int argc, char **argv)
|
||||||
|
|
||||||
|
int do_create_subvol(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- int res, fddst, len;
|
||||||
|
+ int res, fddst, len, e;
|
||||||
|
char *newname;
|
||||||
|
char *dstdir;
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
@@ -492,11 +499,13 @@ int do_create_subvol(int argc, char **argv)
|
||||||
|
printf("Create subvolume '%s/%s'\n", dstdir, newname);
|
||||||
|
strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args);
|
||||||
|
+ e = errno;
|
||||||
|
|
||||||
|
close(fddst);
|
||||||
|
|
||||||
|
if(res < 0 ){
|
||||||
|
- fprintf( stderr, "ERROR: cannot create subvolume\n");
|
||||||
|
+ fprintf( stderr, "ERROR: cannot create subvolume - %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -506,7 +515,7 @@ int do_create_subvol(int argc, char **argv)
|
||||||
|
|
||||||
|
int do_fssync(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- int fd, res;
|
||||||
|
+ int fd, res, e;
|
||||||
|
char *path = argv[1];
|
||||||
|
|
||||||
|
fd = open_file_or_dir(path);
|
||||||
|
@@ -517,9 +526,11 @@ int do_fssync(int argc, char **argv)
|
||||||
|
|
||||||
|
printf("FSSync '%s'\n", path);
|
||||||
|
res = ioctl(fd, BTRFS_IOC_SYNC);
|
||||||
|
+ e = errno;
|
||||||
|
close(fd);
|
||||||
|
if( res < 0 ){
|
||||||
|
- fprintf(stderr, "ERROR: unable to fs-syncing '%s'\n", path);
|
||||||
|
+ fprintf(stderr, "ERROR: unable to fs-syncing '%s' - %s\n",
|
||||||
|
+ path, strerror(e));
|
||||||
|
return 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -528,7 +539,7 @@ int do_fssync(int argc, char **argv)
|
||||||
|
|
||||||
|
int do_scan(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- int i, fd;
|
||||||
|
+ int i, fd, e;
|
||||||
|
if(argc<=1){
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
@@ -560,10 +571,12 @@ int do_scan(int argc, char **argv)
|
||||||
|
* a btrfs filesystem from an I/O error !!!
|
||||||
|
*/
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
|
||||||
|
+ e = errno;
|
||||||
|
|
||||||
|
if( ret < 0 ){
|
||||||
|
close(fd);
|
||||||
|
- fprintf(stderr, "ERROR: unable to scan the device '%s'\n", argv[i]);
|
||||||
|
+ fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
|
||||||
|
+ argv[i], strerror(e));
|
||||||
|
return 11;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -577,7 +590,7 @@ int do_resize(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
- int fd, res, len;
|
||||||
|
+ int fd, res, len, e;
|
||||||
|
char *amount=argv[1], *path=argv[2];
|
||||||
|
|
||||||
|
fd = open_file_or_dir(path);
|
||||||
|
@@ -595,9 +608,11 @@ int do_resize(int argc, char **argv)
|
||||||
|
printf("Resize '%s' of '%s'\n", path, amount);
|
||||||
|
strncpy(args.name, amount, BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fd, BTRFS_IOC_RESIZE, &args);
|
||||||
|
+ e = errno;
|
||||||
|
close(fd);
|
||||||
|
if( res < 0 ){
|
||||||
|
- fprintf(stderr, "ERROR: unable to resize '%s'\n", path);
|
||||||
|
+ fprintf(stderr, "ERROR: unable to resize '%s' - %s\n",
|
||||||
|
+ path, strerror(e));
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
@@ -691,7 +706,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
{
|
||||||
|
|
||||||
|
char *mntpnt = args[nargs-1];
|
||||||
|
- int i, fdmnt, ret=0;
|
||||||
|
+ int i, fdmnt, ret=0, e;
|
||||||
|
|
||||||
|
|
||||||
|
fdmnt = open_file_or_dir(mntpnt);
|
||||||
|
@@ -738,8 +753,10 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
|
||||||
|
strncpy(ioctl_args.name, args[i], BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
|
||||||
|
+ e = errno;
|
||||||
|
if(res<0){
|
||||||
|
- fprintf(stderr, "ERROR: error adding the device '%s'\n", args[i]);
|
||||||
|
+ fprintf(stderr, "ERROR: error adding the device '%s' - %s\n",
|
||||||
|
+ args[i], strerror(e));
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -756,7 +773,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
int do_balance(int argc, char **argv)
|
||||||
|
{
|
||||||
|
|
||||||
|
- int fdmnt, ret=0;
|
||||||
|
+ int fdmnt, ret=0, e;
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
char *path = argv[1];
|
||||||
|
|
||||||
|
@@ -768,9 +785,11 @@ int do_balance(int argc, char **argv)
|
||||||
|
|
||||||
|
memset(&args, 0, sizeof(args));
|
||||||
|
ret = ioctl(fdmnt, BTRFS_IOC_BALANCE, &args);
|
||||||
|
+ e = errno;
|
||||||
|
close(fdmnt);
|
||||||
|
if(ret<0){
|
||||||
|
- fprintf(stderr, "ERROR: balancing '%s'\n", path);
|
||||||
|
+ fprintf(stderr, "ERROR: error during balancing '%s' - %s\n",
|
||||||
|
+ path, strerror(e));
|
||||||
|
|
||||||
|
return 19;
|
||||||
|
}
|
||||||
|
@@ -780,7 +799,7 @@ int do_remove_volume(int nargs, char **args)
|
||||||
|
{
|
||||||
|
|
||||||
|
char *mntpnt = args[nargs-1];
|
||||||
|
- int i, fdmnt, ret=0;
|
||||||
|
+ int i, fdmnt, ret=0, e;
|
||||||
|
|
||||||
|
fdmnt = open_file_or_dir(mntpnt);
|
||||||
|
if (fdmnt < 0) {
|
||||||
|
@@ -794,8 +813,10 @@ int do_remove_volume(int nargs, char **args)
|
||||||
|
|
||||||
|
strncpy(arg.name, args[i], BTRFS_PATH_NAME_MAX);
|
||||||
|
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
|
||||||
|
+ e = errno;
|
||||||
|
if(res<0){
|
||||||
|
- fprintf(stderr, "ERROR: error removing the device '%s'\n", args[i]);
|
||||||
|
+ fprintf(stderr, "ERROR: error removing the device '%s' - %s\n",
|
||||||
|
+ args[i], strerror(e));
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -809,7 +830,7 @@ int do_remove_volume(int nargs, char **args)
|
||||||
|
|
||||||
|
int do_set_default_subvol(int nargs, char **argv)
|
||||||
|
{
|
||||||
|
- int ret=0, fd;
|
||||||
|
+ int ret=0, fd, e;
|
||||||
|
u64 objectid;
|
||||||
|
char *path = argv[2];
|
||||||
|
char *subvolid = argv[1];
|
||||||
|
@@ -826,9 +847,11 @@ int do_set_default_subvol(int nargs, char **argv)
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
|
||||||
|
+ e = errno;
|
||||||
|
close(fd);
|
||||||
|
if( ret < 0 ){
|
||||||
|
- fprintf(stderr, "ERROR: unable to set a new default subvolume\n");
|
||||||
|
+ fprintf(stderr, "ERROR: unable to set a new default subvolume - %s\n",
|
||||||
|
+ strerror(e));
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
@@ -840,6 +863,7 @@ int do_df_filesystem(int nargs, char **argv)
|
||||||
|
u64 count = 0, i;
|
||||||
|
int ret;
|
||||||
|
int fd;
|
||||||
|
+ int e;
|
||||||
|
char *path = argv[1];
|
||||||
|
|
||||||
|
fd = open_file_or_dir(path);
|
||||||
|
@@ -856,7 +880,10 @@ int do_df_filesystem(int nargs, char **argv)
|
||||||
|
sargs->total_spaces = 0;
|
||||||
|
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret) {
|
||||||
|
+ fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n",
|
||||||
|
+ path, strerror(e));
|
||||||
|
free(sargs);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -874,7 +901,11 @@ int do_df_filesystem(int nargs, char **argv)
|
||||||
|
sargs->total_spaces = 0;
|
||||||
|
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
|
||||||
|
+ e = errno;
|
||||||
|
if (ret) {
|
||||||
|
+ fprintf(stderr, "ERROR: couldn't get space info on '%s' - %s\n",
|
||||||
|
+ path, strerror(e));
|
||||||
|
+ close(fd);
|
||||||
|
free(sargs);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index d8c3dcc..2a15d86 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -821,6 +821,7 @@ void btrfs_register_one_device(char *fname)
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
int fd;
|
||||||
|
int ret;
|
||||||
|
+ int e;
|
||||||
|
|
||||||
|
fd = open("/dev/btrfs-control", O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
@@ -830,6 +831,11 @@ void btrfs_register_one_device(char *fname)
|
||||||
|
}
|
||||||
|
strncpy(args.name, fname, BTRFS_PATH_NAME_MAX);
|
||||||
|
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
|
||||||
|
+ e = errno;
|
||||||
|
+ if(ret<0){
|
||||||
|
+ fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
|
||||||
|
+ fname, strerror(e));
|
||||||
|
+ }
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
56
0006-Btrfs-progs-update-super-fields-for-space-cache.patch
Normal file
56
0006-Btrfs-progs-update-super-fields-for-space-cache.patch
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
From c2cefc42ebf8e32e36b1866048a02a579f2cef9a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Josef Bacik <josef@redhat.com>
|
||||||
|
Date: Thu, 9 Dec 2010 18:27:03 +0000
|
||||||
|
Subject: [PATCH 06/15] Btrfs-progs: update super fields for space cache
|
||||||
|
|
||||||
|
This patch updates the super field to add the cache_generation member. It also
|
||||||
|
makes us set it to -1 on mkfs so any new filesystem will get the space cache
|
||||||
|
stuff turned on. Thanks,
|
||||||
|
|
||||||
|
Signed-off-by: Josef Bacik <josef@redhat.com>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
ctree.h | 6 +++++-
|
||||||
|
utils.c | 1 +
|
||||||
|
2 files changed, 6 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ctree.h b/ctree.h
|
||||||
|
index b79e238..962c510 100644
|
||||||
|
--- a/ctree.h
|
||||||
|
+++ b/ctree.h
|
||||||
|
@@ -340,8 +340,10 @@ struct btrfs_super_block {
|
||||||
|
|
||||||
|
char label[BTRFS_LABEL_SIZE];
|
||||||
|
|
||||||
|
+ __le64 cache_generation;
|
||||||
|
+
|
||||||
|
/* future expansion */
|
||||||
|
- __le64 reserved[32];
|
||||||
|
+ __le64 reserved[31];
|
||||||
|
u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
|
||||||
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
|
@@ -1564,6 +1566,8 @@ BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block,
|
||||||
|
incompat_flags, 64);
|
||||||
|
BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block,
|
||||||
|
csum_type, 16);
|
||||||
|
+BTRFS_SETGET_STACK_FUNCS(super_cache_generation, struct btrfs_super_block,
|
||||||
|
+ cache_generation, 64);
|
||||||
|
|
||||||
|
static inline int btrfs_super_csum_size(struct btrfs_super_block *s)
|
||||||
|
{
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 2a15d86..35e17b8 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -107,6 +107,7 @@ int make_btrfs(int fd, const char *device, const char *label,
|
||||||
|
btrfs_set_super_stripesize(&super, stripesize);
|
||||||
|
btrfs_set_super_csum_type(&super, BTRFS_CSUM_TYPE_CRC32);
|
||||||
|
btrfs_set_super_chunk_root_generation(&super, 1);
|
||||||
|
+ btrfs_set_super_cache_generation(&super, -1);
|
||||||
|
if (label)
|
||||||
|
strncpy(super.label, label, BTRFS_LABEL_SIZE - 1);
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
403
0007-Btrfs-progs-add-support-for-mixed-data-metadata-bloc.patch
Normal file
403
0007-Btrfs-progs-add-support-for-mixed-data-metadata-bloc.patch
Normal file
@ -0,0 +1,403 @@
|
|||||||
|
From e7ef1f26a25d06d5606934dced7b52f3e33f1d33 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Josef Bacik <josef@redhat.com>
|
||||||
|
Date: Thu, 9 Dec 2010 18:31:08 +0000
|
||||||
|
Subject: [PATCH 07/15] Btrfs-progs: add support for mixed data+metadata block
|
||||||
|
groups
|
||||||
|
|
||||||
|
So alot of crazy people (I'm looking at you Meego) want to use btrfs on phones
|
||||||
|
and such with small devices. Unfortunately the way we split out metadata/data
|
||||||
|
chunks it makes space usage inefficient for volumes that are smaller than
|
||||||
|
1gigabyte. So add a -M option for mixing metadata+data, and default to this
|
||||||
|
mixed mode if the filesystem is less than or equal to 1 gigabyte. I've tested
|
||||||
|
this with xfstests on a 100mb filesystem and everything is a-ok.
|
||||||
|
|
||||||
|
Signed-off-by: Josef Bacik <josef@redhat.com>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs-vol.c | 4 +-
|
||||||
|
btrfs_cmds.c | 13 +++++-
|
||||||
|
ctree.h | 10 +++--
|
||||||
|
mkfs.c | 122 +++++++++++++++++++++++++++++++++++++++++-----------------
|
||||||
|
utils.c | 10 ++--
|
||||||
|
utils.h | 2 +-
|
||||||
|
6 files changed, 112 insertions(+), 49 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-vol.c b/btrfs-vol.c
|
||||||
|
index 4ed799d..f573023 100644
|
||||||
|
--- a/btrfs-vol.c
|
||||||
|
+++ b/btrfs-vol.c
|
||||||
|
@@ -143,7 +143,9 @@ int main(int ac, char **av)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (cmd == BTRFS_IOC_ADD_DEV) {
|
||||||
|
- ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count);
|
||||||
|
+ int mixed = 0;
|
||||||
|
+
|
||||||
|
+ ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count, &mixed);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "Unable to init %s\n", device);
|
||||||
|
exit(1);
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 775bfe1..c21a007 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -720,6 +720,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
int devfd, res;
|
||||||
|
u64 dev_block_count = 0;
|
||||||
|
struct stat st;
|
||||||
|
+ int mixed = 0;
|
||||||
|
|
||||||
|
devfd = open(args[i], O_RDWR);
|
||||||
|
if (!devfd) {
|
||||||
|
@@ -742,7 +743,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
- res = btrfs_prepare_device(devfd, args[i], 1, &dev_block_count);
|
||||||
|
+ res = btrfs_prepare_device(devfd, args[i], 1, &dev_block_count, &mixed);
|
||||||
|
if (res) {
|
||||||
|
fprintf(stderr, "ERROR: Unable to init '%s'\n", args[i]);
|
||||||
|
close(devfd);
|
||||||
|
@@ -920,8 +921,14 @@ int do_df_filesystem(int nargs, char **argv)
|
||||||
|
memset(description, 0, 80);
|
||||||
|
|
||||||
|
if (flags & BTRFS_BLOCK_GROUP_DATA) {
|
||||||
|
- snprintf(description, 5, "%s", "Data");
|
||||||
|
- written += 4;
|
||||||
|
+ if (flags & BTRFS_BLOCK_GROUP_METADATA) {
|
||||||
|
+ snprintf(description, 15, "%s",
|
||||||
|
+ "Data+Metadata");
|
||||||
|
+ written += 14;
|
||||||
|
+ } else {
|
||||||
|
+ snprintf(description, 5, "%s", "Data");
|
||||||
|
+ written += 4;
|
||||||
|
+ }
|
||||||
|
} else if (flags & BTRFS_BLOCK_GROUP_SYSTEM) {
|
||||||
|
snprintf(description, 7, "%s", "System");
|
||||||
|
written += 6;
|
||||||
|
diff --git a/ctree.h b/ctree.h
|
||||||
|
index 962c510..ed83d02 100644
|
||||||
|
--- a/ctree.h
|
||||||
|
+++ b/ctree.h
|
||||||
|
@@ -352,13 +352,15 @@ struct btrfs_super_block {
|
||||||
|
* ones specified below then we will fail to mount
|
||||||
|
*/
|
||||||
|
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
|
||||||
|
-#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (2ULL << 0)
|
||||||
|
+#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
|
||||||
|
+#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
|
||||||
|
|
||||||
|
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
|
||||||
|
#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
|
||||||
|
-#define BTRFS_FEATURE_INCOMPAT_SUPP \
|
||||||
|
- (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
|
||||||
|
- BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL)
|
||||||
|
+#define BTRFS_FEATURE_INCOMPAT_SUPP \
|
||||||
|
+ (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
|
||||||
|
+ BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
|
||||||
|
+ BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A leaf is full of items. offset and size tell us where to find
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 2e99b95..04de93a 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -69,7 +69,7 @@ static u64 parse_size(char *s)
|
||||||
|
return atol(s) * mult;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int make_root_dir(struct btrfs_root *root)
|
||||||
|
+static int make_root_dir(struct btrfs_root *root, int mixed)
|
||||||
|
{
|
||||||
|
struct btrfs_trans_handle *trans;
|
||||||
|
struct btrfs_key location;
|
||||||
|
@@ -88,30 +88,47 @@ static int make_root_dir(struct btrfs_root *root)
|
||||||
|
0, BTRFS_MKFS_SYSTEM_GROUP_SIZE);
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
- ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
|
||||||
|
- &chunk_start, &chunk_size,
|
||||||
|
- BTRFS_BLOCK_GROUP_METADATA);
|
||||||
|
- BUG_ON(ret);
|
||||||
|
- ret = btrfs_make_block_group(trans, root, 0,
|
||||||
|
- BTRFS_BLOCK_GROUP_METADATA,
|
||||||
|
- BTRFS_FIRST_CHUNK_TREE_OBJECTID,
|
||||||
|
- chunk_start, chunk_size);
|
||||||
|
- BUG_ON(ret);
|
||||||
|
+ if (mixed) {
|
||||||
|
+ ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
|
||||||
|
+ &chunk_start, &chunk_size,
|
||||||
|
+ BTRFS_BLOCK_GROUP_METADATA |
|
||||||
|
+ BTRFS_BLOCK_GROUP_DATA);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ ret = btrfs_make_block_group(trans, root, 0,
|
||||||
|
+ BTRFS_BLOCK_GROUP_METADATA |
|
||||||
|
+ BTRFS_BLOCK_GROUP_DATA,
|
||||||
|
+ BTRFS_FIRST_CHUNK_TREE_OBJECTID,
|
||||||
|
+ chunk_start, chunk_size);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ printf("Created a data/metadata chunk of size %llu\n", chunk_size);
|
||||||
|
+ } else {
|
||||||
|
+ ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
|
||||||
|
+ &chunk_start, &chunk_size,
|
||||||
|
+ BTRFS_BLOCK_GROUP_METADATA);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ ret = btrfs_make_block_group(trans, root, 0,
|
||||||
|
+ BTRFS_BLOCK_GROUP_METADATA,
|
||||||
|
+ BTRFS_FIRST_CHUNK_TREE_OBJECTID,
|
||||||
|
+ chunk_start, chunk_size);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
root->fs_info->system_allocs = 0;
|
||||||
|
btrfs_commit_transaction(trans, root);
|
||||||
|
trans = btrfs_start_transaction(root, 1);
|
||||||
|
BUG_ON(!trans);
|
||||||
|
|
||||||
|
- ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
|
||||||
|
- &chunk_start, &chunk_size,
|
||||||
|
- BTRFS_BLOCK_GROUP_DATA);
|
||||||
|
- BUG_ON(ret);
|
||||||
|
- ret = btrfs_make_block_group(trans, root, 0,
|
||||||
|
- BTRFS_BLOCK_GROUP_DATA,
|
||||||
|
- BTRFS_FIRST_CHUNK_TREE_OBJECTID,
|
||||||
|
- chunk_start, chunk_size);
|
||||||
|
- BUG_ON(ret);
|
||||||
|
+ if (!mixed) {
|
||||||
|
+ ret = btrfs_alloc_chunk(trans, root->fs_info->extent_root,
|
||||||
|
+ &chunk_start, &chunk_size,
|
||||||
|
+ BTRFS_BLOCK_GROUP_DATA);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ ret = btrfs_make_block_group(trans, root, 0,
|
||||||
|
+ BTRFS_BLOCK_GROUP_DATA,
|
||||||
|
+ BTRFS_FIRST_CHUNK_TREE_OBJECTID,
|
||||||
|
+ chunk_start, chunk_size);
|
||||||
|
+ BUG_ON(ret);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
ret = btrfs_make_root_dir(trans, root->fs_info->tree_root,
|
||||||
|
BTRFS_ROOT_TREE_DIR_OBJECTID);
|
||||||
|
@@ -200,7 +217,7 @@ static int create_one_raid_group(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
static int create_raid_groups(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root, u64 data_profile,
|
||||||
|
- u64 metadata_profile)
|
||||||
|
+ u64 metadata_profile, int mixed)
|
||||||
|
{
|
||||||
|
u64 num_devices = btrfs_super_num_devices(&root->fs_info->super_copy);
|
||||||
|
u64 allowed;
|
||||||
|
@@ -215,20 +232,24 @@ static int create_raid_groups(struct btrfs_trans_handle *trans,
|
||||||
|
allowed = BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1;
|
||||||
|
|
||||||
|
if (allowed & metadata_profile) {
|
||||||
|
+ u64 meta_flags = BTRFS_BLOCK_GROUP_METADATA;
|
||||||
|
+
|
||||||
|
ret = create_one_raid_group(trans, root,
|
||||||
|
BTRFS_BLOCK_GROUP_SYSTEM |
|
||||||
|
(allowed & metadata_profile));
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
- ret = create_one_raid_group(trans, root,
|
||||||
|
- BTRFS_BLOCK_GROUP_METADATA |
|
||||||
|
+ if (mixed)
|
||||||
|
+ meta_flags |= BTRFS_BLOCK_GROUP_DATA;
|
||||||
|
+
|
||||||
|
+ ret = create_one_raid_group(trans, root, meta_flags |
|
||||||
|
(allowed & metadata_profile));
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
ret = recow_roots(trans, root);
|
||||||
|
BUG_ON(ret);
|
||||||
|
}
|
||||||
|
- if (num_devices > 1 && (allowed & data_profile)) {
|
||||||
|
+ if (!mixed && num_devices > 1 && (allowed & data_profile)) {
|
||||||
|
ret = create_one_raid_group(trans, root,
|
||||||
|
BTRFS_BLOCK_GROUP_DATA |
|
||||||
|
(allowed & data_profile));
|
||||||
|
@@ -274,6 +295,7 @@ static void print_usage(void)
|
||||||
|
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");
|
||||||
|
+ fprintf(stderr, "\t -M --mixed mix metadata and data together\n");
|
||||||
|
fprintf(stderr, "\t -n --nodesize size of btree nodes\n");
|
||||||
|
fprintf(stderr, "\t -s --sectorsize min block allocation\n");
|
||||||
|
fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
|
||||||
|
@@ -328,6 +350,7 @@ static struct option long_options[] = {
|
||||||
|
{ "leafsize", 1, NULL, 'l' },
|
||||||
|
{ "label", 1, NULL, 'L'},
|
||||||
|
{ "metadata", 1, NULL, 'm' },
|
||||||
|
+ { "mixed", 0, NULL, 'M' },
|
||||||
|
{ "nodesize", 1, NULL, 'n' },
|
||||||
|
{ "sectorsize", 1, NULL, 's' },
|
||||||
|
{ "data", 1, NULL, 'd' },
|
||||||
|
@@ -358,10 +381,13 @@ int main(int ac, char **av)
|
||||||
|
int first_fd;
|
||||||
|
int ret;
|
||||||
|
int i;
|
||||||
|
+ int mixed = 0;
|
||||||
|
+ int data_profile_opt = 0;
|
||||||
|
+ int metadata_profile_opt = 0;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
int c;
|
||||||
|
- c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:V", long_options,
|
||||||
|
+ c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:VM", long_options,
|
||||||
|
&option_index);
|
||||||
|
if (c < 0)
|
||||||
|
break;
|
||||||
|
@@ -371,6 +397,7 @@ int main(int ac, char **av)
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
data_profile = parse_profile(optarg);
|
||||||
|
+ data_profile_opt = 1;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
leafsize = parse_size(optarg);
|
||||||
|
@@ -380,6 +407,10 @@ int main(int ac, char **av)
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
metadata_profile = parse_profile(optarg);
|
||||||
|
+ metadata_profile_opt = 1;
|
||||||
|
+ break;
|
||||||
|
+ case 'M':
|
||||||
|
+ mixed = 1;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
nodesize = parse_size(optarg);
|
||||||
|
@@ -389,12 +420,10 @@ int main(int ac, char **av)
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
block_count = parse_size(optarg);
|
||||||
|
- if (block_count < 256*1024*1024) {
|
||||||
|
- fprintf(stderr, "File system size "
|
||||||
|
- "%llu bytes is too small, "
|
||||||
|
- "256M is required at least\n",
|
||||||
|
- (unsigned long long)block_count);
|
||||||
|
- exit(1);
|
||||||
|
+ if (block_count <= 1024*1024*1024) {
|
||||||
|
+ printf("SMALL VOLUME: forcing mixed "
|
||||||
|
+ "metadata/data groups\n");
|
||||||
|
+ mixed = 1;
|
||||||
|
}
|
||||||
|
zero_end = 0;
|
||||||
|
break;
|
||||||
|
@@ -439,9 +468,22 @@ int main(int ac, char **av)
|
||||||
|
}
|
||||||
|
first_fd = fd;
|
||||||
|
first_file = file;
|
||||||
|
- ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count);
|
||||||
|
+ ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
|
||||||
|
+ &mixed);
|
||||||
|
if (block_count == 0)
|
||||||
|
block_count = dev_block_count;
|
||||||
|
+ if (mixed) {
|
||||||
|
+ if (!metadata_profile_opt)
|
||||||
|
+ metadata_profile = 0;
|
||||||
|
+ if (!data_profile_opt)
|
||||||
|
+ data_profile = 0;
|
||||||
|
+
|
||||||
|
+ if (metadata_profile != data_profile) {
|
||||||
|
+ fprintf(stderr, "With mixed block groups data and metadata "
|
||||||
|
+ "profiles must be the same\n");
|
||||||
|
+ exit(1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
blocks[0] = BTRFS_SUPER_INFO_OFFSET;
|
||||||
|
for (i = 1; i < 7; i++) {
|
||||||
|
@@ -459,7 +501,7 @@ int main(int ac, char **av)
|
||||||
|
root = open_ctree(file, 0, O_RDWR);
|
||||||
|
root->fs_info->alloc_start = alloc_start;
|
||||||
|
|
||||||
|
- ret = make_root_dir(root);
|
||||||
|
+ ret = make_root_dir(root, mixed);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "failed to setup the root directory\n");
|
||||||
|
exit(1);
|
||||||
|
@@ -478,6 +520,8 @@ int main(int ac, char **av)
|
||||||
|
|
||||||
|
zero_end = 1;
|
||||||
|
while(ac-- > 0) {
|
||||||
|
+ int old_mixed = mixed;
|
||||||
|
+
|
||||||
|
file = av[optind++];
|
||||||
|
ret = check_mounted(file);
|
||||||
|
if (ret < 0) {
|
||||||
|
@@ -503,8 +547,8 @@ int main(int ac, char **av)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ret = btrfs_prepare_device(fd, file, zero_end,
|
||||||
|
- &dev_block_count);
|
||||||
|
-
|
||||||
|
+ &dev_block_count, &mixed);
|
||||||
|
+ mixed = old_mixed;
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
ret = btrfs_add_to_fsid(trans, root, fd, file, dev_block_count,
|
||||||
|
@@ -515,12 +559,20 @@ int main(int ac, char **av)
|
||||||
|
|
||||||
|
raid_groups:
|
||||||
|
ret = create_raid_groups(trans, root, data_profile,
|
||||||
|
- metadata_profile);
|
||||||
|
+ metadata_profile, mixed);
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
ret = create_data_reloc_tree(trans, root);
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
+ if (mixed) {
|
||||||
|
+ struct btrfs_super_block *super = &root->fs_info->super_copy;
|
||||||
|
+ u64 flags = btrfs_super_incompat_flags(super);
|
||||||
|
+
|
||||||
|
+ flags |= BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS;
|
||||||
|
+ btrfs_set_super_incompat_flags(super, flags);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
printf("fs created label %s on %s\n\tnodesize %u leafsize %u "
|
||||||
|
"sectorsize %u size %s\n",
|
||||||
|
label, first_file, nodesize, leafsize, sectorsize,
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 35e17b8..ad980ae 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -512,7 +512,8 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret)
|
||||||
|
+int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
||||||
|
+ int *mixed)
|
||||||
|
{
|
||||||
|
u64 block_count;
|
||||||
|
u64 bytenr;
|
||||||
|
@@ -532,10 +533,9 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret)
|
||||||
|
}
|
||||||
|
zero_end = 1;
|
||||||
|
|
||||||
|
- if (block_count < 256 * 1024 * 1024) {
|
||||||
|
- fprintf(stderr, "device %s is too small "
|
||||||
|
- "(must be at least 256 MB)\n", file);
|
||||||
|
- exit(1);
|
||||||
|
+ if (block_count < 1024 * 1024 * 1024 && !(*mixed)) {
|
||||||
|
+ printf("SMALL VOLUME: forcing mixed metadata/data groups\n");
|
||||||
|
+ *mixed = 1;
|
||||||
|
}
|
||||||
|
ret = zero_dev_start(fd);
|
||||||
|
if (ret) {
|
||||||
|
diff --git a/utils.h b/utils.h
|
||||||
|
index 9dce5b0..a28d7f4 100644
|
||||||
|
--- a/utils.h
|
||||||
|
+++ b/utils.h
|
||||||
|
@@ -27,7 +27,7 @@ int make_btrfs(int fd, const char *device, const char *label,
|
||||||
|
int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root, u64 objectid);
|
||||||
|
int btrfs_prepare_device(int fd, char *file, int zero_end,
|
||||||
|
- u64 *block_count_ret);
|
||||||
|
+ u64 *block_count_ret, int *mixed);
|
||||||
|
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root, int fd, char *path,
|
||||||
|
u64 block_count, u32 io_width, u32 io_align,
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
202
0008-Update-for-lzo-support.patch
Normal file
202
0008-Update-for-lzo-support.patch
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
From 97e64f8cb21685b7359169f3047c0d082b0ff7e8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Li Zefan <lizf@cn.fujitsu.com>
|
||||||
|
Date: Thu, 18 Nov 2010 03:49:56 +0000
|
||||||
|
Subject: [PATCH 08/15] Update for lzo support
|
||||||
|
|
||||||
|
[Btrfs-Progs][V2] Update for lzo support
|
||||||
|
|
||||||
|
- Add incompat flag, otherwise btrfs-progs will report error
|
||||||
|
when operating on btrfs filesystems mounted with lzo option.
|
||||||
|
|
||||||
|
- Update man page.
|
||||||
|
|
||||||
|
- Allow to turn on lzo compression for defrag operation:
|
||||||
|
|
||||||
|
# btrfs filesystem defragment -c[zlib, lzo] <file>
|
||||||
|
|
||||||
|
Note: "-c zlib" will fail, because that's how getopt() works
|
||||||
|
for optional arguments.
|
||||||
|
|
||||||
|
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs.c | 2 +-
|
||||||
|
btrfs_cmds.c | 24 ++++++++++++++++++++----
|
||||||
|
ctree.h | 10 +++++++---
|
||||||
|
ioctl.h | 9 ++++++++-
|
||||||
|
man/btrfs.8.in | 10 ++++++----
|
||||||
|
5 files changed, 42 insertions(+), 13 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 46314cf..1b4f403 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -65,7 +65,7 @@ static struct Command commands[] = {
|
||||||
|
"List the recently modified files in a filesystem."
|
||||||
|
},
|
||||||
|
{ do_defrag, -1,
|
||||||
|
- "filesystem defragment", "[-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
|
||||||
|
+ "filesystem defragment", "[-vf] [-c[zlib,lzo]] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
|
||||||
|
"Defragment a file or a directory."
|
||||||
|
},
|
||||||
|
{ do_set_default_subvol, 2,
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index c21a007..26d4fcc 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -142,10 +142,21 @@ static u64 parse_size(char *s)
|
||||||
|
return atoll(s) * mult;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int parse_compress_type(char *s)
|
||||||
|
+{
|
||||||
|
+ if (strcmp(optarg, "zlib") == 0)
|
||||||
|
+ return BTRFS_COMPRESS_ZLIB;
|
||||||
|
+ else if (strcmp(optarg, "lzo") == 0)
|
||||||
|
+ return BTRFS_COMPRESS_LZO;
|
||||||
|
+ else {
|
||||||
|
+ fprintf(stderr, "Unknown compress type %s\n", s);
|
||||||
|
+ exit(1);
|
||||||
|
+ };
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int do_defrag(int ac, char **av)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
- int compress = 0;
|
||||||
|
int flush = 0;
|
||||||
|
u64 start = 0;
|
||||||
|
u64 len = (u64)-1;
|
||||||
|
@@ -157,15 +168,18 @@ int do_defrag(int ac, char **av)
|
||||||
|
int fancy_ioctl = 0;
|
||||||
|
struct btrfs_ioctl_defrag_range_args range;
|
||||||
|
int e=0;
|
||||||
|
+ int compress_type = BTRFS_COMPRESS_NONE;
|
||||||
|
|
||||||
|
optind = 1;
|
||||||
|
while(1) {
|
||||||
|
- int c = getopt(ac, av, "vcfs:l:t:");
|
||||||
|
+ int c = getopt(ac, av, "vc::fs:l:t:");
|
||||||
|
if (c < 0)
|
||||||
|
break;
|
||||||
|
switch(c) {
|
||||||
|
case 'c':
|
||||||
|
- compress = 1;
|
||||||
|
+ compress_type = BTRFS_COMPRESS_ZLIB;
|
||||||
|
+ if (optarg)
|
||||||
|
+ compress_type = parse_compress_type(optarg);
|
||||||
|
fancy_ioctl = 1;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
@@ -203,8 +217,10 @@ int do_defrag(int ac, char **av)
|
||||||
|
range.start = start;
|
||||||
|
range.len = len;
|
||||||
|
range.extent_thresh = thresh;
|
||||||
|
- if (compress)
|
||||||
|
+ if (compress_type) {
|
||||||
|
range.flags |= BTRFS_DEFRAG_RANGE_COMPRESS;
|
||||||
|
+ range.compress_type = compress_type;
|
||||||
|
+ }
|
||||||
|
if (flush)
|
||||||
|
range.flags |= BTRFS_DEFRAG_RANGE_START_IO;
|
||||||
|
|
||||||
|
diff --git a/ctree.h b/ctree.h
|
||||||
|
index ed83d02..61eb639 100644
|
||||||
|
--- a/ctree.h
|
||||||
|
+++ b/ctree.h
|
||||||
|
@@ -354,12 +354,14 @@ struct btrfs_super_block {
|
||||||
|
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
|
||||||
|
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
|
||||||
|
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
|
||||||
|
+#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
|
||||||
|
|
||||||
|
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
|
||||||
|
#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
|
||||||
|
#define BTRFS_FEATURE_INCOMPAT_SUPP \
|
||||||
|
(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
|
||||||
|
BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
|
||||||
|
+ BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
|
||||||
|
BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -505,9 +507,11 @@ struct btrfs_timespec {
|
||||||
|
} __attribute__ ((__packed__));
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
- BTRFS_COMPRESS_NONE = 0,
|
||||||
|
- BTRFS_COMPRESS_ZLIB = 1,
|
||||||
|
- BTRFS_COMPRESS_LAST = 2,
|
||||||
|
+ BTRFS_COMPRESS_NONE = 0,
|
||||||
|
+ BTRFS_COMPRESS_ZLIB = 1,
|
||||||
|
+ BTRFS_COMPRESS_LZO = 2,
|
||||||
|
+ BTRFS_COMPRESS_TYPES = 2,
|
||||||
|
+ BTRFS_COMPRESS_LAST = 3,
|
||||||
|
} btrfs_compression_type;
|
||||||
|
|
||||||
|
/* we don't understand any encryption methods right now */
|
||||||
|
diff --git a/ioctl.h b/ioctl.h
|
||||||
|
index 776d7a9..bb7b9e0 100644
|
||||||
|
--- a/ioctl.h
|
||||||
|
+++ b/ioctl.h
|
||||||
|
@@ -116,8 +116,15 @@ struct btrfs_ioctl_defrag_range_args {
|
||||||
|
*/
|
||||||
|
__u32 extent_thresh;
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * which compression method to use if turning on compression
|
||||||
|
+ * for this defrag operation. If unspecified, zlib will
|
||||||
|
+ * be used
|
||||||
|
+ */
|
||||||
|
+ __u32 compress_type;
|
||||||
|
+
|
||||||
|
/* spare for later */
|
||||||
|
- __u32 unused[5];
|
||||||
|
+ __u32 unused[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct btrfs_ioctl_space_info {
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index cba2de1..1ffed13 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -15,12 +15,12 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBsubvolume set-default\fP\fI <id> <path>\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
-.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem sync\fP\fI <path> \fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem resize\fP\fI [+/\-]<size>[gkm]|max <filesystem>\fP
|
||||||
|
.PP
|
||||||
|
+\fBbtrfs\fP \fBfilesystem defrag\fP\fI [options] <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
+.PP
|
||||||
|
\fBbtrfs\fP \fBdevice scan\fP\fI [<device> [<device>..]]\fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBdevice show\fP\fI <dev>|<label> [<dev>|<label>...]\fP
|
||||||
|
@@ -30,7 +30,6 @@ btrfs \- control a btrfs filesystem
|
||||||
|
\fBbtrfs\fP \fBdevice add\fP\fI <dev> [<dev>..] <path> \fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBdevice delete\fP\fI <dev> [<dev>..] <path> \fP]
|
||||||
|
-
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
||||||
|
.PP
|
||||||
|
@@ -104,10 +103,13 @@ Set the subvolume of the filesystem \fI<path>\fR which is mounted as
|
||||||
|
is returned by the \fBsubvolume list\fR command.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\fR
|
||||||
|
+\fBfilesystem defragment\fP -c[zlib|lzo] [-l \fIlen\fR] [-s \fIstart\fR] [-t \fIsize\fR] -[vf] <\fIfile\fR>|<\fIdir\fR> [<\fIfile\fR>|<\fIdir\fR>...]
|
||||||
|
+
|
||||||
|
Defragment file data and/or directory metadata. To defragment all files in a
|
||||||
|
directory you have to specify each one on its own or use your shell wildcards.
|
||||||
|
|
||||||
|
+The start position and the number of bytes to deframention can be specified by \fIstart\fR and \fIlen\fR. Any extent bigger than \fIthresh\fR will be considered already defragged. Use 0 to take the kernel default, and use 1 to say eveery single extent must be rewritten. You can also turn on compression in defragment operations.
|
||||||
|
+
|
||||||
|
\fB-v\fP be verbose
|
||||||
|
|
||||||
|
\fB-c\fP compress file contents while defragmenting
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
234
0009-Update-clean-up-btrfs-help-and-man-page-V2.patch
Normal file
234
0009-Update-clean-up-btrfs-help-and-man-page-V2.patch
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
From 6f81e1197015ab2dc41beec92c347919feb26967 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goffredo Baroncelli <kreijack@libero.it>
|
||||||
|
Date: Sun, 5 Dec 2010 17:47:45 +0000
|
||||||
|
Subject: [PATCH 09/15] Update/clean up btrfs help and man page V2
|
||||||
|
|
||||||
|
Hi all,
|
||||||
|
|
||||||
|
enclose you can find a patch which improves the help of the btrfs commands,
|
||||||
|
updates the INSTALL file and the btrfs (command) man page.
|
||||||
|
|
||||||
|
Regarding the help of the btrfs command:
|
||||||
|
- moved the "subvolume set-default" command in the "subvolume" commands group
|
||||||
|
- removed a wrong new line
|
||||||
|
- small tweak on the basis of Andreas suggestion
|
||||||
|
|
||||||
|
Regarding the btrfs command man page:
|
||||||
|
- renaming the command "device balance" in "filesystem balance" (thanks to
|
||||||
|
Andreas Phillipp to highlight that)
|
||||||
|
- adding the entry "subvolume find-new"
|
||||||
|
- document the switches of the command "filesystem defrag"
|
||||||
|
- document the <devid> facility of the command "filesystem resize"
|
||||||
|
- small tweak on the basis of Andreas suggestion
|
||||||
|
|
||||||
|
Regarding the INSTALL file, which was very old, I removed the reference of the
|
||||||
|
old btrfsctl utility and changed the examples using the btrfs command.
|
||||||
|
I removed the old (and now wrong) statement about the inability to delete a
|
||||||
|
subvolume/snapshot
|
||||||
|
|
||||||
|
Chris, you can pull the patch from the branch "help_cleanup" of the following
|
||||||
|
repository.
|
||||||
|
|
||||||
|
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
|
||||||
|
|
||||||
|
(or you can browse the changes at
|
||||||
|
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git/?p=btrfs-
|
||||||
|
progs-unstable-all.git;a=summary)
|
||||||
|
|
||||||
|
The patch is very simple: only updates the man page, the INSTALL file and
|
||||||
|
moves/updates some lines in the help of btrfs command. Comments are welcome.
|
||||||
|
|
||||||
|
Regards
|
||||||
|
G.Baroncelli
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
INSTALL | 29 ++++++++++++++++++++---------
|
||||||
|
btrfs.c | 24 ++++++++++++------------
|
||||||
|
man/btrfs.8.in | 29 +++++++++++++++++------------
|
||||||
|
3 files changed, 49 insertions(+), 33 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/INSTALL b/INSTALL
|
||||||
|
index 16b45a5..3840148 100644
|
||||||
|
--- a/INSTALL
|
||||||
|
+++ b/INSTALL
|
||||||
|
@@ -22,23 +22,32 @@ in the e2fsprogs sources, and is usually available as libuuid or
|
||||||
|
e2fsprogs-devel from various distros.
|
||||||
|
|
||||||
|
Building the utilities is just make ; make install. The programs go
|
||||||
|
-into /usr/local/bin. The commands available are:
|
||||||
|
+into /usr/local/bin. The mains commands available are:
|
||||||
|
|
||||||
|
mkfs.btrfs: create a filesystem
|
||||||
|
|
||||||
|
-btrfsctl: control program to create snapshots and subvolumes:
|
||||||
|
-
|
||||||
|
+btrfs: control program to create snapshots and subvolumes:
|
||||||
|
+ # mount a btrfs filesystem
|
||||||
|
mount /dev/sda2 /mnt
|
||||||
|
- btrfsctl -s new_subvol_name /mnt
|
||||||
|
- btrfsctl -s snapshot_of_default /mnt/default
|
||||||
|
- btrfsctl -s snapshot_of_new_subvol /mnt/new_subvol_name
|
||||||
|
- btrfsctl -s snapshot_of_a_snapshot /mnt/snapshot_of_new_subvol
|
||||||
|
+
|
||||||
|
+ # create a subvolume
|
||||||
|
+ btrfs subvolume create /mnt/new_subvol_name
|
||||||
|
+
|
||||||
|
+ # snapshot of a subvolume
|
||||||
|
+ btrfs subvolume snapshot /mnt/default /mnt/snapshot_of_default
|
||||||
|
+ btrfs subvolume snapshot /mnt/snapshot_of_default \
|
||||||
|
+ /mnt/snapshot_of_a_snapshot
|
||||||
|
+
|
||||||
|
+ # list of the subvolumes
|
||||||
|
ls /mnt
|
||||||
|
default snapshot_of_a_snapshot snapshot_of_new_subvol
|
||||||
|
new_subvol_name snapshot_of_default
|
||||||
|
|
||||||
|
- Snapshots and subvolumes cannot be deleted right now, but you can
|
||||||
|
- rm -rf all the files and directories inside them.
|
||||||
|
+ # removal of a subvolume or a snapshot
|
||||||
|
+ btrfs subvolume delete /mn/snapshot_of_a_snapshot
|
||||||
|
+
|
||||||
|
+ # look a the btrfs man page for further information
|
||||||
|
+ man btrfs
|
||||||
|
|
||||||
|
btrfsck: do a limited check of the FS extent trees.</li>
|
||||||
|
|
||||||
|
@@ -46,3 +55,5 @@ debug-tree: print all of the FS metadata in text form. Example:
|
||||||
|
|
||||||
|
debug-tree /dev/sda2 >& big_output_file
|
||||||
|
|
||||||
|
+
|
||||||
|
+
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 1b4f403..62140ef 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -61,6 +61,11 @@ static struct Command commands[] = {
|
||||||
|
{ do_subvol_list, 1, "subvolume list", "<path>\n"
|
||||||
|
"List the snapshot/subvolume of a filesystem."
|
||||||
|
},
|
||||||
|
+ { do_set_default_subvol, 2,
|
||||||
|
+ "subvolume set-default", "<id> <path>\n"
|
||||||
|
+ "Set the subvolume of the filesystem <path> which will be mounted\n"
|
||||||
|
+ "as default."
|
||||||
|
+ },
|
||||||
|
{ do_find_newer, 2, "subvolume find-new", "<path> <last_gen>\n"
|
||||||
|
"List the recently modified files in a filesystem."
|
||||||
|
},
|
||||||
|
@@ -68,11 +73,6 @@ static struct Command commands[] = {
|
||||||
|
"filesystem defragment", "[-vf] [-c[zlib,lzo]] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
|
||||||
|
"Defragment a file or a directory."
|
||||||
|
},
|
||||||
|
- { do_set_default_subvol, 2,
|
||||||
|
- "subvolume set-default", "<id> <path>\n"
|
||||||
|
- "Set the subvolume of the filesystem <path> which will be mounted\n"
|
||||||
|
- "as default."
|
||||||
|
- },
|
||||||
|
{ do_fssync, 1,
|
||||||
|
"filesystem sync", "<path>\n"
|
||||||
|
"Force a sync on the filesystem <path>."
|
||||||
|
@@ -83,29 +83,29 @@ static struct Command commands[] = {
|
||||||
|
"will occupe all available space on the device."
|
||||||
|
},
|
||||||
|
{ do_show_filesystem, 999,
|
||||||
|
- "filesystem show", "[<uuid>|<label>]\n"
|
||||||
|
- "Show the info of a btrfs filesystem. If no <uuid> or <label>\n"
|
||||||
|
+ "filesystem show", "[<device>|<uuid>|<label>]\n"
|
||||||
|
+ "Show the info of a btrfs filesystem. If no argument\n"
|
||||||
|
"is passed, info of all the btrfs filesystem are shown."
|
||||||
|
},
|
||||||
|
{ do_df_filesystem, 1,
|
||||||
|
"filesystem df", "<path>\n"
|
||||||
|
- "Show space usage information for a mount point\n."
|
||||||
|
+ "Show space usage information for a mount point."
|
||||||
|
},
|
||||||
|
{ do_balance, 1,
|
||||||
|
"filesystem balance", "<path>\n"
|
||||||
|
"Balance the chunks across the device."
|
||||||
|
},
|
||||||
|
- { do_scan,
|
||||||
|
- 999, "device scan", "[<device> [<device>..]\n"
|
||||||
|
+ { do_scan, 999,
|
||||||
|
+ "device scan", "[<device>...]\n"
|
||||||
|
"Scan all device for or the passed device for a btrfs\n"
|
||||||
|
"filesystem."
|
||||||
|
},
|
||||||
|
{ do_add_volume, -2,
|
||||||
|
- "device add", "<dev> [<dev>..] <path>\n"
|
||||||
|
+ "device add", "<device> [<device>...] <path>\n"
|
||||||
|
"Add a device to a filesystem."
|
||||||
|
},
|
||||||
|
{ do_remove_volume, -2,
|
||||||
|
- "device delete", "<dev> [<dev>..] <path>\n"
|
||||||
|
+ "device delete", "<device> [<device>...] <path>\n"
|
||||||
|
"Remove a device from a filesystem."
|
||||||
|
},
|
||||||
|
/* coming soon
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index 1ffed13..b9b8913 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -21,15 +21,19 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem defrag\fP\fI [options] <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice scan\fP\fI [<device> [<device>..]]\fP
|
||||||
|
+\fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice show\fP\fI <dev>|<label> [<dev>|<label>...]\fP
|
||||||
|
+\fBbtrfs\fP \fBfilesystem balance\fP\fI <path> \fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice balance\fP\fI <path> \fP
|
||||||
|
+\fBbtrfs\fP \fBfilesystem defragment\fP\fI <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice add\fP\fI <dev> [<dev>..] <path> \fP
|
||||||
|
+\fBbtrfs\fP \fBdevice scan\fP\fI [<device>...]\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice delete\fP\fI <dev> [<dev>..] <path> \fP]
|
||||||
|
+\fBbtrfs\fP \fBdevice show\fP\fI [<device>|<uuid>|<label>]\fP
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBdevice add\fP\fI <device> [<device>...] <path> \fP
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBdevice delete\fP\fI <device> [<device>...] <path> \fP]
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
||||||
|
.PP
|
||||||
|
@@ -48,17 +52,16 @@ For example: it is possible to run
|
||||||
|
instead of
|
||||||
|
.I btrfs subvolume snapshot.
|
||||||
|
But
|
||||||
|
-.I btrfs dev s
|
||||||
|
+.I btrfs file s
|
||||||
|
is not allowed, because
|
||||||
|
-.I dev s
|
||||||
|
+.I file s
|
||||||
|
may be interpreted both as
|
||||||
|
-.I device show
|
||||||
|
+.I filesystem show
|
||||||
|
and as
|
||||||
|
-.I device scan.
|
||||||
|
+.I filesystem sync.
|
||||||
|
In this case
|
||||||
|
.I btrfs
|
||||||
|
-returns an error.
|
||||||
|
-
|
||||||
|
+returnsfilesystem sync
|
||||||
|
If a command is terminated by
|
||||||
|
.I --help
|
||||||
|
, the detailed help is showed. If the passed command matches more commands,
|
||||||
|
@@ -125,9 +128,11 @@ The start position and the number of bytes to deframention can be specified by \
|
||||||
|
NOTE: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of data, don't
|
||||||
|
use it if you use snapshots, have de-duplicated your data or made copies with
|
||||||
|
\fBcp --reflink\fP.
|
||||||
|
+\fBsubvolume find-new\fR\fI <subvolume> <last_gen>\fR
|
||||||
|
+List the recently modified files in a subvolume, after \fI<last_gen>\fR ID.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBdevice scan\fR \fI[<device> [<device>..]]\fR
|
||||||
|
+\fBdevice scan\fR \fI[<device>...]\fR
|
||||||
|
Scan devices for a btrfs filesystem. If no devices are passed, \fBbtrfs\fR scans
|
||||||
|
all the block devices.
|
||||||
|
.TP
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
151
0010-Deprecate-btrfsctl-btrfs-show-btrfs-vol.patch
Normal file
151
0010-Deprecate-btrfsctl-btrfs-show-btrfs-vol.patch
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
From 36d8ab7002c5707538849a61eaa97cbac262bbc3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goffredo Baroncelli <kreijack@libero.it>
|
||||||
|
Date: Sun, 5 Dec 2010 17:47:36 +0000
|
||||||
|
Subject: [PATCH 10/15] Deprecate btrfsctl, btrfs-show, btrfs-vol
|
||||||
|
|
||||||
|
Hi all,
|
||||||
|
|
||||||
|
the patch below deprecates the following programs
|
||||||
|
|
||||||
|
* btrfsctl
|
||||||
|
* btrfs-vol
|
||||||
|
* btrfs-show
|
||||||
|
|
||||||
|
the reason is simple, these programs are superseded by the btrfs utility,
|
||||||
|
both in terms of documentation, usability and bug. The goal is to avoid
|
||||||
|
to duplicate codes and avoid update two programs.
|
||||||
|
|
||||||
|
The patch adds a warning in the man pages, in the INSTALL file and in the
|
||||||
|
programs.
|
||||||
|
|
||||||
|
$ ./btrfsctl
|
||||||
|
**
|
||||||
|
** WARNING: this program is considered deprecated
|
||||||
|
** Please consider to switch to the btrfs utility
|
||||||
|
**
|
||||||
|
no valid commands given
|
||||||
|
usage: btrfsctl [ -d file|dir] [ -s snap_name subvol|tree ]
|
||||||
|
[-r size] [-A device] [-a] [-c] [-D dir .]
|
||||||
|
-d filename: defragments one file
|
||||||
|
-d directory: defragments the entire Btree
|
||||||
|
-s snap_name dir: creates a new snapshot of dir
|
||||||
|
-S subvol_name dir: creates a new subvolume
|
||||||
|
-r [+-]size[gkm]: resize the FS by size amount
|
||||||
|
-A device: scans the device file for a Btrfs filesystem
|
||||||
|
-a: scans all devices for Btrfs filesystems
|
||||||
|
-c: forces a single FS sync
|
||||||
|
-D: delete snapshot
|
||||||
|
-m [tree id] directory: set the default mounted subvolume to the [tree
|
||||||
|
id] or the
|
||||||
|
directory
|
||||||
|
|
||||||
|
Below the patch, but it is possible to pull the changes from:
|
||||||
|
|
||||||
|
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
|
||||||
|
|
||||||
|
branch
|
||||||
|
|
||||||
|
btrfs-deprecated
|
||||||
|
|
||||||
|
Comments are welcome.
|
||||||
|
|
||||||
|
G.Baroncelli
|
||||||
|
|
||||||
|
INSTALL | 5 +++++
|
||||||
|
btrfs-show.c | 5 +++++
|
||||||
|
btrfs-vol.c | 5 +++++
|
||||||
|
btrfsctl.c | 5 +++++
|
||||||
|
man/btrfs-show.8.in | 3 +++
|
||||||
|
man/btrfsctl.8.in | 3 +++
|
||||||
|
6 files changed, 26 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
the tool to create a new snapshot for the filesystem.
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs-show.c | 5 +++++
|
||||||
|
btrfs-vol.c | 5 +++++
|
||||||
|
btrfsctl.c | 5 +++++
|
||||||
|
man/btrfs-show.8.in | 3 +++
|
||||||
|
man/btrfsctl.8.in | 3 +++
|
||||||
|
5 files changed, 21 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-show.c b/btrfs-show.c
|
||||||
|
index c49626c..8210fd2 100644
|
||||||
|
--- a/btrfs-show.c
|
||||||
|
+++ b/btrfs-show.c
|
||||||
|
@@ -117,6 +117,11 @@ int main(int ac, char **av)
|
||||||
|
int ret;
|
||||||
|
int option_index = 0;
|
||||||
|
|
||||||
|
+ printf( "**\n"
|
||||||
|
+ "** WARNING: this program is considered deprecated\n"
|
||||||
|
+ "** Please consider to switch to the btrfs utility\n"
|
||||||
|
+ "**\n");
|
||||||
|
+
|
||||||
|
while(1) {
|
||||||
|
int c;
|
||||||
|
c = getopt_long(ac, av, "", long_options,
|
||||||
|
diff --git a/btrfs-vol.c b/btrfs-vol.c
|
||||||
|
index f573023..0efdbc1 100644
|
||||||
|
--- a/btrfs-vol.c
|
||||||
|
+++ b/btrfs-vol.c
|
||||||
|
@@ -78,6 +78,11 @@ int main(int ac, char **av)
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
u64 dev_block_count = 0;
|
||||||
|
|
||||||
|
+ printf( "**\n"
|
||||||
|
+ "** WARNING: this program is considered deprecated\n"
|
||||||
|
+ "** Please consider to switch to the btrfs utility\n"
|
||||||
|
+ "**\n");
|
||||||
|
+
|
||||||
|
while(1) {
|
||||||
|
int c;
|
||||||
|
c = getopt_long(ac, av, "a:br:", long_options,
|
||||||
|
diff --git a/btrfsctl.c b/btrfsctl.c
|
||||||
|
index adfa519..73e20ec 100644
|
||||||
|
--- a/btrfsctl.c
|
||||||
|
+++ b/btrfsctl.c
|
||||||
|
@@ -107,6 +107,11 @@ int main(int ac, char **av)
|
||||||
|
char *fullpath;
|
||||||
|
u64 objectid = 0;
|
||||||
|
|
||||||
|
+ printf( "**\n"
|
||||||
|
+ "** WARNING: this program is considered deprecated\n"
|
||||||
|
+ "** Please consider to switch to the btrfs utility\n"
|
||||||
|
+ "**\n");
|
||||||
|
+
|
||||||
|
if (ac == 2 && strcmp(av[1], "-a") == 0) {
|
||||||
|
fprintf(stderr, "Scanning for Btrfs filesystems\n");
|
||||||
|
btrfs_scan_one_dir("/dev", 1);
|
||||||
|
diff --git a/man/btrfs-show.8.in b/man/btrfs-show.8.in
|
||||||
|
index dd0b147..cb98b68 100644
|
||||||
|
--- a/man/btrfs-show.8.in
|
||||||
|
+++ b/man/btrfs-show.8.in
|
||||||
|
@@ -3,6 +3,9 @@
|
||||||
|
btrfs-show \- scan the /dev directory for btrfs partitions and print results.
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B btrfs-show
|
||||||
|
+.SH NOTE
|
||||||
|
+.B btrfs-show
|
||||||
|
+is deprecated. Please consider to switch to the btrfs utility.
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B btrfs-show
|
||||||
|
is used to scan the /dev directory for btrfs partitions and display brief
|
||||||
|
diff --git a/man/btrfsctl.8.in b/man/btrfsctl.8.in
|
||||||
|
index c2d4488..8705fa6 100644
|
||||||
|
--- a/man/btrfsctl.8.in
|
||||||
|
+++ b/man/btrfsctl.8.in
|
||||||
|
@@ -10,6 +10,9 @@ btrfsctl \- control a btrfs filesystem
|
||||||
|
[ \fB \-A\fP\fI device\fP ]
|
||||||
|
[ \fB \-a\fP ]
|
||||||
|
[ \fB \-c\fP ]
|
||||||
|
+.SH NOTE
|
||||||
|
+B btrfsctl
|
||||||
|
+is deprecated. Please consider to switch to the btrfs utility.
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B btrfsctl
|
||||||
|
is used to control the filesystem and the files and directories stored. It is the tool to create a new snapshot for the filesystem.
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
389
0011-Add-the-btrfs-filesystem-label-command.patch
Normal file
389
0011-Add-the-btrfs-filesystem-label-command.patch
Normal file
@ -0,0 +1,389 @@
|
|||||||
|
From d1dc6a9cff7e2fe4f335ca783a4b033457b3e184 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goffredo Baroncelli <kreijack@inwind.it>
|
||||||
|
Date: Sun, 5 Dec 2010 17:46:44 +0000
|
||||||
|
Subject: [PATCH 11/15] Add the "btrfs filesystem label" command
|
||||||
|
|
||||||
|
Hi all,
|
||||||
|
|
||||||
|
this patch adds the command "btrfs filesystem label" to change (or show) the
|
||||||
|
label of a filesystem.
|
||||||
|
This patch is a subset of the one written previously by Morey Roof. I
|
||||||
|
included the user space part only. So it is possible only to change/show a
|
||||||
|
label of a *single device* and *unounted* filesystem.
|
||||||
|
|
||||||
|
The reason of excluding the kernel space part, is to simplify the patch in
|
||||||
|
order to speed the check and then the merging of the patch itself. In fact I
|
||||||
|
have to point out that in the past there was almost three attempts to propose
|
||||||
|
this patch, without success neither complaints.
|
||||||
|
|
||||||
|
Chris, let me know how you want to proceed. I know that you are very busy,
|
||||||
|
and you prefer to work to stabilize btrfs instead adding new feature. But I
|
||||||
|
think that changing a label is a *essential* feature for a filesystem
|
||||||
|
managing tool. Think about a mount by LABEL.
|
||||||
|
|
||||||
|
To show a label
|
||||||
|
|
||||||
|
$ btrfs filesystem label <device>
|
||||||
|
|
||||||
|
To set a label
|
||||||
|
|
||||||
|
$ btrfs filesystem label <device> <newlabel>
|
||||||
|
|
||||||
|
Please guys, give a look to the source.
|
||||||
|
Comments are welcome.
|
||||||
|
|
||||||
|
You can pull the source from the branch "label" of the repository
|
||||||
|
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
|
||||||
|
|
||||||
|
Regards
|
||||||
|
G.Baroncelli
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
Makefile | 2 +-
|
||||||
|
btrfs.c | 5 --
|
||||||
|
btrfs_cmds.c | 16 +++++++
|
||||||
|
btrfs_cmds.h | 1 +
|
||||||
|
btrfslabel.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
btrfslabel.h | 5 ++
|
||||||
|
man/btrfs.8.in | 19 +++++++++
|
||||||
|
utils.c | 57 ++++++++++++++++++++++++++
|
||||||
|
utils.h | 2 +
|
||||||
|
9 files changed, 222 insertions(+), 6 deletions(-)
|
||||||
|
create mode 100644 btrfslabel.c
|
||||||
|
create mode 100644 btrfslabel.h
|
||||||
|
|
||||||
|
diff --git a/Makefile b/Makefile
|
||||||
|
index d65f6a2..4b95d2f 100644
|
||||||
|
--- a/Makefile
|
||||||
|
+++ b/Makefile
|
||||||
|
@@ -4,7 +4,7 @@ CFLAGS = -g -Werror -Os
|
||||||
|
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
|
||||||
|
root-tree.o dir-item.o file-item.o inode-item.o \
|
||||||
|
inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
|
||||||
|
- volumes.o utils.o btrfs-list.o
|
||||||
|
+ volumes.o utils.o btrfs-list.o btrfslabel.o
|
||||||
|
|
||||||
|
#
|
||||||
|
CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 62140ef..4cd4210 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -108,11 +108,6 @@ static struct Command commands[] = {
|
||||||
|
"device delete", "<device> [<device>...] <path>\n"
|
||||||
|
"Remove a device from a filesystem."
|
||||||
|
},
|
||||||
|
- /* coming soon
|
||||||
|
- { 2, "filesystem label", "<label> <path>\n"
|
||||||
|
- "Set the label of a filesystem"
|
||||||
|
- }
|
||||||
|
- */
|
||||||
|
{ 0, 0 , 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 26d4fcc..6de73f4 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -40,6 +40,7 @@
|
||||||
|
#include "volumes.h"
|
||||||
|
|
||||||
|
#include "btrfs_cmds.h"
|
||||||
|
+#include "btrfslabel.h"
|
||||||
|
|
||||||
|
#ifdef __CHECKER__
|
||||||
|
#define BLKGETSIZE64 0
|
||||||
|
@@ -874,6 +875,21 @@ int do_set_default_subvol(int nargs, char **argv)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int do_change_label(int nargs, char **argv)
|
||||||
|
+{
|
||||||
|
+ /* check the number of argument */
|
||||||
|
+ if ( nargs > 3 ){
|
||||||
|
+ fprintf(stderr, "ERROR: '%s' requires maximum 2 args\n",
|
||||||
|
+ argv[0]);
|
||||||
|
+ return -2;
|
||||||
|
+ }else if (nargs == 2){
|
||||||
|
+ return get_label(argv[1]);
|
||||||
|
+ } else { /* nargs == 0 */
|
||||||
|
+ return set_label(argv[1], argv[2]);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
int do_df_filesystem(int nargs, char **argv)
|
||||||
|
{
|
||||||
|
struct btrfs_ioctl_space_args *sargs;
|
||||||
|
diff --git a/btrfs_cmds.h b/btrfs_cmds.h
|
||||||
|
index 7bde191..ab722d4 100644
|
||||||
|
--- a/btrfs_cmds.h
|
||||||
|
+++ b/btrfs_cmds.h
|
||||||
|
@@ -32,3 +32,4 @@ int list_subvols(int fd);
|
||||||
|
int do_df_filesystem(int nargs, char **argv);
|
||||||
|
int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
|
||||||
|
int do_find_newer(int argc, char **argv);
|
||||||
|
+int do_change_label(int argc, char **argv);
|
||||||
|
diff --git a/btrfslabel.c b/btrfslabel.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..c9f4684
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/btrfslabel.c
|
||||||
|
@@ -0,0 +1,121 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2008 Morey Roof. All rights reserved.
|
||||||
|
+ *
|
||||||
|
+ * This program is free software; you can redistribute it and/or
|
||||||
|
+ * modify it under the terms of the GNU General Public
|
||||||
|
+ * License v2 as published by the Free Software Foundation.
|
||||||
|
+ *
|
||||||
|
+ * This program is distributed in the hope that it will be useful,
|
||||||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
+ * General Public License for more details.
|
||||||
|
+ *
|
||||||
|
+ * You should have received a copy of the GNU General Public
|
||||||
|
+ * License along with this program; if not, write to the
|
||||||
|
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
+ * Boston, MA 021110-1307, USA.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#define _GNU_SOURCE
|
||||||
|
+
|
||||||
|
+#ifndef __CHECKER__
|
||||||
|
+#include <sys/ioctl.h>
|
||||||
|
+#include <sys/mount.h>
|
||||||
|
+#include "ioctl.h"
|
||||||
|
+#endif /* __CHECKER__ */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <stdlib.h>
|
||||||
|
+#include <sys/types.h>
|
||||||
|
+#include <sys/stat.h>
|
||||||
|
+#include <dirent.h>
|
||||||
|
+#include <fcntl.h>
|
||||||
|
+#include <unistd.h>
|
||||||
|
+#include <linux/fs.h>
|
||||||
|
+#include <linux/limits.h>
|
||||||
|
+#include <ctype.h>
|
||||||
|
+#include "kerncompat.h"
|
||||||
|
+#include "ctree.h"
|
||||||
|
+#include "utils.h"
|
||||||
|
+#include "version.h"
|
||||||
|
+#include "disk-io.h"
|
||||||
|
+#include "transaction.h"
|
||||||
|
+
|
||||||
|
+#define MOUNTED 1
|
||||||
|
+#define UNMOUNTED 2
|
||||||
|
+#define GET_LABEL 3
|
||||||
|
+#define SET_LABEL 4
|
||||||
|
+
|
||||||
|
+static void change_label_unmounted(char *dev, char *nLabel)
|
||||||
|
+{
|
||||||
|
+ struct btrfs_root *root;
|
||||||
|
+ struct btrfs_trans_handle *trans;
|
||||||
|
+
|
||||||
|
+ /* Open the super_block at the default location
|
||||||
|
+ * and as read-write.
|
||||||
|
+ */
|
||||||
|
+ root = open_ctree(dev, 0, 1);
|
||||||
|
+
|
||||||
|
+ trans = btrfs_start_transaction(root, 1);
|
||||||
|
+ strncpy(root->fs_info->super_copy.label, nLabel, BTRFS_LABEL_SIZE);
|
||||||
|
+ btrfs_commit_transaction(trans, root);
|
||||||
|
+
|
||||||
|
+ /* Now we close it since we are done. */
|
||||||
|
+ close_ctree(root);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void get_label_unmounted(char *dev)
|
||||||
|
+{
|
||||||
|
+ struct btrfs_root *root;
|
||||||
|
+
|
||||||
|
+ /* Open the super_block at the default location
|
||||||
|
+ * and as read-only.
|
||||||
|
+ */
|
||||||
|
+ root = open_ctree(dev, 0, 0);
|
||||||
|
+
|
||||||
|
+ fprintf(stdout, "%s\n", root->fs_info->super_copy.label);
|
||||||
|
+
|
||||||
|
+ /* Now we close it since we are done. */
|
||||||
|
+ close_ctree(root);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int get_label(char *btrfs_dev)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ int ret;
|
||||||
|
+ ret = check_mounted(btrfs_dev);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev);
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(ret != 0)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stderr, "FATAL: the filesystem has to be unmounted\n");
|
||||||
|
+ return -2;
|
||||||
|
+ }
|
||||||
|
+ get_label_unmounted(btrfs_dev);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+int set_label(char *btrfs_dev, char *nLabel)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ int ret;
|
||||||
|
+ ret = check_mounted(btrfs_dev);
|
||||||
|
+ if (ret < 0)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stderr, "FATAL: error checking %s mount status\n", btrfs_dev);
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(ret != 0)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stderr, "FATAL: the filesystem has to be unmounted\n");
|
||||||
|
+ return -2;
|
||||||
|
+ }
|
||||||
|
+ change_label_unmounted(btrfs_dev, nLabel);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/btrfslabel.h b/btrfslabel.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..abf43ad
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/btrfslabel.h
|
||||||
|
@@ -0,0 +1,5 @@
|
||||||
|
+/* btrflabel.h */
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+int get_label(char *btrfs_dev);
|
||||||
|
+int set_label(char *btrfs_dev, char *nLabel);
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index b9b8913..6f92f91 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -19,6 +19,8 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem resize\fP\fI [+/\-]<size>[gkm]|max <filesystem>\fP
|
||||||
|
.PP
|
||||||
|
+\fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP
|
||||||
|
+.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem defrag\fP\fI [options] <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP
|
||||||
|
@@ -164,6 +166,23 @@ can expand the partition before enlarging the filesystem and shrink the
|
||||||
|
partition after reducing the size of the filesystem.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
+\fBbtrfs\fP \fBfilesystem label\fP\fI <dev> [newlabel]\fP
|
||||||
|
+Show or update the label of a filesystem. \fI<dev>\fR is used to identify the
|
||||||
|
+filesystem.
|
||||||
|
+If a \fInewlabel\fR optional argument is passed, the label is changed. The
|
||||||
|
+following costraints exist for a label:
|
||||||
|
+.IP
|
||||||
|
+- the maximum allowable lenght shall be less or equal than 256 chars
|
||||||
|
+.IP
|
||||||
|
+- the label shall not contain the '/' or '\\' characters.
|
||||||
|
+
|
||||||
|
+NOTE: Currently there are the following limitations:
|
||||||
|
+.IP
|
||||||
|
+- the filesystem has to be unmounted
|
||||||
|
+.IP
|
||||||
|
+- the filesystem should not have more than one device.
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
\fBfilesystem show\fR [<uuid>|<label>]\fR
|
||||||
|
Show the btrfs filesystem with some additional info. If no UUID or label is
|
||||||
|
passed, \fBbtrfs\fR show info of all the btrfs filesystem.
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index ad980ae..13373c9 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -812,6 +812,39 @@ out_mntloop_err:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/* Gets the mount point of btrfs filesystem that is using the specified device.
|
||||||
|
+ * Returns 0 is everything is good, <0 if we have an error.
|
||||||
|
+ * TODO: Fix this fucntion and check_mounted to work with multiple drive BTRFS
|
||||||
|
+ * setups.
|
||||||
|
+ */
|
||||||
|
+int get_mountpt(char *dev, char *mntpt, size_t size)
|
||||||
|
+{
|
||||||
|
+ struct mntent *mnt;
|
||||||
|
+ FILE *f;
|
||||||
|
+ int ret = 0;
|
||||||
|
+
|
||||||
|
+ f = setmntent("/proc/mounts", "r");
|
||||||
|
+ if (f == NULL)
|
||||||
|
+ return -errno;
|
||||||
|
+
|
||||||
|
+ while ((mnt = getmntent(f)) != NULL )
|
||||||
|
+ {
|
||||||
|
+ if (strcmp(dev, mnt->mnt_fsname) == 0)
|
||||||
|
+ {
|
||||||
|
+ strncpy(mntpt, mnt->mnt_dir, size);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (mnt == NULL)
|
||||||
|
+ {
|
||||||
|
+ /* We didn't find an entry so lets report an error */
|
||||||
|
+ ret = -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
struct pending_dir {
|
||||||
|
struct list_head list;
|
||||||
|
char name[256];
|
||||||
|
@@ -1002,3 +1035,27 @@ char *pretty_sizes(u64 size)
|
||||||
|
return pretty;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+ * Checks to make sure that the label matches our requirements.
|
||||||
|
+ * Returns:
|
||||||
|
+ 0 if everything is safe and usable
|
||||||
|
+ -1 if the label is too long
|
||||||
|
+ -2 if the label contains an invalid character
|
||||||
|
+ */
|
||||||
|
+int check_label(char *input)
|
||||||
|
+{
|
||||||
|
+ int i;
|
||||||
|
+ int len = strlen(input);
|
||||||
|
+
|
||||||
|
+ if (len > BTRFS_LABEL_SIZE) {
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < len; i++) {
|
||||||
|
+ if (input[i] == '/' || input[i] == '\\') {
|
||||||
|
+ return -2;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/utils.h b/utils.h
|
||||||
|
index a28d7f4..c3004ae 100644
|
||||||
|
--- a/utils.h
|
||||||
|
+++ b/utils.h
|
||||||
|
@@ -40,4 +40,6 @@ int check_mounted(const char *devicename);
|
||||||
|
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
|
||||||
|
int super_offset);
|
||||||
|
char *pretty_sizes(u64 size);
|
||||||
|
+int check_label(char *input);
|
||||||
|
+int get_mountpt(char *dev, char *mntpt, size_t size);
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,42 @@
|
|||||||
|
From 4c6ae809c50d44d4530a211b95b004002b3ba45f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mitch Harder <mitch.harder@sabayonlinux.org>
|
||||||
|
Date: Mon, 15 Nov 2010 16:32:12 +0000
|
||||||
|
Subject: [PATCH 12/15] Btrfs-progs: Update man page for mixed data+metadata
|
||||||
|
option.
|
||||||
|
|
||||||
|
Update the mkfs.btrfs man page for the -M option to mix data and
|
||||||
|
metadata chunks.
|
||||||
|
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
man/mkfs.btrfs.8.in | 7 +++++++
|
||||||
|
1 files changed, 7 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/mkfs.btrfs.8.in b/man/mkfs.btrfs.8.in
|
||||||
|
index 1e14c6c..432db1b 100644
|
||||||
|
--- a/man/mkfs.btrfs.8.in
|
||||||
|
+++ b/man/mkfs.btrfs.8.in
|
||||||
|
@@ -9,6 +9,7 @@ mkfs.btrfs \- create an btrfs filesystem
|
||||||
|
[ \fB \-l\fP\fI leafsize\fP ]
|
||||||
|
[ \fB \-L\fP\fI label\fP ]
|
||||||
|
[ \fB \-m\fP\fI metadata profile\fP ]
|
||||||
|
+[ \fB \-M\fP\fI mixed data+metadata\fP ]
|
||||||
|
[ \fB \-n\fP\fI nodesize\fP ]
|
||||||
|
[ \fB \-s\fP\fI sectorsize\fP ]
|
||||||
|
[ \fB \-h\fP ]
|
||||||
|
@@ -45,6 +46,12 @@ Specify a label for the filesystem.
|
||||||
|
Specify how metadata must be spanned across the devices specified. Valid
|
||||||
|
values are raid0, raid1, raid10 or single.
|
||||||
|
.TP
|
||||||
|
+\fB\-M\fR, \fB\-\-mixed\fR
|
||||||
|
+Mix data and metadata chunks together for more efficient space
|
||||||
|
+utilization. This feature incurs a performance penalty in
|
||||||
|
+larger filesystems. It is recommended for use with filesystems
|
||||||
|
+of 1 GiB or smaller.
|
||||||
|
+.TP
|
||||||
|
\fB\-n\fR, \fB\-\-nodesize \fIsize\fR
|
||||||
|
Specify the nodesize. By default the value is set to the pagesize.
|
||||||
|
.TP
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
1108
0013-btrfs-progs-Add-new-feature-to-mkfs.btrfs-to-make-fi.patch
Normal file
1108
0013-btrfs-progs-Add-new-feature-to-mkfs.btrfs-to-make-fi.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,33 @@
|
|||||||
|
From 32ba8209276d3ac1723ea6373aaec9d6399ce5ca Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miao Xie <miaox@cn.fujitsu.com>
|
||||||
|
Date: Tue, 13 Jul 2010 09:18:04 +0000
|
||||||
|
Subject: [PATCH 14/15] btrfs-progs: fix wrong extent buffer size when reading
|
||||||
|
tree block
|
||||||
|
|
||||||
|
the root extent buffer of a tree may not be a leaf, so we must get the right
|
||||||
|
size by its level when reading it.
|
||||||
|
|
||||||
|
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
debug-tree.c | 4 +++-
|
||||||
|
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/debug-tree.c b/debug-tree.c
|
||||||
|
index 0525354..99c12d6 100644
|
||||||
|
--- a/debug-tree.c
|
||||||
|
+++ b/debug-tree.c
|
||||||
|
@@ -212,7 +212,9 @@ again:
|
||||||
|
read_extent_buffer(leaf, &ri, offset, sizeof(ri));
|
||||||
|
buf = read_tree_block(tree_root_scan,
|
||||||
|
btrfs_root_bytenr(&ri),
|
||||||
|
- tree_root_scan->leafsize, 0);
|
||||||
|
+ btrfs_level_size(tree_root_scan,
|
||||||
|
+ btrfs_root_level(&ri)),
|
||||||
|
+ 0);
|
||||||
|
switch(found_key.objectid) {
|
||||||
|
case BTRFS_ROOT_TREE_OBJECTID:
|
||||||
|
if (!skip)
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
109
0015-btrfs-progs-add-discard-support-to-mkfs.patch
Normal file
109
0015-btrfs-progs-add-discard-support-to-mkfs.patch
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
From e6bd18d8938986c997c45f0ea95b221d4edec095 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Christoph Hellwig <hch@lst.de>
|
||||||
|
Date: Thu, 21 Apr 2011 16:24:07 -0400
|
||||||
|
Subject: [PATCH 15/15] btrfs-progs: add discard support to mkfs
|
||||||
|
|
||||||
|
Discard the whole device before starting to create the filesystem structures.
|
||||||
|
Modelled after similar support in mkfs.xfs.
|
||||||
|
|
||||||
|
Signed-off-by: Christoph Hellwig <hch@lst.de>
|
||||||
|
Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
---
|
||||||
|
btrfs_cmds.c | 21 +++++++++++++++++----
|
||||||
|
utils.c | 21 +++++++++++++++++++++
|
||||||
|
2 files changed, 38 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 6de73f4..32f6b25 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -732,13 +732,26 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
- for(i=1 ; i < (nargs-1) ; i++ ){
|
||||||
|
+ for (i = 1; i < (nargs-1); i++ ){
|
||||||
|
struct btrfs_ioctl_vol_args ioctl_args;
|
||||||
|
int devfd, res;
|
||||||
|
u64 dev_block_count = 0;
|
||||||
|
struct stat st;
|
||||||
|
int mixed = 0;
|
||||||
|
|
||||||
|
+ res = check_mounted(args[i]);
|
||||||
|
+ if (res < 0) {
|
||||||
|
+ fprintf(stderr, "error checking %s mount status\n",
|
||||||
|
+ args[i]);
|
||||||
|
+ ret++;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (res == 1) {
|
||||||
|
+ fprintf(stderr, "%s is mounted\n", args[i]);
|
||||||
|
+ ret++;
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
devfd = open(args[i], O_RDWR);
|
||||||
|
if (!devfd) {
|
||||||
|
fprintf(stderr, "ERROR: Unable to open device '%s'\n", args[i]);
|
||||||
|
@@ -746,8 +759,8 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
ret++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
- ret = fstat(devfd, &st);
|
||||||
|
- if (ret) {
|
||||||
|
+ res = fstat(devfd, &st);
|
||||||
|
+ if (res) {
|
||||||
|
fprintf(stderr, "ERROR: Unable to stat '%s'\n", args[i]);
|
||||||
|
close(devfd);
|
||||||
|
ret++;
|
||||||
|
@@ -781,7 +794,7 @@ int do_add_volume(int nargs, char **args)
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fdmnt);
|
||||||
|
- if( ret)
|
||||||
|
+ if (ret)
|
||||||
|
return ret+20;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 13373c9..17e5afe 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -50,6 +50,20 @@
|
||||||
|
static inline int ioctl(int fd, int define, u64 *size) { return 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+#ifndef BLKDISCARD
|
||||||
|
+#define BLKDISCARD _IO(0x12,119)
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+discard_blocks(int fd, u64 start, u64 len)
|
||||||
|
+{
|
||||||
|
+ u64 range[2] = { start, len };
|
||||||
|
+
|
||||||
|
+ if (ioctl(fd, BLKDISCARD, &range) < 0)
|
||||||
|
+ return errno;
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static u64 reference_root_table[] = {
|
||||||
|
[1] = BTRFS_ROOT_TREE_OBJECTID,
|
||||||
|
[2] = BTRFS_EXTENT_TREE_OBJECTID,
|
||||||
|
@@ -537,6 +551,13 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
||||||
|
printf("SMALL VOLUME: forcing mixed metadata/data groups\n");
|
||||||
|
*mixed = 1;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * We intentionally ignore errors from the discard ioctl. It is
|
||||||
|
+ * not necessary for the mkfs functionality but just an optimization.
|
||||||
|
+ */
|
||||||
|
+ discard_blocks(fd, 0, block_count);
|
||||||
|
+
|
||||||
|
ret = zero_dev_start(fd);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "failed to zero device start %d\n", ret);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
63
0101-btrfs-progs-setting-of-time-to-the-root-directory.patch
Normal file
63
0101-btrfs-progs-setting-of-time-to-the-root-directory.patch
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
From 37b1fc8c9302ec7dc1c6c04041805ac21fdfca28 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
|
||||||
|
Date: Wed, 17 Nov 2010 10:07:52 +0900
|
||||||
|
Subject: [PATCH 01/28] btrfs-progs: setting of time to the root directory
|
||||||
|
|
||||||
|
This patch adds the setting of time to the root directory to the
|
||||||
|
mkfs.btrfs command.
|
||||||
|
As a result, the time of the mount point not correctly displayed
|
||||||
|
comes to be displayed correctly.
|
||||||
|
|
||||||
|
[before]
|
||||||
|
# mkfs.btrfs /dev/sdd10
|
||||||
|
# mount /dev/sdd10 /test1
|
||||||
|
# ls -ld /test1
|
||||||
|
dr-xr-xr-x 1 root root 0 Jan 1 1970 /test1
|
||||||
|
|
||||||
|
[after]
|
||||||
|
# date
|
||||||
|
Tue Nov 16 18:06:05 JST 2010
|
||||||
|
# mkfs.btrfs /dev/sdd10
|
||||||
|
# mount /dev/sdd10 /test1
|
||||||
|
# ls -ld /test1
|
||||||
|
dr-xr-xr-x 1 root root 0 Nov 16 18:06 /test1
|
||||||
|
|
||||||
|
Thanks,
|
||||||
|
Tsutomu
|
||||||
|
|
||||||
|
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
utils.c | 9 +++++++++
|
||||||
|
1 files changed, 9 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 17e5afe..74d2c59 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -587,6 +587,7 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct btrfs_inode_item inode_item;
|
||||||
|
+ time_t now = time(NULL);
|
||||||
|
|
||||||
|
memset(&inode_item, 0, sizeof(inode_item));
|
||||||
|
btrfs_set_stack_inode_generation(&inode_item, trans->transid);
|
||||||
|
@@ -594,6 +595,14 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
|
||||||
|
btrfs_set_stack_inode_nlink(&inode_item, 1);
|
||||||
|
btrfs_set_stack_inode_nbytes(&inode_item, root->leafsize);
|
||||||
|
btrfs_set_stack_inode_mode(&inode_item, S_IFDIR | 0555);
|
||||||
|
+ btrfs_set_stack_timespec_sec(&inode_item.atime, now);
|
||||||
|
+ btrfs_set_stack_timespec_nsec(&inode_item.atime, 0);
|
||||||
|
+ btrfs_set_stack_timespec_sec(&inode_item.ctime, now);
|
||||||
|
+ btrfs_set_stack_timespec_nsec(&inode_item.ctime, 0);
|
||||||
|
+ btrfs_set_stack_timespec_sec(&inode_item.mtime, now);
|
||||||
|
+ btrfs_set_stack_timespec_nsec(&inode_item.mtime, 0);
|
||||||
|
+ btrfs_set_stack_timespec_sec(&inode_item.otime, 0);
|
||||||
|
+ btrfs_set_stack_timespec_nsec(&inode_item.otime, 0);
|
||||||
|
|
||||||
|
if (root->fs_info->tree_root == root)
|
||||||
|
btrfs_set_super_root_dir(&root->fs_info->super_copy, objectid);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
33
0103-add-advanced-use-of-help-to-help-message.patch
Normal file
33
0103-add-advanced-use-of-help-to-help-message.patch
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
From 346e20eedde773e9d7b00bd1ea5bc8ecda3236ee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Date: Sun, 23 Jan 2011 13:39:36 +0100
|
||||||
|
Subject: [PATCH 03/28] add advanced use of --help to help message
|
||||||
|
|
||||||
|
explain how to use
|
||||||
|
|
||||||
|
btrfs <cmd> --help
|
||||||
|
|
||||||
|
command in help message
|
||||||
|
|
||||||
|
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs.c | 2 ++
|
||||||
|
1 files changed, 2 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 4cd4210..8e0975e 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -146,6 +146,8 @@ static void help(char *np)
|
||||||
|
print_help(np, cp);
|
||||||
|
|
||||||
|
printf("\n\t%s help|--help|-h\n\t\tShow the help.\n",np);
|
||||||
|
+ printf("\n\t%s <cmd> --help\n\t\tShow detailed help for a command or\n\t\t"
|
||||||
|
+ "subset of commands.\n",np);
|
||||||
|
printf("\n%s\n", BTRFS_BUILD_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
229
0104-add-detailed-help-messages-to-btrfs-command.patch
Normal file
229
0104-add-detailed-help-messages-to-btrfs-command.patch
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
From a36c34289edada01e6447083046cb14a0489f6b9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Date: Sun, 23 Jan 2011 13:42:43 +0100
|
||||||
|
Subject: [PATCH 04/28] add detailed help messages to btrfs command
|
||||||
|
|
||||||
|
extend the
|
||||||
|
|
||||||
|
btrfs <cmd> --help
|
||||||
|
|
||||||
|
command to print detailed help message if available but fallback to
|
||||||
|
basic help message if detailed is unavailable
|
||||||
|
|
||||||
|
add detailed help message for 'filesystem defragment' command
|
||||||
|
|
||||||
|
little tweaks in comments
|
||||||
|
|
||||||
|
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs.c | 96 ++++++++++++++++++++++++++++++++++++++++++--------------------
|
||||||
|
1 files changed, 65 insertions(+), 31 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 8e0975e..742dd27 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -23,6 +23,9 @@
|
||||||
|
#include "btrfs_cmds.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
+#define BASIC_HELP 0
|
||||||
|
+#define ADVANCED_HELP 1
|
||||||
|
+
|
||||||
|
typedef int (*CommandFunction)(int argc, char **argv);
|
||||||
|
|
||||||
|
struct Command {
|
||||||
|
@@ -31,8 +34,10 @@ struct Command {
|
||||||
|
if >= 0, number of arguments,
|
||||||
|
if < 0, _minimum_ number of arguments */
|
||||||
|
char *verb; /* verb */
|
||||||
|
- char *help; /* help lines; form the 2nd onward they are
|
||||||
|
- indented */
|
||||||
|
+ char *help; /* help lines; from the 2nd line onward they
|
||||||
|
+ are automatically indented */
|
||||||
|
+ char *adv_help; /* advanced help message; from the 2nd line
|
||||||
|
+ onward they are automatically indented */
|
||||||
|
|
||||||
|
/* the following fields are run-time filled by the program */
|
||||||
|
char **cmds; /* array of subcommands */
|
||||||
|
@@ -47,68 +52,90 @@ static struct Command commands[] = {
|
||||||
|
{ do_clone, 2,
|
||||||
|
"subvolume snapshot", "<source> [<dest>/]<name>\n"
|
||||||
|
"Create a writable snapshot of the subvolume <source> with\n"
|
||||||
|
- "the name <name> in the <dest> directory."
|
||||||
|
+ "the name <name> in the <dest> directory.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_delete_subvolume, 1,
|
||||||
|
"subvolume delete", "<subvolume>\n"
|
||||||
|
- "Delete the subvolume <subvolume>."
|
||||||
|
+ "Delete the subvolume <subvolume>.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_create_subvol, 1,
|
||||||
|
"subvolume create", "[<dest>/]<name>\n"
|
||||||
|
"Create a subvolume in <dest> (or the current directory if\n"
|
||||||
|
- "not passed)."
|
||||||
|
+ "not passed).",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_subvol_list, 1, "subvolume list", "<path>\n"
|
||||||
|
- "List the snapshot/subvolume of a filesystem."
|
||||||
|
+ "List the snapshot/subvolume of a filesystem.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_set_default_subvol, 2,
|
||||||
|
"subvolume set-default", "<id> <path>\n"
|
||||||
|
"Set the subvolume of the filesystem <path> which will be mounted\n"
|
||||||
|
- "as default."
|
||||||
|
+ "as default.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_find_newer, 2, "subvolume find-new", "<path> <last_gen>\n"
|
||||||
|
- "List the recently modified files in a filesystem."
|
||||||
|
+ "List the recently modified files in a filesystem.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_defrag, -1,
|
||||||
|
"filesystem defragment", "[-vf] [-c[zlib,lzo]] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
|
||||||
|
- "Defragment a file or a directory."
|
||||||
|
+ "Defragment a file or a directory.",
|
||||||
|
+ "[-vcf] [-s start] [-l len] [-t size] <file>|<dir> [<file>|<dir>...]\n"
|
||||||
|
+ "Defragment file data or directory metadata.\n"
|
||||||
|
+ "-v be verbose\n"
|
||||||
|
+ "-c compress the file while defragmenting\n"
|
||||||
|
+ "-f flush data to disk immediately after defragmenting\n"
|
||||||
|
+ "-s start defragment only from byte onward\n"
|
||||||
|
+ "-l len defragment only up to len bytes\n"
|
||||||
|
+ "-t size minimal size of file to be considered for defragmenting\n"
|
||||||
|
},
|
||||||
|
{ do_fssync, 1,
|
||||||
|
"filesystem sync", "<path>\n"
|
||||||
|
- "Force a sync on the filesystem <path>."
|
||||||
|
+ "Force a sync on the filesystem <path>.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_resize, 2,
|
||||||
|
"filesystem resize", "[+/-]<newsize>[gkm]|max <filesystem>\n"
|
||||||
|
"Resize the file system. If 'max' is passed, the filesystem\n"
|
||||||
|
- "will occupe all available space on the device."
|
||||||
|
+ "will occupe all available space on the device.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_show_filesystem, 999,
|
||||||
|
"filesystem show", "[<device>|<uuid>|<label>]\n"
|
||||||
|
"Show the info of a btrfs filesystem. If no argument\n"
|
||||||
|
- "is passed, info of all the btrfs filesystem are shown."
|
||||||
|
+ "is passed, info of all the btrfs filesystem are shown.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_df_filesystem, 1,
|
||||||
|
"filesystem df", "<path>\n"
|
||||||
|
- "Show space usage information for a mount point."
|
||||||
|
+ "Show space usage information for a mount point.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_balance, 1,
|
||||||
|
"filesystem balance", "<path>\n"
|
||||||
|
- "Balance the chunks across the device."
|
||||||
|
+ "Balance the chunks across the device.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_scan, 999,
|
||||||
|
"device scan", "[<device>...]\n"
|
||||||
|
"Scan all device for or the passed device for a btrfs\n"
|
||||||
|
- "filesystem."
|
||||||
|
+ "filesystem.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_add_volume, -2,
|
||||||
|
"device add", "<device> [<device>...] <path>\n"
|
||||||
|
- "Add a device to a filesystem."
|
||||||
|
+ "Add a device to a filesystem.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
{ do_remove_volume, -2,
|
||||||
|
"device delete", "<device> [<device>...] <path>\n"
|
||||||
|
- "Remove a device from a filesystem."
|
||||||
|
+ "Remove a device from a filesystem.",
|
||||||
|
+ NULL
|
||||||
|
},
|
||||||
|
- { 0, 0 , 0 }
|
||||||
|
+ { 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static char *get_prgname(char *programname)
|
||||||
|
@@ -123,17 +150,25 @@ static char *get_prgname(char *programname)
|
||||||
|
return np;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void print_help(char *programname, struct Command *cmd)
|
||||||
|
+static void print_help(char *programname, struct Command *cmd, int helptype)
|
||||||
|
{
|
||||||
|
char *pc;
|
||||||
|
|
||||||
|
printf("\t%s %s ", programname, cmd->verb );
|
||||||
|
|
||||||
|
- for(pc = cmd->help; *pc; pc++){
|
||||||
|
- putchar(*pc);
|
||||||
|
- if(*pc == '\n')
|
||||||
|
- printf("\t\t");
|
||||||
|
- }
|
||||||
|
+ if (helptype == ADVANCED_HELP && cmd->adv_help)
|
||||||
|
+ for(pc = cmd->adv_help; *pc; pc++){
|
||||||
|
+ putchar(*pc);
|
||||||
|
+ if(*pc == '\n')
|
||||||
|
+ printf("\t\t");
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ for(pc = cmd->help; *pc; pc++){
|
||||||
|
+ putchar(*pc);
|
||||||
|
+ if(*pc == '\n')
|
||||||
|
+ printf("\t\t");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -143,7 +178,7 @@ static void help(char *np)
|
||||||
|
|
||||||
|
printf("Usage:\n");
|
||||||
|
for( cp = commands; cp->verb; cp++ )
|
||||||
|
- print_help(np, cp);
|
||||||
|
+ print_help(np, cp, BASIC_HELP);
|
||||||
|
|
||||||
|
printf("\n\t%s help|--help|-h\n\t\tShow the help.\n",np);
|
||||||
|
printf("\n\t%s <cmd> --help\n\t\tShow detailed help for a command or\n\t\t"
|
||||||
|
@@ -252,15 +287,14 @@ static int prepare_args(int *ac, char ***av, char *prgname, struct Command *cmd
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
-
|
||||||
|
- This function perform the following jobs:
|
||||||
|
+ This function performs the following jobs:
|
||||||
|
- show the help if '--help' or 'help' or '-h' are passed
|
||||||
|
- verify that a command is not ambiguous, otherwise show which
|
||||||
|
part of the command is ambiguous
|
||||||
|
- - if after a (even partial) command there is '--help' show the help
|
||||||
|
+ - if after a (even partial) command there is '--help' show detailed help
|
||||||
|
for all the matching commands
|
||||||
|
- - if the command doesn't' match show an error
|
||||||
|
- - finally, if a command match, they return which command is matched and
|
||||||
|
+ - if the command doesn't match show an error
|
||||||
|
+ - finally, if a command matches, they return which command matched and
|
||||||
|
the arguments
|
||||||
|
|
||||||
|
The function return 0 in case of help is requested; <0 in case
|
||||||
|
@@ -314,7 +348,7 @@ static int parse_args(int argc, char **argv,
|
||||||
|
if(argc>i+1 && !strcmp(argv[i+1],"--help")){
|
||||||
|
if(!helprequested)
|
||||||
|
printf("Usage:\n");
|
||||||
|
- print_help(prgname, cp);
|
||||||
|
+ print_help(prgname, cp, ADVANCED_HELP);
|
||||||
|
helprequested=1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
529
0105-Fix-unused-but-set-errors-in-gcc-4.6.patch
Normal file
529
0105-Fix-unused-but-set-errors-in-gcc-4.6.patch
Normal file
@ -0,0 +1,529 @@
|
|||||||
|
From 6eb02bad89c5d7441254fb78d5205ba31024c09c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chris Ball <cjb@laptop.org>
|
||||||
|
Date: Mon, 7 Mar 2011 10:05:21 -0500
|
||||||
|
Subject: [PATCH 05/28] Fix unused-but-set errors in gcc-4.6
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
gcc-4.6 (as shipped in Fedora) turns on -Wunused-but-set-variable by
|
||||||
|
default, which breaks the build when combined with -Wall, e.g.:
|
||||||
|
|
||||||
|
debug-tree.c: In function ‘print_extent_leaf’:
|
||||||
|
debug-tree.c:45:13: error: variable ‘last_len’ set but not used [-Werror=unused-but-set-variable]
|
||||||
|
debug-tree.c:44:13: error: variable ‘last’ set but not used [-Werror=unused-but-set-variable]
|
||||||
|
debug-tree.c:41:21: error: variable ‘item’ set but not used [-Werror=unused-but-set-variable]
|
||||||
|
cc1: all warnings being treated as errors
|
||||||
|
|
||||||
|
This patch fixes the errors by removing the unused variables.
|
||||||
|
|
||||||
|
Signed-off-by: Chris Ball <cjb@laptop.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs-map-logical.c | 2 --
|
||||||
|
btrfsck.c | 15 ++-------------
|
||||||
|
ctree.c | 16 ----------------
|
||||||
|
debug-tree.c | 43 +------------------------------------------
|
||||||
|
dir-item.c | 2 +-
|
||||||
|
disk-io.c | 4 ----
|
||||||
|
extent-cache.c | 6 ++----
|
||||||
|
extent-tree.c | 30 ------------------------------
|
||||||
|
extent_io.c | 4 ----
|
||||||
|
mkfs.c | 3 ---
|
||||||
|
print-tree.c | 3 ---
|
||||||
|
volumes.c | 4 ----
|
||||||
|
12 files changed, 6 insertions(+), 126 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
|
||||||
|
index a109c6a..8a12074 100644
|
||||||
|
--- a/btrfs-map-logical.c
|
||||||
|
+++ b/btrfs-map-logical.c
|
||||||
|
@@ -41,7 +41,6 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
|
||||||
|
u32 blocksize, int copy)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
- int dev_nr;
|
||||||
|
struct extent_buffer *eb;
|
||||||
|
u64 length;
|
||||||
|
struct btrfs_multi_bio *multi = NULL;
|
||||||
|
@@ -53,7 +52,6 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
|
||||||
|
if (!eb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
- dev_nr = 0;
|
||||||
|
length = blocksize;
|
||||||
|
while (1) {
|
||||||
|
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
||||||
|
diff --git a/btrfsck.c b/btrfsck.c
|
||||||
|
index 63e44d1..e3cd435 100644
|
||||||
|
--- a/btrfsck.c
|
||||||
|
+++ b/btrfsck.c
|
||||||
|
@@ -1037,7 +1037,7 @@ static int process_one_leaf(struct btrfs_root *root, struct extent_buffer *eb,
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
- return 0;
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reada_walk_down(struct btrfs_root *root,
|
||||||
|
@@ -1917,7 +1917,6 @@ static int check_owner_ref(struct btrfs_root *root,
|
||||||
|
struct btrfs_root *ref_root;
|
||||||
|
struct btrfs_key key;
|
||||||
|
struct btrfs_path path;
|
||||||
|
- int ret;
|
||||||
|
int level;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
|
@@ -1950,7 +1949,7 @@ static int check_owner_ref(struct btrfs_root *root,
|
||||||
|
|
||||||
|
btrfs_init_path(&path);
|
||||||
|
path.lowest_level = level + 1;
|
||||||
|
- ret = btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
|
||||||
|
+ btrfs_search_slot(NULL, ref_root, &key, &path, 0, 0);
|
||||||
|
|
||||||
|
if (buf->start == btrfs_node_blockptr(path.nodes[level + 1],
|
||||||
|
path.slots[level + 1]))
|
||||||
|
@@ -2539,16 +2538,6 @@ static int run_next_block(struct btrfs_root *root,
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
|
||||||
|
- struct btrfs_block_group_item *bi;
|
||||||
|
- bi = btrfs_item_ptr(buf, i,
|
||||||
|
- struct btrfs_block_group_item);
|
||||||
|
-#if 0
|
||||||
|
- fprintf(stderr,"block group %Lu %Lu used %Lu ",
|
||||||
|
- btrfs_disk_key_objectid(disk_key),
|
||||||
|
- btrfs_disk_key_offset(disk_key),
|
||||||
|
- btrfs_block_group_used(bi));
|
||||||
|
- fprintf(stderr, "flags %x\n", bi->flags);
|
||||||
|
-#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key.type == BTRFS_EXTENT_REF_V0_KEY) {
|
||||||
|
diff --git a/ctree.c b/ctree.c
|
||||||
|
index f70e10c..12f1a55 100644
|
||||||
|
--- a/ctree.c
|
||||||
|
+++ b/ctree.c
|
||||||
|
@@ -262,7 +262,6 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
|
||||||
|
struct extent_buffer **cow_ret,
|
||||||
|
u64 search_start, u64 empty_size)
|
||||||
|
{
|
||||||
|
- u64 generation;
|
||||||
|
struct extent_buffer *cow;
|
||||||
|
struct btrfs_disk_key disk_key;
|
||||||
|
int level;
|
||||||
|
@@ -272,7 +271,6 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
|
||||||
|
WARN_ON(root->ref_cows && trans->transid != root->last_trans);
|
||||||
|
|
||||||
|
level = btrfs_header_level(buf);
|
||||||
|
- generation = btrfs_header_generation(buf);
|
||||||
|
|
||||||
|
if (level == 0)
|
||||||
|
btrfs_item_key(buf, &disk_key, 0);
|
||||||
|
@@ -795,7 +793,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
|
||||||
|
int wret;
|
||||||
|
int pslot;
|
||||||
|
int orig_slot = path->slots[level];
|
||||||
|
- int err_on_enospc = 0;
|
||||||
|
u64 orig_ptr;
|
||||||
|
|
||||||
|
if (level == 0)
|
||||||
|
@@ -845,9 +842,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
|
||||||
|
BTRFS_NODEPTRS_PER_BLOCK(root) / 4)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- if (btrfs_header_nritems(mid) < 2)
|
||||||
|
- err_on_enospc = 1;
|
||||||
|
-
|
||||||
|
left = read_node_slot(root, parent, pslot - 1);
|
||||||
|
if (left) {
|
||||||
|
wret = btrfs_cow_block(trans, root, left,
|
||||||
|
@@ -873,8 +867,6 @@ static int balance_level(struct btrfs_trans_handle *trans,
|
||||||
|
wret = push_node_left(trans, root, left, mid, 1);
|
||||||
|
if (wret < 0)
|
||||||
|
ret = wret;
|
||||||
|
- if (btrfs_header_nritems(mid) < 2)
|
||||||
|
- err_on_enospc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -996,14 +988,12 @@ static int noinline push_nodes_for_insert(struct btrfs_trans_handle *trans,
|
||||||
|
int wret;
|
||||||
|
int pslot;
|
||||||
|
int orig_slot = path->slots[level];
|
||||||
|
- u64 orig_ptr;
|
||||||
|
|
||||||
|
if (level == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
mid = path->nodes[level];
|
||||||
|
WARN_ON(btrfs_header_generation(mid) != trans->transid);
|
||||||
|
- orig_ptr = btrfs_node_blockptr(mid, orig_slot);
|
||||||
|
|
||||||
|
if (level < BTRFS_MAX_LEVEL - 1)
|
||||||
|
parent = path->nodes[level + 1];
|
||||||
|
@@ -2370,7 +2360,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int slot;
|
||||||
|
- int slot_orig;
|
||||||
|
struct extent_buffer *leaf;
|
||||||
|
struct btrfs_item *item;
|
||||||
|
u32 nritems;
|
||||||
|
@@ -2380,7 +2369,6 @@ int btrfs_truncate_item(struct btrfs_trans_handle *trans,
|
||||||
|
unsigned int size_diff;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- slot_orig = path->slots[0];
|
||||||
|
leaf = path->nodes[0];
|
||||||
|
slot = path->slots[0];
|
||||||
|
|
||||||
|
@@ -2468,7 +2456,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
int slot;
|
||||||
|
- int slot_orig;
|
||||||
|
struct extent_buffer *leaf;
|
||||||
|
struct btrfs_item *item;
|
||||||
|
u32 nritems;
|
||||||
|
@@ -2477,7 +2464,6 @@ int btrfs_extend_item(struct btrfs_trans_handle *trans,
|
||||||
|
unsigned int old_size;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
- slot_orig = path->slots[0];
|
||||||
|
leaf = path->nodes[0];
|
||||||
|
|
||||||
|
nritems = btrfs_header_nritems(leaf);
|
||||||
|
@@ -2541,7 +2527,6 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_item *item;
|
||||||
|
int ret = 0;
|
||||||
|
int slot;
|
||||||
|
- int slot_orig;
|
||||||
|
int i;
|
||||||
|
u32 nritems;
|
||||||
|
u32 total_size = 0;
|
||||||
|
@@ -2565,7 +2550,6 @@ int btrfs_insert_empty_items(struct btrfs_trans_handle *trans,
|
||||||
|
if (ret < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
- slot_orig = path->slots[0];
|
||||||
|
leaf = path->nodes[0];
|
||||||
|
|
||||||
|
nritems = btrfs_header_nritems(leaf);
|
||||||
|
diff --git a/debug-tree.c b/debug-tree.c
|
||||||
|
index 99c12d6..d21a8bd 100644
|
||||||
|
--- a/debug-tree.c
|
||||||
|
+++ b/debug-tree.c
|
||||||
|
@@ -35,44 +35,6 @@ static int print_usage(void)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void print_extent_leaf(struct btrfs_root *root, struct extent_buffer *l)
|
||||||
|
-{
|
||||||
|
- int i;
|
||||||
|
- struct btrfs_item *item;
|
||||||
|
-// struct btrfs_extent_ref *ref;
|
||||||
|
- struct btrfs_key key;
|
||||||
|
- static u64 last = 0;
|
||||||
|
- static u64 last_len = 0;
|
||||||
|
- u32 nr = btrfs_header_nritems(l);
|
||||||
|
- u32 type;
|
||||||
|
-
|
||||||
|
- for (i = 0 ; i < nr ; i++) {
|
||||||
|
- item = btrfs_item_nr(l, i);
|
||||||
|
- btrfs_item_key_to_cpu(l, &key, i);
|
||||||
|
- type = btrfs_key_type(&key);
|
||||||
|
- switch (type) {
|
||||||
|
- case BTRFS_EXTENT_ITEM_KEY:
|
||||||
|
- last_len = key.offset;
|
||||||
|
- last = key.objectid;
|
||||||
|
- break;
|
||||||
|
-#if 0
|
||||||
|
- case BTRFS_EXTENT_REF_KEY:
|
||||||
|
- ref = btrfs_item_ptr(l, i, struct btrfs_extent_ref);
|
||||||
|
- printf("%llu %llu extent back ref root %llu gen %llu "
|
||||||
|
- "owner %llu num_refs %lu\n",
|
||||||
|
- (unsigned long long)last,
|
||||||
|
- (unsigned long long)last_len,
|
||||||
|
- (unsigned long long)btrfs_ref_root(l, ref),
|
||||||
|
- (unsigned long long)btrfs_ref_generation(l, ref),
|
||||||
|
- (unsigned long long)btrfs_ref_objectid(l, ref),
|
||||||
|
- (unsigned long)btrfs_ref_num_refs(l, ref));
|
||||||
|
- break;
|
||||||
|
-#endif
|
||||||
|
- };
|
||||||
|
- fflush(stdout);
|
||||||
|
- }
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
@@ -81,10 +43,7 @@ static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
|
||||||
|
|
||||||
|
if (!eb)
|
||||||
|
return;
|
||||||
|
- if (btrfs_is_leaf(eb)) {
|
||||||
|
- print_extent_leaf(root, eb);
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
|
||||||
|
nr = btrfs_header_nritems(eb);
|
||||||
|
for (i = 0; i < nr; i++) {
|
||||||
|
diff --git a/dir-item.c b/dir-item.c
|
||||||
|
index 71373b8..f00485a 100644
|
||||||
|
--- a/dir-item.c
|
||||||
|
+++ b/dir-item.c
|
||||||
|
@@ -332,5 +332,5 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
|
||||||
|
ret = btrfs_truncate_item(trans, root, path,
|
||||||
|
item_len - sub_item_len, 1);
|
||||||
|
}
|
||||||
|
- return 0;
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
diff --git a/disk-io.c b/disk-io.c
|
||||||
|
index 5bd9cfc..a57cb38 100644
|
||||||
|
--- a/disk-io.c
|
||||||
|
+++ b/disk-io.c
|
||||||
|
@@ -123,7 +123,6 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||||
|
u64 parent_transid)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
- int dev_nr;
|
||||||
|
struct extent_buffer *eb;
|
||||||
|
u64 length;
|
||||||
|
struct btrfs_multi_bio *multi = NULL;
|
||||||
|
@@ -135,7 +134,6 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- dev_nr = 0;
|
||||||
|
length = blocksize;
|
||||||
|
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
||||||
|
bytenr, &length, &multi, 0);
|
||||||
|
@@ -177,7 +175,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
|
||||||
|
u32 blocksize, u64 parent_transid)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
- int dev_nr;
|
||||||
|
struct extent_buffer *eb;
|
||||||
|
u64 length;
|
||||||
|
struct btrfs_multi_bio *multi = NULL;
|
||||||
|
@@ -192,7 +189,6 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
|
||||||
|
if (btrfs_buffer_uptodate(eb, parent_transid))
|
||||||
|
return eb;
|
||||||
|
|
||||||
|
- dev_nr = 0;
|
||||||
|
length = blocksize;
|
||||||
|
while (1) {
|
||||||
|
ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
||||||
|
diff --git a/extent-cache.c b/extent-cache.c
|
||||||
|
index b871e18..3dd6434 100644
|
||||||
|
--- a/extent-cache.c
|
||||||
|
+++ b/extent-cache.c
|
||||||
|
@@ -96,13 +96,11 @@ int insert_existing_cache_extent(struct cache_tree *tree,
|
||||||
|
struct cache_extent *pe)
|
||||||
|
{
|
||||||
|
struct rb_node *found;
|
||||||
|
- struct cache_extent *entry;
|
||||||
|
|
||||||
|
found = tree_insert(&tree->root, pe->start, pe->size, &pe->rb_node);
|
||||||
|
- if (found) {
|
||||||
|
- entry = rb_entry(found, struct cache_extent, rb_node);
|
||||||
|
+ if (found)
|
||||||
|
return -EEXIST;
|
||||||
|
- }
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/extent-tree.c b/extent-tree.c
|
||||||
|
index b2f9bb2..d550854 100644
|
||||||
|
--- a/extent-tree.c
|
||||||
|
+++ b/extent-tree.c
|
||||||
|
@@ -1549,7 +1549,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
|
||||||
|
int i;
|
||||||
|
int level;
|
||||||
|
int ret = 0;
|
||||||
|
- int faili = 0;
|
||||||
|
int (*process_func)(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root,
|
||||||
|
u64, u64, u64, u64, u64, u64);
|
||||||
|
@@ -1592,7 +1591,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
|
||||||
|
parent, ref_root, key.objectid,
|
||||||
|
key.offset);
|
||||||
|
if (ret) {
|
||||||
|
- faili = i;
|
||||||
|
WARN_ON(1);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
@@ -1602,7 +1600,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
|
||||||
|
ret = process_func(trans, root, bytenr, num_bytes,
|
||||||
|
parent, ref_root, level - 1, 0);
|
||||||
|
if (ret) {
|
||||||
|
- faili = i;
|
||||||
|
WARN_ON(1);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
@@ -1611,33 +1608,6 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
WARN_ON(1);
|
||||||
|
-#if 0
|
||||||
|
- for (i =0; i < faili; i++) {
|
||||||
|
- if (level == 0) {
|
||||||
|
- u64 disk_bytenr;
|
||||||
|
- btrfs_item_key_to_cpu(buf, &key, i);
|
||||||
|
- if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
|
||||||
|
- continue;
|
||||||
|
- fi = btrfs_item_ptr(buf, i,
|
||||||
|
- struct btrfs_file_extent_item);
|
||||||
|
- if (btrfs_file_extent_type(buf, fi) ==
|
||||||
|
- BTRFS_FILE_EXTENT_INLINE)
|
||||||
|
- continue;
|
||||||
|
- disk_bytenr = btrfs_file_extent_disk_bytenr(buf, fi);
|
||||||
|
- if (disk_bytenr == 0)
|
||||||
|
- continue;
|
||||||
|
- err = btrfs_free_extent(trans, root, disk_bytenr,
|
||||||
|
- btrfs_file_extent_disk_num_bytes(buf,
|
||||||
|
- fi), 0);
|
||||||
|
- BUG_ON(err);
|
||||||
|
- } else {
|
||||||
|
- bytenr = btrfs_node_blockptr(buf, i);
|
||||||
|
- err = btrfs_free_extent(trans, root, bytenr,
|
||||||
|
- btrfs_level_size(root, level - 1), 0);
|
||||||
|
- BUG_ON(err);
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/extent_io.c b/extent_io.c
|
||||||
|
index 069c199..70fecbb 100644
|
||||||
|
--- a/extent_io.c
|
||||||
|
+++ b/extent_io.c
|
||||||
|
@@ -296,7 +296,6 @@ int set_extent_bits(struct extent_io_tree *tree, u64 start,
|
||||||
|
struct extent_state *prealloc = NULL;
|
||||||
|
struct cache_extent *node;
|
||||||
|
int err = 0;
|
||||||
|
- int set;
|
||||||
|
u64 last_start;
|
||||||
|
u64 last_end;
|
||||||
|
again:
|
||||||
|
@@ -327,7 +326,6 @@ again:
|
||||||
|
* Just lock what we found and keep going
|
||||||
|
*/
|
||||||
|
if (state->start == start && state->end <= end) {
|
||||||
|
- set = state->state & bits;
|
||||||
|
state->state |= bits;
|
||||||
|
merge_state(tree, state);
|
||||||
|
if (last_end == (u64)-1)
|
||||||
|
@@ -352,7 +350,6 @@ again:
|
||||||
|
* desired bit on it.
|
||||||
|
*/
|
||||||
|
if (state->start < start) {
|
||||||
|
- set = state->state & bits;
|
||||||
|
err = split_state(tree, state, prealloc, start);
|
||||||
|
BUG_ON(err == -EEXIST);
|
||||||
|
prealloc = NULL;
|
||||||
|
@@ -398,7 +395,6 @@ again:
|
||||||
|
* We need to split the extent, and set the bit
|
||||||
|
* on the first half
|
||||||
|
*/
|
||||||
|
- set = state->state & bits;
|
||||||
|
err = split_state(tree, state, prealloc, end + 1);
|
||||||
|
BUG_ON(err == -EEXIST);
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 57c88f9..171710e 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -1149,7 +1149,6 @@ int main(int ac, char **av)
|
||||||
|
int zero_end = 1;
|
||||||
|
int option_index = 0;
|
||||||
|
int fd;
|
||||||
|
- int first_fd;
|
||||||
|
int ret;
|
||||||
|
int i;
|
||||||
|
int mixed = 0;
|
||||||
|
@@ -1250,7 +1249,6 @@ int main(int ac, char **av)
|
||||||
|
fprintf(stderr, "unable to open %s\n", file);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
- first_fd = fd;
|
||||||
|
first_file = file;
|
||||||
|
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, &mixed);
|
||||||
|
if (block_count == 0)
|
||||||
|
@@ -1264,7 +1262,6 @@ int main(int ac, char **av)
|
||||||
|
}
|
||||||
|
|
||||||
|
file = output;
|
||||||
|
- first_fd = fd;
|
||||||
|
first_file = file;
|
||||||
|
block_count = size_sourcedir(source_dir, sectorsize,
|
||||||
|
&num_of_meta_chunks, &size_of_data);
|
||||||
|
diff --git a/print-tree.c b/print-tree.c
|
||||||
|
index ac575d5..ddcade1 100644
|
||||||
|
--- a/print-tree.c
|
||||||
|
+++ b/print-tree.c
|
||||||
|
@@ -444,7 +444,6 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
|
||||||
|
struct btrfs_dir_item *di;
|
||||||
|
struct btrfs_inode_item *ii;
|
||||||
|
struct btrfs_file_extent_item *fi;
|
||||||
|
- struct btrfs_csum_item *ci;
|
||||||
|
struct btrfs_block_group_item *bi;
|
||||||
|
struct btrfs_extent_data_ref *dref;
|
||||||
|
struct btrfs_shared_data_ref *sref;
|
||||||
|
@@ -556,11 +555,9 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case BTRFS_CSUM_ITEM_KEY:
|
||||||
|
- ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
|
||||||
|
printf("\t\tcsum item\n");
|
||||||
|
break;
|
||||||
|
case BTRFS_EXTENT_CSUM_KEY:
|
||||||
|
- ci = btrfs_item_ptr(l, i, struct btrfs_csum_item);
|
||||||
|
printf("\t\textent csum item\n");
|
||||||
|
break;
|
||||||
|
case BTRFS_EXTENT_DATA_KEY:
|
||||||
|
diff --git a/volumes.c b/volumes.c
|
||||||
|
index 4bb77e2..61af845 100644
|
||||||
|
--- a/volumes.c
|
||||||
|
+++ b/volumes.c
|
||||||
|
@@ -643,7 +643,6 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
|
||||||
|
struct list_head *cur;
|
||||||
|
struct map_lookup *map;
|
||||||
|
int min_stripe_size = 1 * 1024 * 1024;
|
||||||
|
- u64 physical;
|
||||||
|
u64 calc_size = 8 * 1024 * 1024;
|
||||||
|
u64 min_free;
|
||||||
|
u64 max_chunk_size = 4 * calc_size;
|
||||||
|
@@ -811,7 +810,6 @@ again:
|
||||||
|
btrfs_set_stack_stripe_devid(stripe, device->devid);
|
||||||
|
btrfs_set_stack_stripe_offset(stripe, dev_offset);
|
||||||
|
memcpy(stripe->dev_uuid, device->uuid, BTRFS_UUID_SIZE);
|
||||||
|
- physical = dev_offset;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
BUG_ON(!list_empty(&private_devs));
|
||||||
|
@@ -971,14 +969,12 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len)
|
||||||
|
struct cache_extent *ce;
|
||||||
|
struct map_lookup *map;
|
||||||
|
int ret;
|
||||||
|
- u64 offset;
|
||||||
|
|
||||||
|
ce = find_first_cache_extent(&map_tree->cache_tree, logical);
|
||||||
|
BUG_ON(!ce);
|
||||||
|
BUG_ON(ce->start > logical || ce->start + ce->size < logical);
|
||||||
|
map = container_of(ce, struct map_lookup, ce);
|
||||||
|
|
||||||
|
- offset = logical - ce->start;
|
||||||
|
if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1))
|
||||||
|
ret = map->num_stripes;
|
||||||
|
else if (map->type & BTRFS_BLOCK_GROUP_RAID10)
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
30
0106-btrfs-map-logical-usage-update.patch
Normal file
30
0106-btrfs-map-logical-usage-update.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 1cae9a17f66b138a4d2292cb000e755ff0d1fe58 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Arne Jansen <sensille@gmx.net>
|
||||||
|
Date: Mon, 14 Mar 2011 13:16:30 +0100
|
||||||
|
Subject: [PATCH 06/28] btrfs-map-logical: usage update
|
||||||
|
|
||||||
|
The option to give the number of bytes to read is -b, not -s. Updated
|
||||||
|
usage accordingly.
|
||||||
|
|
||||||
|
Signed-off-by: Arne Jansen <sensille@gmx.net>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs-map-logical.c | 2 +-
|
||||||
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
|
||||||
|
index 8a12074..678ff36 100644
|
||||||
|
--- a/btrfs-map-logical.c
|
||||||
|
+++ b/btrfs-map-logical.c
|
||||||
|
@@ -88,7 +88,7 @@ static void print_usage(void)
|
||||||
|
fprintf(stderr, "\t-l Logical extent to map\n");
|
||||||
|
fprintf(stderr, "\t-c Copy of the extent to read (usually 1 or 2)\n");
|
||||||
|
fprintf(stderr, "\t-o Output file to hold the extent\n");
|
||||||
|
- fprintf(stderr, "\t-s Number of bytes to read\n");
|
||||||
|
+ fprintf(stderr, "\t-b Number of bytes to read\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
138
0107-btrfs-progs-cast-u64-to-long-long-to-avoid-printf-wa.patch
Normal file
138
0107-btrfs-progs-cast-u64-to-long-long-to-avoid-printf-wa.patch
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
From 2aba8e8914fa7b21e426ab6df1fc23ed684b149f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Anton Blanchard <anton@samba.org>
|
||||||
|
Date: Thu, 7 Apr 2011 21:02:04 +1000
|
||||||
|
Subject: [PATCH 07/28] btrfs-progs: cast u64 to long long to avoid printf
|
||||||
|
warnings
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
When building on ppc64 I hit a number of warnings in printf:
|
||||||
|
|
||||||
|
btrfs-map-logical.c:69: error: format ‘%Lu’ expects type ‘long long
|
||||||
|
unsigned int’, but argument 4 has type ‘u64’
|
||||||
|
|
||||||
|
Fix them.
|
||||||
|
|
||||||
|
Signed-off-by: Anton Blanchard <anton@samba.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs-list.c | 3 ++-
|
||||||
|
btrfs-map-logical.c | 4 ++--
|
||||||
|
btrfsctl.c | 2 +-
|
||||||
|
debug-tree.c | 3 ++-
|
||||||
|
disk-io.c | 6 ++++--
|
||||||
|
extent-tree.c | 3 ++-
|
||||||
|
print-tree.c | 2 +-
|
||||||
|
7 files changed, 14 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-list.c b/btrfs-list.c
|
||||||
|
index abcc2f4..f804dfc 100644
|
||||||
|
--- a/btrfs-list.c
|
||||||
|
+++ b/btrfs-list.c
|
||||||
|
@@ -249,7 +249,8 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- printf("ID %llu top level %llu path %s\n", ri->root_id, top_id,
|
||||||
|
+ printf("ID %llu top level %llu path %s\n",
|
||||||
|
+ (unsigned long long)ri->root_id, (unsigned long long)top_id,
|
||||||
|
full_path);
|
||||||
|
free(full_path);
|
||||||
|
return 0;
|
||||||
|
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
|
||||||
|
index 678ff36..6d3ef7a 100644
|
||||||
|
--- a/btrfs-map-logical.c
|
||||||
|
+++ b/btrfs-map-logical.c
|
||||||
|
@@ -63,8 +63,8 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
|
||||||
|
eb->dev_bytenr = multi->stripes[0].physical;
|
||||||
|
|
||||||
|
fprintf(info_file, "mirror %d logical %Lu physical %Lu "
|
||||||
|
- "device %s\n", mirror_num, bytenr, eb->dev_bytenr,
|
||||||
|
- device->name);
|
||||||
|
+ "device %s\n", mirror_num, (unsigned long long)bytenr,
|
||||||
|
+ (unsigned long long)eb->dev_bytenr, device->name);
|
||||||
|
kfree(multi);
|
||||||
|
|
||||||
|
if (!copy || mirror_num == copy)
|
||||||
|
diff --git a/btrfsctl.c b/btrfsctl.c
|
||||||
|
index 73e20ec..d45e2a7 100644
|
||||||
|
--- a/btrfsctl.c
|
||||||
|
+++ b/btrfsctl.c
|
||||||
|
@@ -250,7 +250,7 @@ int main(int ac, char **av)
|
||||||
|
args.fd = fd;
|
||||||
|
ret = ioctl(snap_fd, command, &args);
|
||||||
|
} else if (command == BTRFS_IOC_DEFAULT_SUBVOL) {
|
||||||
|
- printf("objectid is %llu\n", objectid);
|
||||||
|
+ printf("objectid is %llu\n", (unsigned long long)objectid);
|
||||||
|
ret = ioctl(fd, command, &objectid);
|
||||||
|
} else
|
||||||
|
ret = ioctl(fd, command, &args);
|
||||||
|
diff --git a/debug-tree.c b/debug-tree.c
|
||||||
|
index d21a8bd..34cefe9 100644
|
||||||
|
--- a/debug-tree.c
|
||||||
|
+++ b/debug-tree.c
|
||||||
|
@@ -125,7 +125,8 @@ int main(int ac, char **av)
|
||||||
|
root->nodesize, 0);
|
||||||
|
}
|
||||||
|
if (!leaf) {
|
||||||
|
- fprintf(stderr, "failed to read %llu\n", block_only);
|
||||||
|
+ fprintf(stderr, "failed to read %llu\n",
|
||||||
|
+ (unsigned long long)block_only);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
btrfs_print_tree(root, leaf, 0);
|
||||||
|
diff --git a/disk-io.c b/disk-io.c
|
||||||
|
index a57cb38..8b2133b 100644
|
||||||
|
--- a/disk-io.c
|
||||||
|
+++ b/disk-io.c
|
||||||
|
@@ -674,7 +674,8 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
|
||||||
|
~BTRFS_FEATURE_INCOMPAT_SUPP;
|
||||||
|
if (features) {
|
||||||
|
printk("couldn't open because of unsupported "
|
||||||
|
- "option features (%Lx).\n", features);
|
||||||
|
+ "option features (%Lx).\n",
|
||||||
|
+ (unsigned long long)features);
|
||||||
|
BUG_ON(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -688,7 +689,8 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
|
||||||
|
~BTRFS_FEATURE_COMPAT_RO_SUPP;
|
||||||
|
if (writes && features) {
|
||||||
|
printk("couldn't open RDWR because of unsupported "
|
||||||
|
- "option features (%Lx).\n", features);
|
||||||
|
+ "option features (%Lx).\n",
|
||||||
|
+ (unsigned long long)features);
|
||||||
|
BUG_ON(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/extent-tree.c b/extent-tree.c
|
||||||
|
index d550854..1c606c9 100644
|
||||||
|
--- a/extent-tree.c
|
||||||
|
+++ b/extent-tree.c
|
||||||
|
@@ -1448,7 +1448,8 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
|
||||||
|
goto out;
|
||||||
|
if (ret != 0) {
|
||||||
|
btrfs_print_leaf(root, path->nodes[0]);
|
||||||
|
- printk("failed to find block number %Lu\n", bytenr);
|
||||||
|
+ printk("failed to find block number %Lu\n",
|
||||||
|
+ (unsigned long long)bytenr);
|
||||||
|
BUG();
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/print-tree.c b/print-tree.c
|
||||||
|
index ddcade1..59c23c5 100644
|
||||||
|
--- a/print-tree.c
|
||||||
|
+++ b/print-tree.c
|
||||||
|
@@ -496,7 +496,7 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
|
||||||
|
case BTRFS_DIR_LOG_ITEM_KEY:
|
||||||
|
dlog = btrfs_item_ptr(l, i, struct btrfs_dir_log_item);
|
||||||
|
printf("\t\tdir log end %Lu\n",
|
||||||
|
- btrfs_dir_log_end(l, dlog));
|
||||||
|
+ (unsigned long long)btrfs_dir_log_end(l, dlog));
|
||||||
|
break;
|
||||||
|
case BTRFS_ORPHAN_ITEM_KEY:
|
||||||
|
printf("\t\torphan item\n");
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
57
0108-Added-support-for-an-additional-ioctl.patch
Normal file
57
0108-Added-support-for-an-additional-ioctl.patch
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
From 5cfea320d7c0119589009cd445c8938be5db1d90 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Date: Tue, 26 Apr 2011 10:02:40 +0200
|
||||||
|
Subject: [PATCH 08/28] Added support for an additional ioctl.
|
||||||
|
|
||||||
|
Added BTRFS_IOC_SNAP_CREATE_V2 and struct btrfs_ioctl_vol_args_v2 as
|
||||||
|
defined in fs/btrfs/ioctl.h in the kernel sources.
|
||||||
|
|
||||||
|
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
ioctl.h | 17 +++++++++++++++++
|
||||||
|
1 files changed, 17 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ioctl.h b/ioctl.h
|
||||||
|
index bb7b9e0..5aa288b 100644
|
||||||
|
--- a/ioctl.h
|
||||||
|
+++ b/ioctl.h
|
||||||
|
@@ -30,6 +30,20 @@ struct btrfs_ioctl_vol_args {
|
||||||
|
char name[BTRFS_PATH_NAME_MAX + 1];
|
||||||
|
};
|
||||||
|
|
||||||
|
+#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
|
||||||
|
+#define BTRFS_SUBVOL_NAME_MAX 4039
|
||||||
|
+
|
||||||
|
+struct btrfs_ioctl_vol_args_v2 {
|
||||||
|
+ __s64 fd;
|
||||||
|
+ __u64 transid;
|
||||||
|
+ __u64 flags;
|
||||||
|
+ __u64 unused[4];
|
||||||
|
+ char name[BTRFS_SUBVOL_NAME_MAX + 1];
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define BTRFS_FSID_SIZE 16
|
||||||
|
+#define BTRFS_UUID_SIZE 16
|
||||||
|
+
|
||||||
|
struct btrfs_ioctl_search_key {
|
||||||
|
/* which root are we searching. 0 is the tree of tree roots */
|
||||||
|
__u64 tree_id;
|
||||||
|
@@ -139,6 +153,7 @@ struct btrfs_ioctl_space_args {
|
||||||
|
struct btrfs_ioctl_space_info spaces[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
+/* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */
|
||||||
|
#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
|
||||||
|
struct btrfs_ioctl_vol_args)
|
||||||
|
#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
|
||||||
|
@@ -176,4 +191,6 @@ struct btrfs_ioctl_space_args {
|
||||||
|
#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
|
||||||
|
#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
|
||||||
|
struct btrfs_ioctl_space_args)
|
||||||
|
+#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
|
||||||
|
+ struct btrfs_ioctl_vol_args_v2)
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
95
0109-Add-support-for-read-only-subvolumes.patch
Normal file
95
0109-Add-support-for-read-only-subvolumes.patch
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
From fd296ee4952a542d18ed1bfe4adbf247474f7d21 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Date: Tue, 26 Apr 2011 10:02:41 +0200
|
||||||
|
Subject: [PATCH 09/28] Add support for read-only subvolumes.
|
||||||
|
|
||||||
|
Use BTRFS_IOC_CREATE_SNAP_V2 instead of BTRFS_IOC_CREATE_SNAP and add
|
||||||
|
an option for the creation of a readonly snapshot.
|
||||||
|
|
||||||
|
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs_cmds.c | 48 ++++++++++++++++++++++++++++++++++++++++--------
|
||||||
|
1 files changed, 40 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 32f6b25..505322d 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -44,7 +44,7 @@
|
||||||
|
|
||||||
|
#ifdef __CHECKER__
|
||||||
|
#define BLKGETSIZE64 0
|
||||||
|
-#define BTRFS_IOC_SNAP_CREATE 0
|
||||||
|
+#define BTRFS_IOC_SNAP_CREATE_V2 0
|
||||||
|
#define BTRFS_VOL_NAME_MAX 255
|
||||||
|
struct btrfs_ioctl_vol_args { char name[BTRFS_VOL_NAME_MAX]; };
|
||||||
|
static inline int ioctl(int fd, int define, void *arg) { return 0; }
|
||||||
|
@@ -330,13 +330,38 @@ int do_subvol_list(int argc, char **argv)
|
||||||
|
int do_clone(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *subvol, *dst;
|
||||||
|
- int res, fd, fddst, len, e;
|
||||||
|
+ int res, fd, fddst, len, e, optind = 0, readonly = 0;
|
||||||
|
char *newname;
|
||||||
|
char *dstdir;
|
||||||
|
+ struct btrfs_ioctl_vol_args_v2 args;
|
||||||
|
|
||||||
|
- subvol = argv[1];
|
||||||
|
- dst = argv[2];
|
||||||
|
- struct btrfs_ioctl_vol_args args;
|
||||||
|
+ memset(&args, 0, sizeof(args));
|
||||||
|
+
|
||||||
|
+ while (1) {
|
||||||
|
+ int c = getopt(argc, argv, "r");
|
||||||
|
+
|
||||||
|
+ if (c < 0)
|
||||||
|
+ break;
|
||||||
|
+ switch (c) {
|
||||||
|
+ case 'r':
|
||||||
|
+ optind++;
|
||||||
|
+ readonly = 1;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ fprintf(stderr,
|
||||||
|
+ "Invalid arguments for subvolume snapshot\n");
|
||||||
|
+ free(argv);
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (argc - optind < 2) {
|
||||||
|
+ fprintf(stderr, "Invalid arguments for subvolume snapshot\n");
|
||||||
|
+ free(argv);
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ subvol = argv[optind+1];
|
||||||
|
+ dst = argv[optind+2];
|
||||||
|
|
||||||
|
res = test_issubvolume(subvol);
|
||||||
|
if(res<0){
|
||||||
|
@@ -392,11 +417,18 @@ int do_clone(int argc, char **argv)
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
- printf("Create a snapshot of '%s' in '%s/%s'\n",
|
||||||
|
- subvol, dstdir, newname);
|
||||||
|
+ if (readonly) {
|
||||||
|
+ args.flags |= BTRFS_SUBVOL_RDONLY;
|
||||||
|
+ printf("Create a readonly snapshot of '%s' in '%s/%s'\n",
|
||||||
|
+ subvol, dstdir, newname);
|
||||||
|
+ } else {
|
||||||
|
+ printf("Create a snapshot of '%s' in '%s/%s'\n",
|
||||||
|
+ subvol, dstdir, newname);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
args.fd = fd;
|
||||||
|
strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
- res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args);
|
||||||
|
+ res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE_V2, &args);
|
||||||
|
e = errno;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
From 4e5f702b00a0717aa29fabad76cb8c94a53b4728 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Date: Tue, 26 Apr 2011 10:02:42 +0200
|
||||||
|
Subject: [PATCH 10/28] Support the new parameters in do_clone(int argc,
|
||||||
|
char** argv).
|
||||||
|
|
||||||
|
Now 'btrfs subvolume snapshot' takes not two but only at least two
|
||||||
|
parameters. Additionally, the help message is updated accordingly.
|
||||||
|
|
||||||
|
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs.c | 4 ++--
|
||||||
|
1 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 742dd27..c90ee48 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -50,8 +50,8 @@ static struct Command commands[] = {
|
||||||
|
avoid short commands different for the case only
|
||||||
|
*/
|
||||||
|
{ do_clone, 2,
|
||||||
|
- "subvolume snapshot", "<source> [<dest>/]<name>\n"
|
||||||
|
- "Create a writable snapshot of the subvolume <source> with\n"
|
||||||
|
+ "subvolume snapshot", "[-r] <source> [<dest>/]<name>\n"
|
||||||
|
+ "Create a writable/readonly snapshot of the subvolume <source> with\n"
|
||||||
|
"the name <name> in the <dest> directory.",
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
43
0112-Updated-manpage-for-btrfs-subvolume-snapshot.patch
Normal file
43
0112-Updated-manpage-for-btrfs-subvolume-snapshot.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From ff26077c61eabdf2ddad810e994540f644975310 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Date: Tue, 26 Apr 2011 10:02:44 +0200
|
||||||
|
Subject: [PATCH 12/28] Updated manpage for btrfs subvolume snapshot.
|
||||||
|
|
||||||
|
Signed-off-by: Andreas Philipp <philipp.andreas@gmail.com>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
man/btrfs.8.in | 11 ++++++-----
|
||||||
|
1 files changed, 6 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index 6f92f91..cb32679 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -5,7 +5,7 @@
|
||||||
|
.SH NAME
|
||||||
|
btrfs \- control a btrfs filesystem
|
||||||
|
.SH SYNOPSIS
|
||||||
|
-\fBbtrfs\fP \fBsubvolume snapshot\fP\fI <source> [<dest>/]<name>\fP
|
||||||
|
+\fBbtrfs\fP \fBsubvolume snapshot\fP\fI [-r] <source> [<dest>/]<name>\fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBsubvolume delete\fP\fI <subvolume>\fP
|
||||||
|
.PP
|
||||||
|
@@ -76,10 +76,11 @@ commands.
|
||||||
|
.SH COMMANDS
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBsubvolume snapshot\fR\fI <source> [<dest>/]<name>\fR
|
||||||
|
-Create a writable snapshot of the subvolume \fI<source>\fR with the name
|
||||||
|
-\fI<name>\fR in the \fI<dest>\fR directory. If \fI<source>\fR is not a
|
||||||
|
-subvolume, \fBbtrfs\fR returns an error.
|
||||||
|
+\fBsubvolume snapshot\fR\fI [-r] <source> [<dest>/]<name>\fR
|
||||||
|
+Create a writable/readonly snapshot of the subvolume \fI<source>\fR with the
|
||||||
|
+name \fI<name>\fR in the \fI<dest>\fR directory. If \fI<source>\fR is not a
|
||||||
|
+subvolume, \fBbtrfs\fR returns an error. If \fI-r\fR is given, the snapshot
|
||||||
|
+will be readonly.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
\fBsubvolume delete\fR\fI <subvolume>\fR
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
29
0113-btrfs-progs-Fix-over-sized-limit-on-buffer.patch
Normal file
29
0113-btrfs-progs-Fix-over-sized-limit-on-buffer.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From 3295594b099c06935f5299c8234effeeeeea5d11 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
Date: Sun, 12 Jun 2011 21:52:39 +0100
|
||||||
|
Subject: [PATCH 13/28] btrfs-progs: Fix over-sized limit on buffer
|
||||||
|
|
||||||
|
gcc-4.4 complains (rightly) that the strncpy has a limit too large for
|
||||||
|
the array it's copying into. Use the correct array length.
|
||||||
|
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs_cmds.c | 2 +-
|
||||||
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs_cmds.c b/btrfs_cmds.c
|
||||||
|
index 505322d..da5bd91 100644
|
||||||
|
--- a/btrfs_cmds.c
|
||||||
|
+++ b/btrfs_cmds.c
|
||||||
|
@@ -427,7 +427,7 @@ int do_clone(int argc, char **argv)
|
||||||
|
}
|
||||||
|
|
||||||
|
args.fd = fd;
|
||||||
|
- strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
|
||||||
|
+ strncpy(args.name, newname, BTRFS_SUBVOL_NAME_MAX);
|
||||||
|
res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE_V2, &args);
|
||||||
|
e = errno;
|
||||||
|
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
29
0114-incorrect-argument-checking-for-btrfs-sub-snap-r.patch
Normal file
29
0114-incorrect-argument-checking-for-btrfs-sub-snap-r.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From d77a169154ad56e502ae63b3692c990038c96643 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stephane Chazelas <stephane.chazelas@gmail.com>
|
||||||
|
Date: Thu, 30 Jun 2011 13:34:38 +0100
|
||||||
|
Subject: [PATCH 14/28] incorrect argument checking for "btrfs sub snap -r"
|
||||||
|
|
||||||
|
Looks like this was missing in integration-20110626 for the
|
||||||
|
readonly snapshot patch:
|
||||||
|
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs.c | 2 +-
|
||||||
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index c90ee48..9cc2665 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -49,7 +49,7 @@ static struct Command commands[] = {
|
||||||
|
/*
|
||||||
|
avoid short commands different for the case only
|
||||||
|
*/
|
||||||
|
- { do_clone, 2,
|
||||||
|
+ { do_clone, -2,
|
||||||
|
"subvolume snapshot", "[-r] <source> [<dest>/]<name>\n"
|
||||||
|
"Create a writable/readonly snapshot of the subvolume <source> with\n"
|
||||||
|
"the name <name> in the <dest> directory.",
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,62 @@
|
|||||||
|
From 0f1835a980fbae38e21c07e7ee5ece97679b87fe Mon Sep 17 00:00:00 2001
|
||||||
|
From: Arne Jansen <sensille@gmx.net>
|
||||||
|
Date: Thu, 5 May 2011 16:16:12 +0200
|
||||||
|
Subject: [PATCH 15/28] btrfs progs: fix extra metadata chunk allocation in
|
||||||
|
--mixed case
|
||||||
|
|
||||||
|
When creating a mixed fs with mkfs, an extra metadata chunk got allocated.
|
||||||
|
This is because btrfs_reserve_extent calls do_chunk_alloc for METADATA,
|
||||||
|
which in turn wasn't able to find the proper space_info, as __find_space_info
|
||||||
|
did a hard compare of the flags. It is now sufficient for the space_info to
|
||||||
|
include the proper flag. This reflects the change done to the kernel code
|
||||||
|
to support mixed chunks.
|
||||||
|
Also for a subsequent chunk allocation (which should not be hit in the mkfs
|
||||||
|
case), the chunk is now created with the flags from the space_info instead
|
||||||
|
of the requested flags. A better solution would be to pull the full changeset
|
||||||
|
for the mixed case from the kernel into the user mode (or, even better, share
|
||||||
|
the code)
|
||||||
|
|
||||||
|
The additional chunk probably confused block_rsv calculation, which in turn
|
||||||
|
led to severeal ENOSPC Oopses.
|
||||||
|
|
||||||
|
Signed-off-by: Arne Jansen <sensille@gmx.net>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
extent-tree.c | 7 ++++---
|
||||||
|
1 files changed, 4 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/extent-tree.c b/extent-tree.c
|
||||||
|
index 1c606c9..16e11fc 100644
|
||||||
|
--- a/extent-tree.c
|
||||||
|
+++ b/extent-tree.c
|
||||||
|
@@ -1706,7 +1706,7 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info,
|
||||||
|
struct btrfs_space_info *found;
|
||||||
|
list_for_each(cur, head) {
|
||||||
|
found = list_entry(cur, struct btrfs_space_info, list);
|
||||||
|
- if (found->flags == flags)
|
||||||
|
+ if (found->flags & flags)
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
@@ -1783,7 +1783,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
|
||||||
|
thresh)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes, flags);
|
||||||
|
+ ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes,
|
||||||
|
+ space_info->flags);
|
||||||
|
if (ret == -ENOSPC) {
|
||||||
|
space_info->full = 1;
|
||||||
|
return 0;
|
||||||
|
@@ -1791,7 +1792,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
BUG_ON(ret);
|
||||||
|
|
||||||
|
- ret = btrfs_make_block_group(trans, extent_root, 0, flags,
|
||||||
|
+ ret = btrfs_make_block_group(trans, extent_root, 0, space_info->flags,
|
||||||
|
BTRFS_FIRST_CHUNK_TREE_OBJECTID, start, num_bytes);
|
||||||
|
BUG_ON(ret);
|
||||||
|
return 0;
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
58
0116-make-btrfs-filesystem-label-command-actually-work.patch
Normal file
58
0116-make-btrfs-filesystem-label-command-actually-work.patch
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
From 55e0c7a250d6573fc9f8bdc561e73e1d02b3f3dc Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Fajar A. Nugraha" <list@fajar.net>
|
||||||
|
Date: Thu, 2 Jun 2011 09:54:27 +0700
|
||||||
|
Subject: [PATCH 16/28] make "btrfs filesystem label" command actually work
|
||||||
|
|
||||||
|
This simple patch makes "btrfs filesystem label" command actually work.
|
||||||
|
|
||||||
|
On tmp branch, commit d1dc6a9, "btrfs filesystem label" functionality
|
||||||
|
was introduced. However the commit lacks one component that lets
|
||||||
|
"btrfs" accept "filesystem label" command.
|
||||||
|
Test case:
|
||||||
|
|
||||||
|
/dev/loop0
|
||||||
|
|
||||||
|
WARNING! - Btrfs Btrfs v0.19 IS EXPERIMENTAL
|
||||||
|
WARNING! - see http://btrfs.wiki.kernel.org before using
|
||||||
|
|
||||||
|
fs created label old on /dev/loop0
|
||||||
|
nodesize 4096 leafsize 4096 sectorsize 4096 size 1.00GB
|
||||||
|
Btrfs Btrfs v0.19
|
||||||
|
|
||||||
|
old
|
||||||
|
|
||||||
|
new
|
||||||
|
|
||||||
|
FATAL: the filesystem has to be unmounted
|
||||||
|
|
||||||
|
new
|
||||||
|
|
||||||
|
Not sure if you need if you need a signoff for something as trivial as
|
||||||
|
this, but here it is just in case.
|
||||||
|
|
||||||
|
Signed-off-by: Fajar A. Nugraha <list@fajar.net>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs.c | 6 ++++++
|
||||||
|
1 files changed, 6 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs.c b/btrfs.c
|
||||||
|
index 9cc2665..ff84260 100644
|
||||||
|
--- a/btrfs.c
|
||||||
|
+++ b/btrfs.c
|
||||||
|
@@ -119,6 +119,12 @@ static struct Command commands[] = {
|
||||||
|
"Balance the chunks across the device.",
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
+ { do_change_label, -1,
|
||||||
|
+ "filesystem label", "<device> [<newlabel>]\n"
|
||||||
|
+ "With one argument, get the label of filesystem on <device>.\n"
|
||||||
|
+ "If <newlabel> is passed, set the filesystem label to <newlabel>.\n"
|
||||||
|
+ "The filesystem must be unmounted.\n"
|
||||||
|
+ },
|
||||||
|
{ do_scan, 999,
|
||||||
|
"device scan", "[<device>...]\n"
|
||||||
|
"Scan all device for or the passed device for a btrfs\n"
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
48
0118-mkfs.btrfs-fail-on-scandir-error-r-mode.patch
Normal file
48
0118-mkfs.btrfs-fail-on-scandir-error-r-mode.patch
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
From 0b71340df8491fbb78af2c374adaac6b11608e25 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:18 +0300
|
||||||
|
Subject: [PATCH 18/28] mkfs.btrfs: fail on scandir error (-r mode)
|
||||||
|
|
||||||
|
mkfs.btrfs does not handle relative pathnames for now. When
|
||||||
|
they are passed to it it creates empty image. So first time
|
||||||
|
I thought it does not work at all.
|
||||||
|
|
||||||
|
This patch adds error handling for scandir(). With patch it behaves
|
||||||
|
this way:
|
||||||
|
|
||||||
|
$ mkfs.btrfs -r ./root
|
||||||
|
...
|
||||||
|
fs created label (null) on output.img
|
||||||
|
nodesize 4096 leafsize 4096 sectorsize 4096 size 256.00MB
|
||||||
|
Btrfs v0.19-52-g438c5ff-dirty
|
||||||
|
scandir for ./root failed: No such file or directory
|
||||||
|
unable to traverse_directory
|
||||||
|
Making image is aborted.
|
||||||
|
mkfs.btrfs: mkfs.c:1402: main: Assertion `!(ret)' failed.
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 6 ++++++
|
||||||
|
1 files changed, 6 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 171710e..efd85d5 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -895,6 +895,12 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
count = scandir(parent_dir_entry->path, &files,
|
||||||
|
directory_select, NULL);
|
||||||
|
+ if (count == -1)
|
||||||
|
+ {
|
||||||
|
+ fprintf(stderr, "scandir for %s failed: %s\n",
|
||||||
|
+ parent_dir_name, strerror (errno));
|
||||||
|
+ goto fail;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
cur_file = files[i];
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
From e97ed92c902fdfb456d7e21e05692354804f2113 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:19 +0300
|
||||||
|
Subject: [PATCH 19/28] mkfs.btrfs: return some defined value instead of
|
||||||
|
garbage when lookup checksum
|
||||||
|
|
||||||
|
==31873== Command: ./mkfs.btrfs -r /some/root/
|
||||||
|
==31873== Parent PID: 31872
|
||||||
|
==31873==
|
||||||
|
==31873== Conditional jump or move depends on uninitialised value(s)
|
||||||
|
==31873== at 0x42C3D0: add_file_items (mkfs.c:792)
|
||||||
|
==31873== by 0x42CAB3: traverse_directory (mkfs.c:948)
|
||||||
|
==31873== by 0x42CF11: make_image (mkfs.c:1047)
|
||||||
|
==31873== by 0x42DE53: main (mkfs.c:1401)
|
||||||
|
==31873== Uninitialised value was created by a stack allocation
|
||||||
|
==31873== at 0x41B1B1: btrfs_csum_file_block (file-item.c:195)
|
||||||
|
|
||||||
|
'ret' value was not initialized for 'found' branch.
|
||||||
|
|
||||||
|
The same fix sits in kernel:
|
||||||
|
> commit 639cb58675ce9b507eed9c3d6b3335488079b21a
|
||||||
|
> Author: Chris Mason <chris.mason@oracle.com>
|
||||||
|
> Date: Thu Aug 28 06:15:25 2008 -0400
|
||||||
|
>
|
||||||
|
> Btrfs: Fix variable init during csum creation
|
||||||
|
>
|
||||||
|
> Signed-off-by: Chris Mason <chris.mason@oracle.com>
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
file-item.c | 1 +
|
||||||
|
1 files changed, 1 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/file-item.c b/file-item.c
|
||||||
|
index 9732282..47f6ad2 100644
|
||||||
|
--- a/file-item.c
|
||||||
|
+++ b/file-item.c
|
||||||
|
@@ -218,6 +218,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
|
||||||
|
item = btrfs_lookup_csum(trans, root, path, bytenr, 1);
|
||||||
|
if (!IS_ERR(item)) {
|
||||||
|
leaf = path->nodes[0];
|
||||||
|
+ ret = 0;
|
||||||
|
goto found;
|
||||||
|
}
|
||||||
|
ret = PTR_ERR(item);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
48
0120-mkfs.btrfs-fix-symlink-names-writing.patch
Normal file
48
0120-mkfs.btrfs-fix-symlink-names-writing.patch
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
From b2ffa3e547d84be5c098fc1e4046ee10447485ba Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:20 +0300
|
||||||
|
Subject: [PATCH 20/28] mkfs.btrfs: fix symlink names writing
|
||||||
|
|
||||||
|
Found by valgrind:
|
||||||
|
==8968== Use of uninitialised value of size 8
|
||||||
|
==8968== at 0x41CE7D: crc32c_le (crc32c.c:98)
|
||||||
|
==8968== by 0x40A1D0: csum_tree_block_size (disk-io.c:82)
|
||||||
|
==8968== by 0x40A2D4: csum_tree_block (disk-io.c:105)
|
||||||
|
==8968== by 0x40A7D6: write_tree_block (disk-io.c:241)
|
||||||
|
==8968== by 0x40ACEE: __commit_transaction (disk-io.c:354)
|
||||||
|
==8968== by 0x40AE9E: btrfs_commit_transaction (disk-io.c:385)
|
||||||
|
==8968== by 0x42CF66: make_image (mkfs.c:1061)
|
||||||
|
==8968== by 0x42DE63: main (mkfs.c:1410)
|
||||||
|
==8968== Uninitialised value was created by a stack allocation
|
||||||
|
==8968== at 0x42B5FB: add_inode_items (mkfs.c:493)
|
||||||
|
|
||||||
|
readlink(2) does not write '\0' for us, so make it manually.
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 4 +++-
|
||||||
|
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index efd85d5..5e483dc 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -709,11 +709,13 @@ static int add_symbolic_link(struct btrfs_trans_handle *trans,
|
||||||
|
fprintf(stderr, "readlink failed for %s\n", path_name);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
- if (ret > sectorsize) {
|
||||||
|
+ if (ret >= sectorsize) {
|
||||||
|
fprintf(stderr, "symlink too long for %s", path_name);
|
||||||
|
ret = -1;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ buf[ret] = '\0'; /* readlink does not do it for us */
|
||||||
|
ret = btrfs_insert_inline_extent(trans, root, objectid, 0,
|
||||||
|
buf, ret + 1);
|
||||||
|
fail:
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,66 @@
|
|||||||
|
From 6b8dacb969d0e4c61c4a2a6f9d6144e934595f73 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:21 +0300
|
||||||
|
Subject: [PATCH 21/28] mkfs.btrfs: write zeroes instead on uninitialized
|
||||||
|
data.
|
||||||
|
|
||||||
|
Found by valgrind:
|
||||||
|
==8968== Use of uninitialised value of size 8
|
||||||
|
==8968== at 0x41CE7D: crc32c_le (crc32c.c:98)
|
||||||
|
==8968== by 0x40A1D0: csum_tree_block_size (disk-io.c:82)
|
||||||
|
==8968== by 0x40A2D4: csum_tree_block (disk-io.c:105)
|
||||||
|
==8968== by 0x40A7D6: write_tree_block (disk-io.c:241)
|
||||||
|
==8968== by 0x40ACEE: __commit_transaction (disk-io.c:354)
|
||||||
|
==8968== by 0x40AE9E: btrfs_commit_transaction (disk-io.c:385)
|
||||||
|
==8968== by 0x42CF66: make_image (mkfs.c:1061)
|
||||||
|
==8968== by 0x42DE63: main (mkfs.c:1410)
|
||||||
|
==8968== Uninitialised value was created by a stack allocation
|
||||||
|
==8968== at 0x42B5FB: add_inode_items (mkfs.c:493)
|
||||||
|
|
||||||
|
1. On-disk inode format has reserved (and thus, random at alloc time) fields:
|
||||||
|
btrfs_inode_item: __le64 reserved[4]
|
||||||
|
2. Sometimes extents are created on disk without writing data there.
|
||||||
|
(Or at least not all data is written there). Kernel code always had
|
||||||
|
it kzalloc'ed.
|
||||||
|
Zero them all.
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
extent_io.c | 1 +
|
||||||
|
mkfs.c | 7 +++++++
|
||||||
|
2 files changed, 8 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/extent_io.c b/extent_io.c
|
||||||
|
index 70fecbb..8f0a876 100644
|
||||||
|
--- a/extent_io.c
|
||||||
|
+++ b/extent_io.c
|
||||||
|
@@ -568,6 +568,7 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
|
||||||
|
BUG();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
+ memset(eb, 0, sizeof(struct extent_buffer) + blocksize);
|
||||||
|
|
||||||
|
eb->start = bytenr;
|
||||||
|
eb->len = blocksize;
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 5e483dc..428ec18 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -411,6 +411,13 @@ static int fill_inode_item(struct btrfs_trans_handle *trans,
|
||||||
|
u64 blocks = 0;
|
||||||
|
u64 sectorsize = root->sectorsize;
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * btrfs_inode_item has some reserved fields
|
||||||
|
+ * and represents on-disk inode entry, so
|
||||||
|
+ * zero everything to prevent information leak
|
||||||
|
+ */
|
||||||
|
+ memset(dst, 0, sizeof (*dst));
|
||||||
|
+
|
||||||
|
btrfs_set_stack_inode_generation(dst, trans->transid);
|
||||||
|
btrfs_set_stack_inode_size(dst, src->st_size);
|
||||||
|
btrfs_set_stack_inode_nbytes(dst, 0);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
42
0122-mkfs.btrfs-free-buffers-allocated-by-pretty_sizes.patch
Normal file
42
0122-mkfs.btrfs-free-buffers-allocated-by-pretty_sizes.patch
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
From 647520313d86686725d813e0846dccb533557576 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:22 +0300
|
||||||
|
Subject: [PATCH 22/28] mkfs.btrfs: free buffers allocated by pretty_sizes
|
||||||
|
|
||||||
|
found by valgrind:
|
||||||
|
==2559== 16 bytes in 1 blocks are definitely lost in loss record 3 of 19
|
||||||
|
==2559== at 0x4C2720E: malloc (vg_replace_malloc.c:236)
|
||||||
|
==2559== by 0x412F7E: pretty_sizes (utils.c:1054)
|
||||||
|
==2559== by 0x4179E9: main (mkfs.c:1395)
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 4 +++-
|
||||||
|
1 files changed, 3 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 428ec18..5701c0a 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -1175,6 +1175,7 @@ int main(int ac, char **av)
|
||||||
|
char *output = "output.img";
|
||||||
|
u64 num_of_meta_chunks = 0;
|
||||||
|
u64 size_of_data = 0;
|
||||||
|
+ char *pretty_buf;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
int c;
|
||||||
|
@@ -1392,7 +1393,8 @@ raid_groups:
|
||||||
|
printf("fs created label %s on %s\n\tnodesize %u leafsize %u "
|
||||||
|
"sectorsize %u size %s\n",
|
||||||
|
label, first_file, nodesize, leafsize, sectorsize,
|
||||||
|
- pretty_sizes(btrfs_super_total_bytes(&root->fs_info->super_copy)));
|
||||||
|
+ pretty_buf = pretty_sizes(btrfs_super_total_bytes(&root->fs_info->super_copy)));
|
||||||
|
+ free(pretty_buf);
|
||||||
|
|
||||||
|
printf("%s\n", BTRFS_BUILD_VERSION);
|
||||||
|
btrfs_commit_transaction(trans, root);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,63 @@
|
|||||||
|
From 52ba789b8b6d316df29639379daa764ed630718b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:23 +0300
|
||||||
|
Subject: [PATCH 23/28] mkfs.btrfs: fix memory leak caused by 'scandir()'
|
||||||
|
calls
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 16 ++++++++++++++++
|
||||||
|
1 files changed, 16 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index 5701c0a..b93b874 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -468,6 +468,18 @@ static int directory_select(const struct direct *entry)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void free_namelist(struct direct **files, int count)
|
||||||
|
+{
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ if (count < 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < count; ++i)
|
||||||
|
+ free(files[i]);
|
||||||
|
+ free(files);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static u64 calculate_dir_inode_size(char *dirname)
|
||||||
|
{
|
||||||
|
int count, i;
|
||||||
|
@@ -481,6 +493,8 @@ static u64 calculate_dir_inode_size(char *dirname)
|
||||||
|
dir_inode_size += strlen(cur_file->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ free_namelist(files, count);
|
||||||
|
+
|
||||||
|
dir_inode_size *= 2;
|
||||||
|
return dir_inode_size;
|
||||||
|
}
|
||||||
|
@@ -971,6 +985,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ free_namelist(files, count);
|
||||||
|
free(parent_dir_entry->path);
|
||||||
|
free(parent_dir_entry);
|
||||||
|
|
||||||
|
@@ -980,6 +995,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
+ free_namelist(files, count);
|
||||||
|
free(parent_dir_entry->path);
|
||||||
|
free(parent_dir_entry);
|
||||||
|
return -1;
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
38
0124-mkfs.btrfs-fix-error-text-in-r-mode.patch
Normal file
38
0124-mkfs.btrfs-fix-error-text-in-r-mode.patch
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
From 2f7d93cb50ad80d422243b74675f1f0f72d6e14f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Date: Sat, 4 Jun 2011 11:19:24 +0300
|
||||||
|
Subject: [PATCH 24/28] mkfs.btrfs: fix error text in '-r' mode
|
||||||
|
|
||||||
|
Smart gcc noticed use of uninitialized warning when compiled
|
||||||
|
with -O0 flags:
|
||||||
|
|
||||||
|
mkfs.c:1291: error: 'file' may be used uninitialized in this function
|
||||||
|
|
||||||
|
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 2 +-
|
||||||
|
1 files changed, 1 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index b93b874..e191b7f 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -1287,13 +1287,13 @@ int main(int ac, char **av)
|
||||||
|
block_count = dev_block_count;
|
||||||
|
} else {
|
||||||
|
ac = 0;
|
||||||
|
+ file = output;
|
||||||
|
fd = open_target(output);
|
||||||
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "unable to open the %s\n", file);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
- file = output;
|
||||||
|
first_file = file;
|
||||||
|
block_count = size_sourcedir(source_dir, sectorsize,
|
||||||
|
&num_of_meta_chunks, &size_of_data);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
From bb1b811edfa23c767890ace271dede34094155a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Arne Jansen <sensille@gmx.net>
|
||||||
|
Date: Mon, 14 Mar 2011 12:57:49 +0100
|
||||||
|
Subject: [PATCH 25/28] btrfs-map-logical: segfaults when no output file is
|
||||||
|
given
|
||||||
|
|
||||||
|
when no output file is given, info_file stays NULL and the following
|
||||||
|
fprintf segfaults. Default to stdout.
|
||||||
|
|
||||||
|
Signed-off-by: Arne Jansen <sensille@gmx.net>
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
btrfs-map-logical.c | 1 +
|
||||||
|
1 files changed, 1 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
|
||||||
|
index 6d3ef7a..d79a73a 100644
|
||||||
|
--- a/btrfs-map-logical.c
|
||||||
|
+++ b/btrfs-map-logical.c
|
||||||
|
@@ -173,6 +173,7 @@ int main(int ac, char **av)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ info_file = stdout;
|
||||||
|
if (output_file) {
|
||||||
|
if (strcmp(output_file, "-") == 0) {
|
||||||
|
out_fd = 1;
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
57
0127-mkfs.btrfs-Fix-compilation-errors-with-gcc-4.6.patch
Normal file
57
0127-mkfs.btrfs-Fix-compilation-errors-with-gcc-4.6.patch
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
From 3a058ce2f1febacf8aacde2b117cdfba291c95cf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
Date: Sun, 26 Jun 2011 19:41:18 +0100
|
||||||
|
Subject: [PATCH 27/28] mkfs.btrfs: Fix compilation errors with gcc 4.6
|
||||||
|
|
||||||
|
gcc 4.6 complains about several possible use-before-initialise cases
|
||||||
|
in mkfs, and stops. Fix these by initialising one of the variables in
|
||||||
|
question, and using the correct error-handling paths for the
|
||||||
|
remainder.
|
||||||
|
|
||||||
|
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
|
||||||
|
---
|
||||||
|
mkfs.c | 7 ++++---
|
||||||
|
1 files changed, 4 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index e191b7f..f2953db 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -750,7 +750,7 @@ static int add_file_items(struct btrfs_trans_handle *trans,
|
||||||
|
ino_t parent_inum, struct stat *st,
|
||||||
|
const char *path_name, int out_fd)
|
||||||
|
{
|
||||||
|
- int ret;
|
||||||
|
+ int ret = -1;
|
||||||
|
ssize_t ret_read;
|
||||||
|
u64 bytes_read = 0;
|
||||||
|
char *buffer = NULL;
|
||||||
|
@@ -889,7 +889,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
ret = btrfs_lookup_inode(trans, root, &path, &root_dir_key, 1);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "root dir lookup error\n");
|
||||||
|
- goto fail;
|
||||||
|
+ return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
leaf = path.nodes[0];
|
||||||
|
@@ -913,7 +913,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
if (chdir(parent_dir_entry->path)) {
|
||||||
|
fprintf(stderr, "chdir error for %s\n",
|
||||||
|
parent_dir_name);
|
||||||
|
- goto fail;
|
||||||
|
+ goto fail_no_files;
|
||||||
|
}
|
||||||
|
|
||||||
|
count = scandir(parent_dir_entry->path, &files,
|
||||||
|
@@ -996,6 +996,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
return 0;
|
||||||
|
fail:
|
||||||
|
free_namelist(files, count);
|
||||||
|
+fail_no_files:
|
||||||
|
free(parent_dir_entry->path);
|
||||||
|
free(parent_dir_entry);
|
||||||
|
return -1;
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
103
0216-commands-added.patch
Normal file
103
0216-commands-added.patch
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
From dbe531beb817f8cb584faf05251f6bd744fc7786 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
Date: Wed, 30 Mar 2011 18:53:09 +0200
|
||||||
|
Subject: [PATCH 16/32] commands added
|
||||||
|
|
||||||
|
- scrub commands added
|
||||||
|
- open_file_or_dir no longer static (needed by scrub.c)
|
||||||
|
|
||||||
|
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
---
|
||||||
|
Makefile | 4 ++--
|
||||||
|
btrfs.c | 20 ++++++++++++++++++++
|
||||||
|
btrfs_cmds.c | 3 ++-
|
||||||
|
btrfs_cmds.h | 5 +++++
|
||||||
|
4 files changed, 29 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/Makefile
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/Makefile
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/Makefile
|
||||||
|
@@ -37,8 +37,8 @@ all: version $(progs) manpages
|
||||||
|
version:
|
||||||
|
bash version.sh
|
||||||
|
|
||||||
|
-btrfs: $(objects) btrfs.o btrfs_cmds.o
|
||||||
|
- gcc $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o \
|
||||||
|
+btrfs: $(objects) btrfs.o btrfs_cmds.o scrub.o
|
||||||
|
+ gcc $(CFLAGS) -pthread -o btrfs btrfs.o btrfs_cmds.o scrub.o \
|
||||||
|
$(objects) $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
btrfsctl: $(objects) btrfsctl.o
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/btrfs.c
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/btrfs.c
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/btrfs.c
|
||||||
|
@@ -125,6 +125,26 @@ static struct Command commands[] = {
|
||||||
|
"If <newlabel> is passed, set the filesystem label to <newlabel>.\n"
|
||||||
|
"The filesystem must be unmounted.\n"
|
||||||
|
},
|
||||||
|
+ { do_scrub_start, -1,
|
||||||
|
+ "scrub start", "[-Bdqr] <path>|<device>\n"
|
||||||
|
+ "Start a new scrub.",
|
||||||
|
+ NULL
|
||||||
|
+ },
|
||||||
|
+ { do_scrub_cancel, 1,
|
||||||
|
+ "scrub cancel", "<path>|<device>\n"
|
||||||
|
+ "Cancel a running scrub.",
|
||||||
|
+ NULL
|
||||||
|
+ },
|
||||||
|
+ { do_scrub_resume, -1,
|
||||||
|
+ "scrub resume", "[-Bdqr] <path>|<device>\n"
|
||||||
|
+ "Resume previously canceled or interrupted scrub.",
|
||||||
|
+ NULL
|
||||||
|
+ },
|
||||||
|
+ { do_scrub_status, -1,
|
||||||
|
+ "scrub status", "[-d] <path>|<device>\n"
|
||||||
|
+ "Show status of running or finished scrub.",
|
||||||
|
+ NULL
|
||||||
|
+ },
|
||||||
|
{ do_scan, 999,
|
||||||
|
"device scan", "[<device>...]\n"
|
||||||
|
"Scan all device for or the passed device for a btrfs\n"
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.c
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/btrfs_cmds.c
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.c
|
||||||
|
@@ -91,7 +91,7 @@ static int test_isdir(char *path)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int open_file_or_dir(const char *fname)
|
||||||
|
+int open_file_or_dir(const char *fname)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct stat st;
|
||||||
|
@@ -858,6 +858,7 @@ int do_balance(int argc, char **argv)
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
int do_remove_volume(int nargs, char **args)
|
||||||
|
{
|
||||||
|
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.h
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/btrfs_cmds.h
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.h
|
||||||
|
@@ -23,6 +23,10 @@ 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_scrub_start(int nargs, char **argv);
|
||||||
|
+int do_scrub_status(int argc, char **argv);
|
||||||
|
+int do_scrub_resume(int argc, char **argv);
|
||||||
|
+int do_scrub_cancel(int nargs, char **argv);
|
||||||
|
int do_remove_volume(int nargs, char **args);
|
||||||
|
int do_scan(int nargs, char **argv);
|
||||||
|
int do_resize(int nargs, char **argv);
|
||||||
|
@@ -33,3 +37,4 @@ int do_df_filesystem(int nargs, char **a
|
||||||
|
int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
|
||||||
|
int do_find_newer(int argc, char **argv);
|
||||||
|
int do_change_label(int argc, char **argv);
|
||||||
|
+int open_file_or_dir(const char *fname);
|
119
0217-scrub-ioctls.patch
Normal file
119
0217-scrub-ioctls.patch
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
From 11c84274c669441fbbb5ed237d73c87209edc8d6 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
Date: Wed, 30 Mar 2011 18:53:10 +0200
|
||||||
|
Subject: [PATCH 17/32] scrub ioctls
|
||||||
|
|
||||||
|
- scrub structs added
|
||||||
|
- ioctls for scrub
|
||||||
|
- BTRFS_FSID_SIZE moved
|
||||||
|
|
||||||
|
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
---
|
||||||
|
ctree.h | 2 +-
|
||||||
|
ioctl.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||||
|
2 files changed, 57 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ctree.h b/ctree.h
|
||||||
|
index 61eb639..6e1b80b 100644
|
||||||
|
--- a/ctree.h
|
||||||
|
+++ b/ctree.h
|
||||||
|
@@ -24,6 +24,7 @@
|
||||||
|
#include "radix-tree.h"
|
||||||
|
#include "extent-cache.h"
|
||||||
|
#include "extent_io.h"
|
||||||
|
+#include "ioctl.h"
|
||||||
|
|
||||||
|
struct btrfs_root;
|
||||||
|
struct btrfs_trans_handle;
|
||||||
|
@@ -250,7 +251,6 @@ static inline unsigned long btrfs_chunk_item_size(int num_stripes)
|
||||||
|
sizeof(struct btrfs_stripe) * (num_stripes - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define BTRFS_FSID_SIZE 16
|
||||||
|
#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
|
||||||
|
#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
|
||||||
|
#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
|
||||||
|
diff --git a/ioctl.h b/ioctl.h
|
||||||
|
index 5aa288b..f1889c6 100644
|
||||||
|
--- a/ioctl.h
|
||||||
|
+++ b/ioctl.h
|
||||||
|
@@ -23,8 +23,9 @@
|
||||||
|
|
||||||
|
#define BTRFS_IOCTL_MAGIC 0x94
|
||||||
|
#define BTRFS_VOL_NAME_MAX 255
|
||||||
|
-#define BTRFS_PATH_NAME_MAX 4087
|
||||||
|
|
||||||
|
+/* this should be 4k */
|
||||||
|
+#define BTRFS_PATH_NAME_MAX 4087
|
||||||
|
struct btrfs_ioctl_vol_args {
|
||||||
|
__s64 fd;
|
||||||
|
char name[BTRFS_PATH_NAME_MAX + 1];
|
||||||
|
@@ -44,6 +45,51 @@ struct btrfs_ioctl_vol_args_v2 {
|
||||||
|
#define BTRFS_FSID_SIZE 16
|
||||||
|
#define BTRFS_UUID_SIZE 16
|
||||||
|
|
||||||
|
+struct btrfs_scrub_progress {
|
||||||
|
+ __u64 data_extents_scrubbed;
|
||||||
|
+ __u64 tree_extents_scrubbed;
|
||||||
|
+ __u64 data_bytes_scrubbed;
|
||||||
|
+ __u64 tree_bytes_scrubbed;
|
||||||
|
+ __u64 read_errors;
|
||||||
|
+ __u64 csum_errors;
|
||||||
|
+ __u64 verify_errors;
|
||||||
|
+ __u64 no_csum;
|
||||||
|
+ __u64 csum_discards;
|
||||||
|
+ __u64 super_errors;
|
||||||
|
+ __u64 malloc_errors;
|
||||||
|
+ __u64 uncorrectable_errors;
|
||||||
|
+ __u64 corrected_errors;
|
||||||
|
+ __u64 last_physical;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define BTRFS_SCRUB_READONLY 1
|
||||||
|
+struct btrfs_ioctl_scrub_args {
|
||||||
|
+ __u64 devid; /* in */
|
||||||
|
+ __u64 start; /* in */
|
||||||
|
+ __u64 end; /* in */
|
||||||
|
+ __u64 flags; /* in */
|
||||||
|
+ struct btrfs_scrub_progress progress; /* out */
|
||||||
|
+ /* pad to 1k */
|
||||||
|
+ __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define BTRFS_DEVICE_PATH_NAME_MAX 1024
|
||||||
|
+struct btrfs_ioctl_dev_info_args {
|
||||||
|
+ __u64 devid; /* in/out */
|
||||||
|
+ __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
|
||||||
|
+ __u64 bytes_used; /* out */
|
||||||
|
+ __u64 total_bytes; /* out */
|
||||||
|
+ __u64 unused[379]; /* pad to 4k */
|
||||||
|
+ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+struct btrfs_ioctl_fs_info_args {
|
||||||
|
+ __u64 max_id; /* out */
|
||||||
|
+ __u64 num_devices; /* out */
|
||||||
|
+ __u8 fsid[BTRFS_FSID_SIZE]; /* out */
|
||||||
|
+ __u64 reserved[124]; /* pad to 1k */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
struct btrfs_ioctl_search_key {
|
||||||
|
/* which root are we searching. 0 is the tree of tree roots */
|
||||||
|
__u64 tree_id;
|
||||||
|
@@ -193,4 +239,13 @@ struct btrfs_ioctl_space_args {
|
||||||
|
struct btrfs_ioctl_space_args)
|
||||||
|
#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
|
||||||
|
struct btrfs_ioctl_vol_args_v2)
|
||||||
|
+#define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
|
||||||
|
+ struct btrfs_ioctl_scrub_args)
|
||||||
|
+#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
|
||||||
|
+#define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
|
||||||
|
+ struct btrfs_ioctl_scrub_args)
|
||||||
|
+#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
|
||||||
|
+ struct btrfs_ioctl_dev_info_args)
|
||||||
|
+#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
|
||||||
|
+ struct btrfs_ioctl_fs_info_args)
|
||||||
|
#endif
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
90
0218-added-check_mounted_where.patch
Normal file
90
0218-added-check_mounted_where.patch
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
From dff7a7e14481812b6f28479ecfe45fe79c9365c5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
Date: Wed, 30 Mar 2011 18:53:11 +0200
|
||||||
|
Subject: [PATCH 18/32] added check_mounted_where
|
||||||
|
|
||||||
|
new version of check_mounted() returning more information gathered while
|
||||||
|
searching. check_mounted() is now a wrapper for check_mounted_where(). the new
|
||||||
|
version is needed by scrub.c
|
||||||
|
|
||||||
|
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
---
|
||||||
|
utils.c | 29 ++++++++++++++++++++++-------
|
||||||
|
utils.h | 2 ++
|
||||||
|
2 files changed, 24 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/utils.c b/utils.c
|
||||||
|
index 46b9a2c..da54b75 100644
|
||||||
|
--- a/utils.c
|
||||||
|
+++ b/utils.c
|
||||||
|
@@ -790,13 +790,8 @@ int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices, const char* file)
|
||||||
|
*/
|
||||||
|
int check_mounted(const char* file)
|
||||||
|
{
|
||||||
|
- int ret;
|
||||||
|
int fd;
|
||||||
|
- u64 total_devs = 1;
|
||||||
|
- int is_btrfs;
|
||||||
|
- struct btrfs_fs_devices* fs_devices_mnt = NULL;
|
||||||
|
- FILE *f;
|
||||||
|
- struct mntent *mnt;
|
||||||
|
+ int ret;
|
||||||
|
|
||||||
|
fd = open(file, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
@@ -804,11 +799,26 @@ int check_mounted(const char* file)
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ ret = check_mounted_where(fd, file, NULL, 0, NULL);
|
||||||
|
+ close(fd);
|
||||||
|
+
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int check_mounted_where(int fd, const char* file, char *where, int size,
|
||||||
|
+ struct btrfs_fs_devices **fs_dev_ret)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+ u64 total_devs = 1;
|
||||||
|
+ int is_btrfs;
|
||||||
|
+ struct btrfs_fs_devices* fs_devices_mnt = NULL;
|
||||||
|
+ FILE *f;
|
||||||
|
+ struct mntent *mnt;
|
||||||
|
+
|
||||||
|
/* scan the initial device */
|
||||||
|
ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
|
||||||
|
&total_devs, BTRFS_SUPER_INFO_OFFSET);
|
||||||
|
is_btrfs = (ret >= 0);
|
||||||
|
- close(fd);
|
||||||
|
|
||||||
|
/* scan other devices */
|
||||||
|
if (is_btrfs && total_devs > 1) {
|
||||||
|
@@ -844,6 +854,11 @@ int check_mounted(const char* file)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Did we find an entry in mnt table? */
|
||||||
|
+ if (mnt && size && where)
|
||||||
|
+ strncpy(where, mnt->mnt_dir, size);
|
||||||
|
+ if (fs_dev_ret)
|
||||||
|
+ *fs_dev_ret = fs_devices_mnt;
|
||||||
|
+
|
||||||
|
ret = (mnt != NULL);
|
||||||
|
|
||||||
|
out_mntloop_err:
|
||||||
|
diff --git a/utils.h b/utils.h
|
||||||
|
index c3004ae..167021a 100644
|
||||||
|
--- a/utils.h
|
||||||
|
+++ b/utils.h
|
||||||
|
@@ -37,6 +37,8 @@ int btrfs_scan_for_fsid(struct btrfs_fs_devices *fs_devices, u64 total_devs,
|
||||||
|
void btrfs_register_one_device(char *fname);
|
||||||
|
int btrfs_scan_one_dir(char *dirname, int run_ioctl);
|
||||||
|
int check_mounted(const char *devicename);
|
||||||
|
+int check_mounted_where(int fd, const char* file, char *where, int size,
|
||||||
|
+ struct btrfs_fs_devices **fs_devices_mnt);
|
||||||
|
int btrfs_device_already_in_root(struct btrfs_root *root, int fd,
|
||||||
|
int super_offset);
|
||||||
|
char *pretty_sizes(u64 size);
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
1588
0219-scrub-userland-implementation.patch
Normal file
1588
0219-scrub-userland-implementation.patch
Normal file
File diff suppressed because it is too large
Load Diff
97
0220-scrub-added-to-manpage.patch
Normal file
97
0220-scrub-added-to-manpage.patch
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
From 8043249f02f79ec7e2379e0fe3fad09ec9a1a306 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
Date: Wed, 30 Mar 2011 18:53:13 +0200
|
||||||
|
Subject: [PATCH 20/32] scrub added to manpage
|
||||||
|
|
||||||
|
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
|
||||||
|
---
|
||||||
|
man/btrfs.8.in | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||||
|
1 files changed, 65 insertions(+), 1 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
|
||||||
|
index cb32679..2407153 100644
|
||||||
|
--- a/man/btrfs.8.in
|
||||||
|
+++ b/man/btrfs.8.in
|
||||||
|
@@ -35,7 +35,15 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBdevice add\fP\fI <device> [<device>...] <path> \fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice delete\fP\fI <device> [<device>...] <path> \fP]
|
||||||
|
+\fBbtrfs\fP \fBdevice delete\fP\fI <device> [<device>...] <path> \fP
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+.PP
|
||||||
|
+\fBbtrfs\fP \fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP
|
||||||
|
.PP
|
||||||
|
@@ -200,6 +208,62 @@ Add device(s) to the filesystem identified by \fI<path>\fR.
|
||||||
|
|
||||||
|
\fBdevice delete\fR\fI <dev> [<dev>..] <path>\fR
|
||||||
|
Remove device(s) from a filesystem identified by \fI<path>\fR.
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
+\fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+Start a scrub on all devices of the filesystem identified by \fI<path>\fR or on
|
||||||
|
+a single \fI<device>\fR. Without options, scrub is started as a background
|
||||||
|
+process. Progress can be obtained with the \fBscrub status\fR command. Scrubbing
|
||||||
|
+involves reading all data from all disks and verifying checksums. Errors are
|
||||||
|
+corrected along the way if possible.
|
||||||
|
+.RS
|
||||||
|
+
|
||||||
|
+\fIOptions\fR
|
||||||
|
+.IP -B 5
|
||||||
|
+Do not background and print scrub statistics when finished.
|
||||||
|
+.IP -d 5
|
||||||
|
+Print separate statistics for each device of the filesystem (-B only).
|
||||||
|
+.IP -q 5
|
||||||
|
+Quiet. Omit error messages and statistics.
|
||||||
|
+.IP -r 5
|
||||||
|
+Read only mode. Do not attempt to correct anything.
|
||||||
|
+.IP -u 5
|
||||||
|
+Scrub unused space as well. (NOT IMPLEMENTED)
|
||||||
|
+.RE
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
+\fBscrub cancel\fP {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+If a scrub is running on the filesystem identified by \fI<path>\fR, cancel it.
|
||||||
|
+Progress is saved in the scrub progress file and scrubbing can be resumed later
|
||||||
|
+using the \fBscrub resume\fR command.
|
||||||
|
+If a \fI<device>\fR is given, the corresponding filesystem is found and
|
||||||
|
+\fBscrub cancel\fP behaves as if it was called on that filesystem.
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
+\fBscrub resume\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+Resume a canceled or interrupted scrub cycle on the filesystem identified by
|
||||||
|
+\fI<path>\fR or on a given \fI<device>\fR. Does not start a new scrub if the
|
||||||
|
+last scrub finished successfully.
|
||||||
|
+.RS
|
||||||
|
+
|
||||||
|
+\fIOptions\fR
|
||||||
|
+.TP
|
||||||
|
+see \fBscrub start\fP.
|
||||||
|
+.RE
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
+\fBscrub status\fP [-d] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
+Show status of a running scrub for the filesystem identified by \fI<path>\fR or
|
||||||
|
+for the specified \fI<device>\fR.
|
||||||
|
+If no scrub is running, show statistics of the last finished or canceled scrub
|
||||||
|
+for that filesystem or device.
|
||||||
|
+.RS
|
||||||
|
+
|
||||||
|
+\fIOptions\fR
|
||||||
|
+.IP -d 5
|
||||||
|
+Print separate statistics for each device of the filesystem.
|
||||||
|
+.RE
|
||||||
|
+
|
||||||
|
.PP
|
||||||
|
|
||||||
|
.SH EXIT STATUS
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
259
0230-Scan-the-devices-listed-in-proc-partitions.patch
Normal file
259
0230-Scan-the-devices-listed-in-proc-partitions.patch
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
From ca3e8d2b057b3efaa0ec224ef73d6c88ad7d67c1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Goffredo Baroncelli <kreijack@inwind.it>
|
||||||
|
Date: Wed, 15 Jun 2011 21:55:25 +0200
|
||||||
|
Subject: [PATCH 30/32] Scan the devices listed in /proc/partitions
|
||||||
|
|
||||||
|
During the commands:
|
||||||
|
- btrfs filesystem show
|
||||||
|
- btrfs device scan
|
||||||
|
the devices "scanned" are extracted from /proc/partitions. This
|
||||||
|
should avoid to scan devices not suitable for a btrfs filesystem like cdrom
|
||||||
|
and floppy or to scan not existant devices.
|
||||||
|
The old behavior (scan all the block devices under /dev) may be
|
||||||
|
forced passing the "--all-devices" switch.
|
||||||
|
---
|
||||||
|
btrfs.c | 4 +-
|
||||||
|
btrfs_cmds.c | 47 ++++++++++++++++++++++++++++++++++++++++----
|
||||||
|
man/btrfs.8.in | 26 +++++++++++++++---------
|
||||||
|
utils.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
utils.h | 2 +
|
||||||
|
5 files changed, 120 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/btrfs.c
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/btrfs.c
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/btrfs.c
|
||||||
|
@@ -104,7 +104,7 @@ static struct Command commands[] = {
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
{ do_show_filesystem, 999,
|
||||||
|
- "filesystem show", "[<device>|<uuid>|<label>]\n"
|
||||||
|
+ "filesystem show", "[--all-devices][<uuid>|<label>]\n"
|
||||||
|
"Show the info of a btrfs filesystem. If no argument\n"
|
||||||
|
"is passed, info of all the btrfs filesystem are shown.",
|
||||||
|
NULL
|
||||||
|
@@ -146,7 +146,7 @@ static struct Command commands[] = {
|
||||||
|
NULL
|
||||||
|
},
|
||||||
|
{ do_scan, 999,
|
||||||
|
- "device scan", "[<device>...]\n"
|
||||||
|
+ "device scan", "[--all-devices|<device> [<device> ...]]\n"
|
||||||
|
"Scan all device for or the passed device for a btrfs\n"
|
||||||
|
"filesystem.",
|
||||||
|
NULL
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.c
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/btrfs_cmds.c
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/btrfs_cmds.c
|
||||||
|
@@ -589,11 +589,29 @@ int do_fssync(int argc, char **argv)
|
||||||
|
int do_scan(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i, fd, e;
|
||||||
|
- if(argc<=1){
|
||||||
|
+ int checklist = 1;
|
||||||
|
+ int devstart = 1;
|
||||||
|
+
|
||||||
|
+ if( argc >= 2 && !strcmp(argv[1],"--all-devices")){
|
||||||
|
+
|
||||||
|
+ if( argc >2 ){
|
||||||
|
+ fprintf(stderr, "ERROR: too may arguments\n");
|
||||||
|
+ return 22;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ checklist = 0;
|
||||||
|
+ devstart += 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(argc<=devstart){
|
||||||
|
+
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
printf("Scanning for Btrfs filesystems\n");
|
||||||
|
- ret = btrfs_scan_one_dir("/dev", 1);
|
||||||
|
+ if(checklist)
|
||||||
|
+ ret = btrfs_scan_block_devices(1);
|
||||||
|
+ else
|
||||||
|
+ ret = btrfs_scan_one_dir("/dev", 1);
|
||||||
|
if (ret){
|
||||||
|
fprintf(stderr, "ERROR: error %d while scanning\n", ret);
|
||||||
|
return 18;
|
||||||
|
@@ -607,7 +625,7 @@ int do_scan(int argc, char **argv)
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
- for( i = 1 ; i < argc ; i++ ){
|
||||||
|
+ for( i = devstart ; i < argc ; i++ ){
|
||||||
|
struct btrfs_ioctl_vol_args args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
@@ -730,14 +748,33 @@ int do_show_filesystem(int argc, char **
|
||||||
|
struct list_head *all_uuids;
|
||||||
|
struct btrfs_fs_devices *fs_devices;
|
||||||
|
struct list_head *cur_uuid;
|
||||||
|
- char *search = argv[1];
|
||||||
|
+ char *search = 0;
|
||||||
|
int ret;
|
||||||
|
+ int checklist = 1;
|
||||||
|
+ int searchstart = 1;
|
||||||
|
+
|
||||||
|
+ if( argc >= 2 && !strcmp(argv[1],"--all-devices")){
|
||||||
|
+ checklist = 0;
|
||||||
|
+ searchstart += 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if( argc > searchstart+1 ){
|
||||||
|
+ fprintf(stderr, "ERROR: too many arguments\n");
|
||||||
|
+ return 22;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if(checklist)
|
||||||
|
+ ret = btrfs_scan_block_devices(0);
|
||||||
|
+ else
|
||||||
|
+ ret = btrfs_scan_one_dir("/dev", 0);
|
||||||
|
|
||||||
|
- ret = btrfs_scan_one_dir("/dev", 0);
|
||||||
|
if (ret){
|
||||||
|
fprintf(stderr, "ERROR: error %d while scanning\n", ret);
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ if(searchstart < argc)
|
||||||
|
+ search = argv[searchstart];
|
||||||
|
|
||||||
|
all_uuids = btrfs_scanned_uuids();
|
||||||
|
list_for_each(cur_uuid, all_uuids) {
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/man/btrfs.8.in
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/man/btrfs.8.in
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/man/btrfs.8.in
|
||||||
|
@@ -29,9 +29,9 @@ btrfs \- control a btrfs filesystem
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBfilesystem defragment\fP\fI <file>|<dir> [<file>|<dir>...]\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice scan\fP\fI [<device>...]\fP
|
||||||
|
+\fBbtrfs\fP \fBdevice scan\fP\fI [--all-devices|<device> [<device>...]]\fP
|
||||||
|
.PP
|
||||||
|
-\fBbtrfs\fP \fBdevice show\fP\fI [<device>|<uuid>|<label>]\fP
|
||||||
|
+\fBbtrfs\fP \fBdevice show\fP\fI [--all-devices|<uuid>|<label>]\fP
|
||||||
|
.PP
|
||||||
|
\fBbtrfs\fP \fBdevice add\fP\fI <device> [<device>...] <path> \fP
|
||||||
|
.PP
|
||||||
|
@@ -143,11 +143,6 @@ use it if you use snapshots, have de-dup
|
||||||
|
List the recently modified files in a subvolume, after \fI<last_gen>\fR ID.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBdevice scan\fR \fI[<device>...]\fR
|
||||||
|
-Scan devices for a btrfs filesystem. If no devices are passed, \fBbtrfs\fR scans
|
||||||
|
-all the block devices.
|
||||||
|
-.TP
|
||||||
|
-
|
||||||
|
\fBfilesystem sync\fR\fI <path> \fR
|
||||||
|
Force a sync for the filesystem identified by \fI<path>\fR.
|
||||||
|
.TP
|
||||||
|
@@ -192,9 +187,11 @@ NOTE: Currently there are the following
|
||||||
|
- the filesystem should not have more than one device.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
-\fBfilesystem show\fR [<uuid>|<label>]\fR
|
||||||
|
-Show the btrfs filesystem with some additional info. If no UUID or label is
|
||||||
|
-passed, \fBbtrfs\fR show info of all the btrfs filesystem.
|
||||||
|
+\fBfilesystem show\fR [--all-devices|<uuid>|<label>]\fR
|
||||||
|
+Show the btrfs filesystem with some additional info. If no \fIUUID\fP or
|
||||||
|
+\fIlabel\fP is passed, \fBbtrfs\fR show info of all the btrfs filesystem.
|
||||||
|
+If \fB--all-devices\fP is passed, all the devices under /dev are scanned;
|
||||||
|
+otherwise the devices list is extracted from the /proc/partitions file.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
\fBdevice balance\fR \fI<path>\fR
|
||||||
|
@@ -210,6 +207,14 @@ Add device(s) to the filesystem identifi
|
||||||
|
Remove device(s) from a filesystem identified by \fI<path>\fR.
|
||||||
|
.TP
|
||||||
|
|
||||||
|
+\fBdevice scan\fR \fI[--all-devices|<device> [<device>...]\fR
|
||||||
|
+If one or more devices are passed, these are scanned for a btrfs filesystem.
|
||||||
|
+If no devices are passed, \fBbtrfs\fR scans all the block devices listed
|
||||||
|
+in the /proc/partitions file.
|
||||||
|
+Finally, if \fB--all-devices\fP is passed, all the devices under /dev are
|
||||||
|
+scanned.
|
||||||
|
+.TP
|
||||||
|
+
|
||||||
|
\fBscrub start\fP [-Bdqru] {\fI<path>\fP|\fI<device>\fP}
|
||||||
|
Start a scrub on all devices of the filesystem identified by \fI<path>\fR or on
|
||||||
|
a single \fI<device>\fR. Without options, scrub is started as a background
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/utils.c
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/utils.c
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/utils.c
|
||||||
|
@@ -1104,3 +1104,61 @@ int check_label(char *input)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int btrfs_scan_block_devices(int run_ioctl)
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ struct stat st;
|
||||||
|
+ int ret;
|
||||||
|
+ int fd;
|
||||||
|
+ struct btrfs_fs_devices *tmp_devices;
|
||||||
|
+ u64 num_devices;
|
||||||
|
+ FILE *proc_partitions;
|
||||||
|
+ int i;
|
||||||
|
+ char buf[1024];
|
||||||
|
+ char fullpath[110];
|
||||||
|
+
|
||||||
|
+ proc_partitions = fopen("/proc/partitions","r");
|
||||||
|
+ if (!proc_partitions) {
|
||||||
|
+ fprintf(stderr, "Unable to open '/proc/partitions' for scanning\n");
|
||||||
|
+ return -ENOENT;
|
||||||
|
+ }
|
||||||
|
+ /* skip the header */
|
||||||
|
+ for(i=0; i < 2 ; i++)
|
||||||
|
+ if(!fgets(buf, 1023, proc_partitions)){
|
||||||
|
+ fprintf(stderr, "Unable to read '/proc/partitions' for scanning\n");
|
||||||
|
+ fclose(proc_partitions);
|
||||||
|
+ return -ENOENT;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ strcpy(fullpath,"/dev/");
|
||||||
|
+ while(fgets(buf, 1023, proc_partitions)) {
|
||||||
|
+
|
||||||
|
+ i = sscanf(buf," %*d %*d %*d %99s", fullpath+5);
|
||||||
|
+ ret = lstat(fullpath, &st);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ fprintf(stderr, "failed to stat %s\n", fullpath);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ if (!S_ISBLK(st.st_mode)) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fd = open(fullpath, O_RDONLY);
|
||||||
|
+ if (fd < 0) {
|
||||||
|
+ fprintf(stderr, "failed to read %s\n", fullpath);
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+ ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
|
||||||
|
+ &num_devices,
|
||||||
|
+ BTRFS_SUPER_INFO_OFFSET);
|
||||||
|
+ if (ret == 0 && run_ioctl > 0) {
|
||||||
|
+ btrfs_register_one_device(fullpath);
|
||||||
|
+ }
|
||||||
|
+ close(fd);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ fclose(proc_partitions);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
Index: btrfs-progs-v0.19-35-g1b444cd/utils.h
|
||||||
|
===================================================================
|
||||||
|
--- btrfs-progs-v0.19-35-g1b444cd.orig/utils.h
|
||||||
|
+++ btrfs-progs-v0.19-35-g1b444cd/utils.h
|
||||||
|
@@ -44,4 +44,6 @@ int btrfs_device_already_in_root(struct
|
||||||
|
char *pretty_sizes(u64 size);
|
||||||
|
int check_label(char *input);
|
||||||
|
int get_mountpt(char *dev, char *mntpt, size_t size);
|
||||||
|
+
|
||||||
|
+int btrfs_scan_block_devices(int run_ioctl);
|
||||||
|
#endif
|
151
0231-btrfs-progs-Improvement-for-making-btrfs-image-from-.patch
Normal file
151
0231-btrfs-progs-Improvement-for-making-btrfs-image-from-.patch
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
From 74da7aa43f7ace05794d755a428bf8520d61e8fd Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Zhong, Xin" <xin.zhong@intel.com>
|
||||||
|
Date: Tue, 21 Jun 2011 09:45:59 +0800
|
||||||
|
Subject: [PATCH 31/32] btrfs-progs: Improvement for making btrfs image from
|
||||||
|
source directory.
|
||||||
|
|
||||||
|
* Initialize ret in btrfs_csum_file_block
|
||||||
|
* Do not abort when xattr is not supported in the source directory
|
||||||
|
* Remove size limitation of 256M
|
||||||
|
* Alloc data chunk in a smaller size (8M) to make btrfs image smaller
|
||||||
|
* Let user specify the btrfs image name
|
||||||
|
Depends on below patch from samsung guys:
|
||||||
|
http://marc.info/?l=linux-btrfs&m=127858068226025&w=2
|
||||||
|
|
||||||
|
Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
|
||||||
|
---
|
||||||
|
file-item.c | 2 +-
|
||||||
|
mkfs.c | 33 +++++++++++++++++----------------
|
||||||
|
2 files changed, 18 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/file-item.c b/file-item.c
|
||||||
|
index 47f6ad2..c746b44 100644
|
||||||
|
--- a/file-item.c
|
||||||
|
+++ b/file-item.c
|
||||||
|
@@ -193,7 +193,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
|
||||||
|
struct btrfs_root *root, u64 alloc_end,
|
||||||
|
u64 bytenr, char *data, size_t len)
|
||||||
|
{
|
||||||
|
- int ret;
|
||||||
|
+ int ret = 0;
|
||||||
|
struct btrfs_key file_key;
|
||||||
|
struct btrfs_key found_key;
|
||||||
|
u64 next_offset = (u64)-1;
|
||||||
|
diff --git a/mkfs.c b/mkfs.c
|
||||||
|
index f2953db..3a49bab 100644
|
||||||
|
--- a/mkfs.c
|
||||||
|
+++ b/mkfs.c
|
||||||
|
@@ -553,6 +553,8 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
ret = llistxattr(file_name, xattr_list, XATTR_LIST_MAX);
|
||||||
|
if (ret < 0) {
|
||||||
|
+ if(errno == ENOTSUP)
|
||||||
|
+ return 0;
|
||||||
|
fprintf(stderr, "get a list of xattr failed for %s\n",
|
||||||
|
file_name);
|
||||||
|
return ret;
|
||||||
|
@@ -567,8 +569,11 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
|
||||||
|
if (ret < 0) {
|
||||||
|
- fprintf(stderr, "get a xattr value failed for %s\n",
|
||||||
|
- cur_name);
|
||||||
|
+ if(errno == ENOTSUP)
|
||||||
|
+ return 0;
|
||||||
|
+ fprintf(stderr, "get a xattr value failed for %s attr %s\n",
|
||||||
|
+ file_name, cur_name);
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = btrfs_insert_xattr_item(trans, root, cur_name,
|
||||||
|
@@ -584,7 +589,6 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
-
|
||||||
|
static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
|
||||||
|
u64 hint_byte, struct btrfs_key *ins)
|
||||||
|
{
|
||||||
|
@@ -957,7 +961,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
||||||
|
cur_inum, cur_file->d_name);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "add_xattr_item failed\n");
|
||||||
|
- goto fail;
|
||||||
|
+ if(ret != -ENOTSUP)
|
||||||
|
+ goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S_ISDIR(st.st_mode)) {
|
||||||
|
@@ -1019,7 +1024,7 @@ static int create_chunks(struct btrfs_trans_handle *trans,
|
||||||
|
u64 chunk_size;
|
||||||
|
u64 meta_type = BTRFS_BLOCK_GROUP_METADATA;
|
||||||
|
u64 data_type = BTRFS_BLOCK_GROUP_DATA;
|
||||||
|
- u64 minimum_data_chunk_size = 64 * 1024 * 1024;
|
||||||
|
+ u64 minimum_data_chunk_size = 8 * 1024 * 1024;
|
||||||
|
u64 i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
@@ -1094,7 +1099,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
|
||||||
|
char path[512];
|
||||||
|
char *file_name = "temp_file";
|
||||||
|
FILE *file;
|
||||||
|
- u64 minimum_data_size = 256 * 1024 * 1024; /* 256MB */
|
||||||
|
u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */
|
||||||
|
u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */
|
||||||
|
u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */
|
||||||
|
@@ -1133,9 +1137,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
|
||||||
|
|
||||||
|
*num_of_meta_chunks_ret = num_of_meta_chunks;
|
||||||
|
|
||||||
|
- if (total_size < minimum_data_size)
|
||||||
|
- total_size = minimum_data_size;
|
||||||
|
-
|
||||||
|
return total_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1189,9 +1190,9 @@ int main(int ac, char **av)
|
||||||
|
|
||||||
|
char *source_dir = NULL;
|
||||||
|
int source_dir_set = 0;
|
||||||
|
- char *output = "output.img";
|
||||||
|
u64 num_of_meta_chunks = 0;
|
||||||
|
u64 size_of_data = 0;
|
||||||
|
+ u64 source_dir_size = 0;
|
||||||
|
char *pretty_buf;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
@@ -1256,8 +1257,6 @@ int main(int ac, char **av)
|
||||||
|
fprintf(stderr, "Illegal nodesize %u\n", nodesize);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
- if (source_dir_set)
|
||||||
|
- ac++;
|
||||||
|
ac = ac - optind;
|
||||||
|
if (ac == 0)
|
||||||
|
print_usage();
|
||||||
|
@@ -1288,16 +1287,18 @@ int main(int ac, char **av)
|
||||||
|
block_count = dev_block_count;
|
||||||
|
} else {
|
||||||
|
ac = 0;
|
||||||
|
- file = output;
|
||||||
|
- fd = open_target(output);
|
||||||
|
+ file = av[optind++];
|
||||||
|
+ fd = open_target(file);
|
||||||
|
if (fd < 0) {
|
||||||
|
fprintf(stderr, "unable to open the %s\n", file);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
first_file = file;
|
||||||
|
- block_count = size_sourcedir(source_dir, sectorsize,
|
||||||
|
- &num_of_meta_chunks, &size_of_data);
|
||||||
|
+ source_dir_size = size_sourcedir(source_dir, sectorsize,
|
||||||
|
+ &num_of_meta_chunks, &size_of_data);
|
||||||
|
+ if(block_count < source_dir_size)
|
||||||
|
+ block_count = source_dir_size;
|
||||||
|
ret = zero_output_file(fd, block_count, sectorsize);
|
||||||
|
if (ret) {
|
||||||
|
fprintf(stderr, "unable to zero the output file\n");
|
||||||
|
--
|
||||||
|
1.7.5.2.353.g5df3e
|
||||||
|
|
@ -1,8 +1,36 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jul 20 19:12:46 CEST 2011 - dsterba@suse.cz
|
||||||
|
|
||||||
|
- remove debugging printf from
|
||||||
|
0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jul 1 16:59:41 CEST 2011 - dsterba@suse.cz
|
||||||
|
|
||||||
|
- add support for currently available kernel features:
|
||||||
|
- add scrub subcommand
|
||||||
|
- scan /proc/partitions by default (or use --all-devices for all)
|
||||||
|
- mkfs fixes and improvements
|
||||||
|
- documentation fixes
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Jul 1 16:31:44 CEST 2011 - dmueller@suse.de
|
Fri Jul 1 16:31:44 CEST 2011 - dmueller@suse.de
|
||||||
|
|
||||||
- fix failing on deleted loop mounts (bnc#697671)
|
- fix failing on deleted loop mounts (bnc#697671)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jul 1 15:54:23 CEST 2011 - dsterba@suse.cz
|
||||||
|
|
||||||
|
- update from git:
|
||||||
|
- add btrfs-select-super utility
|
||||||
|
- add btrfs-label utility
|
||||||
|
- allow mixed data+metadata (option --mixed)
|
||||||
|
- allow populating new filesystem with files (option --rootdir)
|
||||||
|
- allow discard support in mkfs
|
||||||
|
- lzo support
|
||||||
|
- deprecate 'btrfsctl' 'btrfs-vol' 'btrfs-show'
|
||||||
|
- other bugfixes and documentation improvements
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 21 13:01:23 CET 2011 - dmueller@suse.de
|
Mon Mar 21 13:01:23 CET 2011 - dmueller@suse.de
|
||||||
|
|
||||||
|
113
btrfsprogs.spec
113
btrfsprogs.spec
@ -18,32 +18,131 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: btrfsprogs
|
Name: btrfsprogs
|
||||||
Url: http://oss.oracle.com/~mason/btrfs/
|
Url: http://btrfs.wiki.kernel.org/index.php/Main_Page
|
||||||
Version: 0.19
|
Version: 0.19
|
||||||
Release: 39
|
Release: 5.<RELEASE8>
|
||||||
%define tar_version v0.19-35-g1b444cd
|
%define tar_version v0.19-35-g1b444cd
|
||||||
Summary: Btrfs File System Utilities
|
Summary: Utilities for the Second Btr File System
|
||||||
License: GNU General Public License (GPL)
|
License: GPL v2 only
|
||||||
Group: System/Filesystems
|
Group: System/Filesystems
|
||||||
Supplements: filesystem(btrfs)
|
Supplements: filesystem(btrfs)
|
||||||
Source: btrfs-progs-%{tar_version}.tar.bz2
|
Source: btrfs-progs-%{tar_version}.tar.bz2
|
||||||
Patch0: memleak-fix.diff
|
Patch0: memleak-fix.diff
|
||||||
Patch1: 0001-Plug-Memory-leak-in-find_and_setup_log_root.patch
|
Patch1: 0001-Plug-Memory-leak-in-find_and_setup_log_root.patch
|
||||||
Patch2: ignore-deleted-loopmounts.diff
|
|
||||||
|
# git: master..tmp (1b444cd..e6bd18d)
|
||||||
|
Patch2: 0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch
|
||||||
|
Patch3: 0002-Btrfs-progs-use-safe-string-manipulation-functions.patch
|
||||||
|
Patch4: 0003-Btrfs-progs-utils-Informative-errors.patch
|
||||||
|
Patch5: 0004-update-man-page-to-new-defragment-command-interface.patch
|
||||||
|
Patch6: 0005-Improve-error-handling-in-the-btrfs-command.patch
|
||||||
|
Patch7: 0006-Btrfs-progs-update-super-fields-for-space-cache.patch
|
||||||
|
Patch8: 0007-Btrfs-progs-add-support-for-mixed-data-metadata-bloc.patch
|
||||||
|
Patch9: 0008-Update-for-lzo-support.patch
|
||||||
|
Patch10: 0009-Update-clean-up-btrfs-help-and-man-page-V2.patch
|
||||||
|
Patch11: 0010-Deprecate-btrfsctl-btrfs-show-btrfs-vol.patch
|
||||||
|
Patch12: 0011-Add-the-btrfs-filesystem-label-command.patch
|
||||||
|
Patch13: 0012-Btrfs-progs-Update-man-page-for-mixed-data-metadata-.patch
|
||||||
|
Patch14: 0013-btrfs-progs-Add-new-feature-to-mkfs.btrfs-to-make-fi.patch
|
||||||
|
Patch15: 0014-btrfs-progs-fix-wrong-extent-buffer-size-when-readin.patch
|
||||||
|
Patch16: 0015-btrfs-progs-add-discard-support-to-mkfs.patch
|
||||||
|
|
||||||
|
# git: tmp..<to be pulled soon>
|
||||||
|
Patch20: 0101-btrfs-progs-setting-of-time-to-the-root-directory.patch
|
||||||
|
Patch21: 0103-add-advanced-use-of-help-to-help-message.patch
|
||||||
|
Patch22: 0104-add-detailed-help-messages-to-btrfs-command.patch
|
||||||
|
Patch23: 0105-Fix-unused-but-set-errors-in-gcc-4.6.patch
|
||||||
|
Patch24: 0106-btrfs-map-logical-usage-update.patch
|
||||||
|
Patch25: 0107-btrfs-progs-cast-u64-to-long-long-to-avoid-printf-wa.patch
|
||||||
|
Patch26: 0108-Added-support-for-an-additional-ioctl.patch
|
||||||
|
Patch27: 0109-Add-support-for-read-only-subvolumes.patch
|
||||||
|
Patch28: 0110-Support-the-new-parameters-in-do_clone-int-argc-char.patch
|
||||||
|
Patch29: 0112-Updated-manpage-for-btrfs-subvolume-snapshot.patch
|
||||||
|
Patch30: 0113-btrfs-progs-Fix-over-sized-limit-on-buffer.patch
|
||||||
|
Patch31: 0114-incorrect-argument-checking-for-btrfs-sub-snap-r.patch
|
||||||
|
Patch32: 0115-btrfs-progs-fix-extra-metadata-chunk-allocation-in-m.patch
|
||||||
|
Patch33: 0116-make-btrfs-filesystem-label-command-actually-work.patch
|
||||||
|
Patch34: 0118-mkfs.btrfs-fail-on-scandir-error-r-mode.patch
|
||||||
|
Patch35: 0119-mkfs.btrfs-return-some-defined-value-instead-of-garb.patch
|
||||||
|
Patch36: 0120-mkfs.btrfs-fix-symlink-names-writing.patch
|
||||||
|
Patch37: 0121-mkfs.btrfs-write-zeroes-instead-on-uninitialized-dat.patch
|
||||||
|
Patch38: 0122-mkfs.btrfs-free-buffers-allocated-by-pretty_sizes.patch
|
||||||
|
Patch39: 0123-mkfs.btrfs-fix-memory-leak-caused-by-scandir-calls.patch
|
||||||
|
Patch40: 0124-mkfs.btrfs-fix-error-text-in-r-mode.patch
|
||||||
|
Patch41: 0125-btrfs-map-logical-segfaults-when-no-output-file-is-g.patch
|
||||||
|
Patch42: 0127-mkfs.btrfs-Fix-compilation-errors-with-gcc-4.6.patch
|
||||||
|
|
||||||
|
# git: scrub, fixes, improvements
|
||||||
|
Patch50: 0216-commands-added.patch
|
||||||
|
Patch51: 0217-scrub-ioctls.patch
|
||||||
|
Patch52: 0218-added-check_mounted_where.patch
|
||||||
|
Patch53: 0219-scrub-userland-implementation.patch
|
||||||
|
Patch54: 0220-scrub-added-to-manpage.patch
|
||||||
|
Patch55: 0230-Scan-the-devices-listed-in-proc-partitions.patch
|
||||||
|
Patch56: 0231-btrfs-progs-Improvement-for-making-btrfs-image-from-.patch
|
||||||
|
|
||||||
|
Patch57: ignore-deleted-loopmounts.diff
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildRequires: libacl-devel libext2fs-devel libuuid-devel zlib-devel
|
BuildRequires: libacl-devel libext2fs-devel libuuid-devel zlib-devel
|
||||||
# for /bin/true
|
# for /bin/true
|
||||||
Requires: coreutils
|
Requires: coreutils
|
||||||
|
|
||||||
%description
|
%description
|
||||||
This package contains utilities for creating, checking, and
|
Utilities needed to create and maintain btrfs file systems under Linux.
|
||||||
debugging btrfs file systems.
|
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n btrfs-progs-%{tar_version}
|
%setup -q -n btrfs-progs-%{tar_version}
|
||||||
%patch0
|
%patch0
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
%patch2 -p1
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
%patch4 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
%patch6 -p1
|
||||||
|
%patch7 -p1
|
||||||
|
%patch8 -p1
|
||||||
|
%patch9 -p1
|
||||||
|
%patch10 -p1
|
||||||
|
%patch11 -p1
|
||||||
|
%patch12 -p1
|
||||||
|
%patch13 -p1
|
||||||
|
%patch14 -p1
|
||||||
|
%patch15 -p1
|
||||||
|
%patch16 -p1
|
||||||
|
%patch20 -p1
|
||||||
|
%patch21 -p1
|
||||||
|
%patch22 -p1
|
||||||
|
%patch23 -p1
|
||||||
|
%patch24 -p1
|
||||||
|
%patch25 -p1
|
||||||
|
%patch26 -p1
|
||||||
|
%patch27 -p1
|
||||||
|
%patch28 -p1
|
||||||
|
%patch29 -p1
|
||||||
|
%patch30 -p1
|
||||||
|
%patch31 -p1
|
||||||
|
%patch32 -p1
|
||||||
|
%patch33 -p1
|
||||||
|
%patch34 -p1
|
||||||
|
%patch35 -p1
|
||||||
|
%patch36 -p1
|
||||||
|
%patch37 -p1
|
||||||
|
%patch38 -p1
|
||||||
|
%patch39 -p1
|
||||||
|
%patch40 -p1
|
||||||
|
%patch41 -p1
|
||||||
|
%patch42 -p1
|
||||||
|
%patch50 -p1
|
||||||
|
%patch51 -p1
|
||||||
|
%patch52 -p1
|
||||||
|
%patch53 -p1
|
||||||
|
%patch54 -p1
|
||||||
|
%patch55 -p1
|
||||||
|
%patch56 -p1
|
||||||
|
%patch57 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make %{?jobs:-j%jobs} CFLAGS="%{optflags}" all convert
|
make %{?jobs:-j%jobs} CFLAGS="%{optflags}" all convert
|
||||||
|
Loading…
Reference in New Issue
Block a user