-update to latest upstream

This commit is contained in:
Josef Bacik 2012-08-17 17:21:59 -04:00
parent 54126891f8
commit b5e03c726d
8 changed files with 445 additions and 16724 deletions

17
.gitignore vendored
View File

@ -1 +1,16 @@
btrfs-progs-0.19.tar.bz2
*.o
.*.o.d
version.h
man/*.gz
btrfs
btrfs-debug-tree
btrfs-map-logical
btrfs-show
btrfs-vol
btrfsck
btrfsctl
find-root
mkfs.btrfs
repair
restore
/btrfs-progs-0.19.20120817git043a639.tar.bz2

View File

@ -0,0 +1,84 @@
From 01077c81987011d8a50999824f96032c10b2733b Mon Sep 17 00:00:00 2001
From: Josef Bacik <jbacik@fusionio.com>
Date: Thu, 21 Jun 2012 16:02:10 -0400
Subject: [PATCH 1/3] Btrfs-progs: add btrfs device ready command
This command will be used by things like dracut that wish to know very
simply if all of the devices have been added to the kernel cache yet for the
device to be fully mounted. This keeps initrd's from constantly having to
try to mount the file system until it succeeds every time a device is added
to the system. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
cmds-device.c | 35 +++++++++++++++++++++++++++++++++++
ioctl.h | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/cmds-device.c b/cmds-device.c
index 771856b..b24e2a3 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -249,11 +249,46 @@ static int cmd_scan_dev(int argc, char **argv)
return 0;
}
+static const char * const cmd_ready_dev_usage[] = {
+ "btrfs device ready <device>",
+ "Check device to see if it has all of it's devices in cache for mounting",
+ NULL
+};
+
+static int cmd_ready_dev(int argc, char **argv)
+{
+ struct btrfs_ioctl_vol_args args;
+ int fd;
+ int ret;
+
+ if (check_argc_min(argc, 2))
+ usage(cmd_ready_dev_usage);
+
+ fd = open("/dev/btrfs-control", O_RDWR);
+ if (fd < 0) {
+ perror("failed to open /dev/btrfs-control");
+ return 10;
+ }
+
+ strncpy(args.name, argv[argc - 1], BTRFS_PATH_NAME_MAX);
+ ret = ioctl(fd, BTRFS_IOC_DEVICES_READY, &args);
+ if (ret < 0) {
+ fprintf(stderr, "ERROR: unable to determine if the device '%s'"
+ " is ready for mounting - %s\n", argv[argc - 1],
+ strerror(errno));
+ ret = 1;
+ }
+
+ close(fd);
+ return ret;
+}
+
const struct cmd_group device_cmd_group = {
device_cmd_group_usage, NULL, {
{ "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 },
{ "delete", cmd_rm_dev, cmd_rm_dev_usage, NULL, 0 },
{ "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 },
+ { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 },
{ 0, 0, 0, 0, 0 }
}
};
diff --git a/ioctl.h b/ioctl.h
index d6f3d07..30220ad 100644
--- a/ioctl.h
+++ b/ioctl.h
@@ -365,6 +365,8 @@ struct btrfs_ioctl_clone_range_args {
struct btrfs_ioctl_ino_path_args)
#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
struct btrfs_ioctl_ino_path_args)
+#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
+ struct btrfs_ioctl_vol_args)
#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
struct btrfs_ioctl_received_subvol_args)
--
1.7.7.6

View File

@ -0,0 +1,163 @@
From f507119002c6bb972df09a47edfa8998c0fc8172 Mon Sep 17 00:00:00 2001
From: Josef Bacik <jbacik@fusionio.com>
Date: Fri, 20 Jul 2012 11:09:43 -0400
Subject: [PATCH 2/3] Btrfs-progs: detect if the disk we are formatting is a
ssd
SSD's do not gain anything by having metadata DUP turned on. The underlying
file system that is a part of all SSD's could easily map duplicate metadat
blocks into the same erase block which effectively eliminates the benefit of
duplicating the metadata on disk. So detect if we are formatting a single
SSD drive and if we are do not use DUP. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
Makefile | 2 +-
man/mkfs.btrfs.8.in | 5 +++-
mkfs.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index c0aaa3d..1afef49 100644
--- a/Makefile
+++ b/Makefile
@@ -66,7 +66,7 @@ btrfsck: $(objects) btrfsck.o
$(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS)
mkfs.btrfs: $(objects) mkfs.o
- $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
+ $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) -lblkid
btrfs-debug-tree: $(objects) debug-tree.o
$(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS)
diff --git a/man/mkfs.btrfs.8.in b/man/mkfs.btrfs.8.in
index fc2e1d2..dfa7996 100644
--- a/man/mkfs.btrfs.8.in
+++ b/man/mkfs.btrfs.8.in
@@ -46,7 +46,10 @@ Specify a label for the filesystem.
.TP
\fB\-m\fR, \fB\-\-metadata \fIprofile\fR
Specify how metadata must be spanned across the devices specified. Valid
-values are raid0, raid1, raid10 or single.
+values are raid0, raid1, raid10, single or dup. Single device will have dup
+set by default except in the case of SSDs which will default to single. This is
+because SSDs can remap blocks internally so duplicate blocks could end up in the
+same erase block which negates the benefits of doing metadata duplication.
.TP
\fB\-M\fR, \fB\-\-mixed\fR
Mix data and metadata chunks together for more efficient space
diff --git a/mkfs.c b/mkfs.c
index dff5eb8..8816db8 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -37,6 +37,7 @@
#include <linux/fs.h>
#include <ctype.h>
#include <attr/xattr.h>
+#include <blkid/blkid.h>
#include "kerncompat.h"
#include "ctree.h"
#include "disk-io.h"
@@ -234,7 +235,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,
int data_profile_opt, u64 metadata_profile,
- int metadata_profile_opt, int mixed)
+ int metadata_profile_opt, int mixed, int ssd)
{
u64 num_devices = btrfs_super_num_devices(&root->fs_info->super_copy);
u64 allowed;
@@ -245,8 +246,12 @@ static int create_raid_groups(struct btrfs_trans_handle *trans,
* For mixed groups defaults are single/single.
*/
if (!metadata_profile_opt && !mixed) {
+ if (num_devices == 1 && ssd)
+ printf("Detected a SSD, turning off metadata "
+ "duplication. Mkfs with -m dup if you want to "
+ "force metadata duplication.\n");
metadata_profile = (num_devices > 1) ?
- BTRFS_BLOCK_GROUP_RAID1 : BTRFS_BLOCK_GROUP_DUP;
+ BTRFS_BLOCK_GROUP_RAID1 : (ssd) ? 0: BTRFS_BLOCK_GROUP_DUP;
}
if (!data_profile_opt && !mixed) {
data_profile = (num_devices > 1) ?
@@ -1201,6 +1206,49 @@ static int zero_output_file(int out_fd, u64 size, u32 sectorsize)
return ret;
}
+static int is_ssd(const char *file)
+{
+ char *devname;
+ blkid_probe probe;
+ char *dev;
+ char path[PATH_MAX];
+ dev_t disk;
+ int fd;
+ char rotational;
+
+ probe = blkid_new_probe_from_filename(file);
+ if (!probe)
+ return 0;
+
+ /*
+ * We want to use blkid_devno_to_wholedisk() but it's broken for some
+ * reason on F17 at least so we'll do this trickery
+ */
+ disk = blkid_probe_get_wholedisk_devno(probe);
+ devname = blkid_devno_to_devname(disk);
+
+ dev = strrchr(devname, '/');
+ dev++;
+
+ snprintf(path, PATH_MAX, "/sys/block/%s/queue/rotational", dev);
+
+ free(devname);
+ blkid_free_probe(probe);
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ return 0;
+ }
+
+ if (read(fd, &rotational, sizeof(char)) < sizeof(char)) {
+ close(fd);
+ return 0;
+ }
+ close(fd);
+
+ return !atoi((const char *)&rotational);
+}
+
int main(int ac, char **av)
{
char *file;
@@ -1227,6 +1275,7 @@ int main(int ac, char **av)
int data_profile_opt = 0;
int metadata_profile_opt = 0;
int nodiscard = 0;
+ int ssd = 0;
char *source_dir = NULL;
int source_dir_set = 0;
@@ -1352,6 +1401,9 @@ int main(int ac, char **av)
exit(1);
}
}
+
+ ssd = is_ssd(file);
+
if (mixed) {
if (metadata_profile != data_profile) {
fprintf(stderr, "With mixed block groups data and metadata "
@@ -1438,7 +1490,7 @@ raid_groups:
if (!source_dir_set) {
ret = create_raid_groups(trans, root, data_profile,
data_profile_opt, metadata_profile,
- metadata_profile_opt, mixed);
+ metadata_profile_opt, mixed, ssd);
BUG_ON(ret);
}
--
1.7.7.6

View File

@ -0,0 +1,143 @@
From cbe7ca77431c40bab80135c7b8ee6a5dece56e03 Mon Sep 17 00:00:00 2001
From: Josef Bacik <jbacik@fusionio.com>
Date: Fri, 27 Jul 2012 08:24:37 -0400
Subject: [PATCH 3/3] Btrfs-progs: only enforce a maximum size if we specify
one
My patch
04609add88ef8428d725de6ef60f46a3ff0dbc8e
introduced a regression where if you mkfs'ed a group of disks with different
sizes it limited the disks to the size of the first one that is specified.
This was not the intent of my patch, I only want it to limit the size based
on the -b option, so I've reworked the code to pass in a max block count and
that fixes the issue. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
btrfs-vol.c | 3 ++-
cmds-device.c | 3 ++-
mkfs.c | 15 ++++++---------
utils.c | 12 +++---------
utils.h | 6 ++----
5 files changed, 15 insertions(+), 24 deletions(-)
diff --git a/btrfs-vol.c b/btrfs-vol.c
index 0efdbc1..ad824bd 100644
--- a/btrfs-vol.c
+++ b/btrfs-vol.c
@@ -150,7 +150,8 @@ int main(int ac, char **av)
if (cmd == BTRFS_IOC_ADD_DEV) {
int mixed = 0;
- ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count, &mixed);
+ ret = btrfs_prepare_device(devfd, device, 1, &dev_block_count,
+ 0, &mixed, 0);
if (ret) {
fprintf(stderr, "Unable to init %s\n", device);
exit(1);
diff --git a/cmds-device.c b/cmds-device.c
index b24e2a3..75ee293 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -107,7 +107,8 @@ static int cmd_add_dev(int argc, char **argv)
continue;
}
- res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count, &mixed);
+ res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count,
+ 0, &mixed, 0);
if (res) {
fprintf(stderr, "ERROR: Unable to init '%s'\n", argv[i]);
close(devfd);
diff --git a/mkfs.c b/mkfs.c
index 8816db8..93cd83c 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1373,11 +1373,9 @@ int main(int ac, char **av)
exit(1);
}
first_file = file;
- ret = __btrfs_prepare_device(fd, file, zero_end,
- &dev_block_count, &mixed, nodiscard);
- if (block_count == 0)
- block_count = dev_block_count;
- else if (block_count > dev_block_count) {
+ ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
+ block_count, &mixed, nodiscard);
+ if (block_count && block_count > dev_block_count) {
fprintf(stderr, "%s is smaller than requested size\n", file);
exit(1);
}
@@ -1418,7 +1416,7 @@ int main(int ac, char **av)
leafsize * i;
}
- ret = make_btrfs(fd, file, label, blocks, block_count,
+ ret = make_btrfs(fd, file, label, blocks, dev_block_count,
nodesize, leafsize,
sectorsize, stripesize);
if (ret) {
@@ -1474,9 +1472,8 @@ int main(int ac, char **av)
close(fd);
continue;
}
- dev_block_count = block_count;
- ret = __btrfs_prepare_device(fd, file, zero_end,
- &dev_block_count, &mixed, nodiscard);
+ ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count,
+ block_count, &mixed, nodiscard);
mixed = old_mixed;
BUG_ON(ret);
diff --git a/utils.c b/utils.c
index aade9e2..a5ffb62 100644
--- a/utils.c
+++ b/utils.c
@@ -537,13 +537,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
}
int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
- int *mixed)
-{
- /* discard by default when called from 'device add' */
- return __btrfs_prepare_device(fd, file, zero_end, block_count_ret, mixed, 0);
-}
-int __btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
- int *mixed, int nodiscard)
+ u64 max_block_count, int *mixed, int nodiscard)
{
u64 block_count;
u64 bytenr;
@@ -561,8 +555,8 @@ int __btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_re
fprintf(stderr, "unable to find %s size\n", file);
exit(1);
}
- if (*block_count_ret)
- block_count = min(block_count, *block_count_ret);
+ if (max_block_count)
+ block_count = min(block_count, max_block_count);
zero_end = 1;
if (block_count < 1024 * 1024 * 1024 && !(*mixed)) {
diff --git a/utils.h b/utils.h
index c147c12..3a0368b 100644
--- a/utils.h
+++ b/utils.h
@@ -26,10 +26,8 @@ int make_btrfs(int fd, const char *device, const char *label,
u32 leafsize, u32 sectorsize, u32 stripesize);
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, int *mixed);
-int __btrfs_prepare_device(int fd, char *file, int zero_end,
- u64 *block_count_ret, int *mixed, int nodiscard);
+int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
+ u64 max_block_count, int *mixed, int nodiscard);
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.7.6

21
btrfs-init-dev-list.patch Normal file
View File

@ -0,0 +1,21 @@
diff --git a/utils.c b/utils.c
index a5ffb62..f6686c6 100644
--- a/utils.c
+++ b/utils.c
@@ -476,7 +476,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
u64 num_devs;
int ret;
- device = kmalloc(sizeof(*device), GFP_NOFS);
+ device = kzalloc(sizeof(*device), GFP_NOFS);
if (!device)
return -ENOMEM;
buf = kmalloc(sectorsize, GFP_NOFS);
@@ -502,6 +502,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
device->bytes_used = 0;
device->total_ios = 0;
device->dev_root = root->fs_info->dev_root;
+ INIT_LIST_HEAD(&device->dev_list);
ret = btrfs_add_device(trans, root, device);
BUG_ON(ret);

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,23 @@
Name: btrfs-progs
Version: 0.19
Release: 20%{?dist}
Version: 0.19.20120817git043a639
Release: 1%{?dist}
Summary: Userspace programs for btrfs
Group: System Environment/Base
License: GPLv2
URL: http://btrfs.wiki.kernel.org/index.php/Main_Page
Source0: http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/%{name}-%{version}.tar.bz2
Patch0: btrfs-progs-upstream.patch
Patch1: btrfs-progs-fix-labels.patch
Patch2: btrfs-progs-valgrind.patch
Patch3: btrfs-progs-build-fixes.patch
Patch4: Btrfs-progs-make-btrfs-filesystem-show-uuid-actually.patch
Source0: %{name}-%{version}.tar.bz2
Patch0: btrfs-progs-fix-labels.patch
Patch1: btrfs-progs-valgrind.patch
Patch2: btrfs-progs-build-fixes.patch
Patch3: Btrfs-progs-add-btrfs-device-ready-command.patch
Patch4: Btrfs-progs-detect-if-the-disk-we-are-formatting-is-.patch
Patch5: Btrfs-progs-only-enforce-a-maximum-size-if-we-specif.patch
Patch6: btrfs-init-dev-list.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel, libuuid-devel, zlib-devel, libacl-devel
BuildRequires: e2fsprogs-devel, libuuid-devel, zlib-devel, libacl-devel, libblkid-devel
%define _root_sbindir /sbin
@ -29,6 +32,8 @@ check, modify and correct any inconsistencies in the btrfs filesystem.
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
@ -65,6 +70,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/btrfs.8.gz
%changelog
* Fri Aug 17 2012 Josef Bacik <josef@toxicpanda.com> 0.19.20120817git043a639-1
- update to latest btrfs-progs
* Wed Jul 18 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.19-20
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

View File

@ -1 +1 @@
5854728d080cc76f21a83bdc99b6ddaa btrfs-progs-0.19.tar.bz2
97159994f7f5af4ac159825639bc88fc btrfs-progs-0.19.20120817git043a639.tar.bz2