summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES14
-rw-r--r--Documentation/btrfs-inspect-internal.asciidoc29
-rw-r--r--Documentation/btrfs-man5.asciidoc15
-rw-r--r--Documentation/btrfs-subvolume.asciidoc6
-rw-r--r--Documentation/mkfs.btrfs.asciidoc20
-rw-r--r--Makefile.in5
-rw-r--r--btrfs-convert.c6
-rw-r--r--cmds-check.c11
-rw-r--r--cmds-filesystem.c15
-rw-r--r--cmds-inspect-dump-super.c32
-rw-r--r--cmds-inspect-tree-stats.c16
-rw-r--r--cmds-subvolume.c6
-rwxr-xr-xconfigure18
-rw-r--r--ctree.h3
-rw-r--r--debian/changelog6
-rw-r--r--disk-io.c6
-rw-r--r--extent-tree.c2
-rw-r--r--extent_io.h2
-rw-r--r--mkfs.c6
-rw-r--r--tests/common.convert95
-rw-r--r--tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.imgbin0 -> 24576 bytes
-rwxr-xr-xtests/fsck-tests/021-partially-dropped-snapshot-case/test.sh18
-rwxr-xr-xtests/fuzz-tests/001-simple-check-unmounted/test.sh (renamed from tests/fuzz-tests/001-simple-unmounted/test.sh)0
-rwxr-xr-xtests/fuzz-tests/002-simple-image/test.sh24
-rwxr-xr-xtests/fuzz-tests/003-multi-check-unmounted/test.sh26
-rw-r--r--tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.txt5
-rw-r--r--tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xzbin0 -> 3676 bytes
-rw-r--r--tests/fuzz-tests/images/bko-155181-bad-backref.raw.txt22
-rw-r--r--tests/fuzz-tests/images/bko-155181-bad-backref.raw.xzbin0 -> 3684 bytes
-rw-r--r--tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.txt25
-rw-r--r--tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xzbin0 -> 3712 bytes
-rw-r--r--tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.txt62
-rw-r--r--tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xzbin0 -> 3764 bytes
-rw-r--r--utils.c22
-rw-r--r--utils.h4
-rwxr-xr-xversion.sh2
36 files changed, 438 insertions, 85 deletions
diff --git a/CHANGES b/CHANGES
index 03168517..559267ab 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,17 @@
+btrfs-progs-4.7.3 (2016-09-21)
+ * fixed free space tree compat status
+ * check: low-mem mode: handle partially dropped snapshots
+ * dump-super: consolidate options for superblock copy
+ * tree-stats: check mount status
+ * subvol delete: handle verbosity option
+ * defrag: print correct error string
+ * mkfs: fix reading rotational status
+ * other:
+ * UBSAN build option
+ * documentation updates
+ * enhanced tests: convert, fuzzed images, more tools to run on fuzzed
+ images
+
btrfs-progs-4.7.2 (2016-09-05)
* check:
* urgent fix: false report of backref mismatches; do not --repair
diff --git a/Documentation/btrfs-inspect-internal.asciidoc b/Documentation/btrfs-inspect-internal.asciidoc
index 74f6dea8..44615e76 100644
--- a/Documentation/btrfs-inspect-internal.asciidoc
+++ b/Documentation/btrfs-inspect-internal.asciidoc
@@ -30,25 +30,36 @@ Besides verifictaion of the filesystem signature, there are no other sanity
checks. The superblock checksum status is reported, the device item and
filesystem UUIDs are checked and reported.
+
+NOTE: the meaning of option '-s' has changed in version 4.8 to be consistent
+with other tools to specify superblock copy rather the offset. The old way still
+works, but prints a warning. Please update your scripts to use '--bytenr'
+instead. The option '-i' has been deprecated.
++
`Options`
+
-f|--full::::
print full superblock information, including the system chunk array and backup roots
-a|--all::::
-print information about all present superblock copies (cannot be used together with '-i' option)
--i <super_mirror>::::
-specify which mirror to print, valid values are 0, 1 and 2 and the superblock must be present on the device
+print information about all present superblock copies (cannot be used together
+with '-s' option)
+-i <super>::::
+(deprecated since 4.8, same behaviour as '--super')
+--bytenr <bytenr>::::
+specify offset to a superblock in a non-standard location at 'bytenr', useful
+for debugging (disables the '-f' option)
+
-If there are multiple options specified, only the last one is applies.
+If there are multiple options specified, only the last one applies.
+
-F|--force::::
-attempt to print the superblock even if thre's no valid BTRFS signature found
+attempt to print the superblock even if thre's no valid BTRFS signature found,
+the result may be completely wrong if the data do not resemble a superblock
+
-The result may be completely wrong if the data do not resemble a superblock.
+-s|--super <bytenr>::::
+(see compatibility note above)
+
--s <bytenr>::::
-specify offset to a superblock in a non-standard location at 'bytenr', useful
-for debugging (disables the '-f' option)
+specify which mirror to print, valid values are 0, 1 and 2 and the superblock
+must be present on the device with a valid signature, can be used together with
+'--force'
*dump-tree* [options] <device>::
(replaces the standalone tool *btrfs-debug-tree*)
diff --git a/Documentation/btrfs-man5.asciidoc b/Documentation/btrfs-man5.asciidoc
index a1f364e0..caa9390b 100644
--- a/Documentation/btrfs-man5.asciidoc
+++ b/Documentation/btrfs-man5.asciidoc
@@ -214,15 +214,18 @@ parameters, eg. 'panic', 'oops' or 'crashkernel'.
*flushoncommit*::
*noflushoncommit*::
-(default: on)
+(default: off)
+
This option forces any data dirtied by a write in a prior transaction to commit
-as part of the current commit. This makes the committed state a fully
-consistent view of the file system from the application's perspective (i.e., it
-includes all completed file system operations). This was previously the
-behavior only when a snapshot was created.
+as part of the current commit, effectively a full filesystem sync.
++
+This makes the committed state a fully consistent view of the file system from
+the application's perspective (i.e., it includes all completed file system
+operations). This was previously the behavior only when a snapshot was
+created.
+
-Disabling flushing may improve performance but is not crash-safe.
+When off, the filesystem is consistent but buffered writes may last more than
+one transaction commit.
*fragment='type'*::
(depends on compile-time option BTRFS_DEBUG, since: 4.4, default: off)
diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc
index 2044b07d..0a1ca003 100644
--- a/Documentation/btrfs-subvolume.asciidoc
+++ b/Documentation/btrfs-subvolume.asciidoc
@@ -47,7 +47,7 @@ do not affect the files in the original subvolume.
SUBCOMMAND
-----------
-*create* [-i <qgroupid>] [<dest>]<name>::
+*create* [-i <qgroupid>] [<dest>/]<name>::
Create a subvolume <name> in <dest>.
+
If <dest> is not given, subvolume <name> will be created in the current
@@ -130,14 +130,14 @@ list subvolumes in the filesystem that its generation is
neither \'+' nor \'-', it means = value.
-C [+|-]<value>::::
list subvolumes in the filesystem that its ogeneration is
->=, \<= or = value. The usage is the same to '-g' option.
+>=, \<= or = value. The usage is the same to '-G' option.
--sort=rootid,gen,ogen,path::::
list subvolumes in order by specified items.
you can add \'\+' or \'-' in front of each items, \'+' means ascending,
\'-' means descending. The default is ascending.
+
for --sort you can combine some items together by \',', just like
--sort=+ogen,-gen,path,rootid.
+--sort=+ogen,-gen,path,rootid.
*set-default* <id> <path>::
Set the subvolume of the filesystem <path> which is mounted as
diff --git a/Documentation/mkfs.btrfs.asciidoc b/Documentation/mkfs.btrfs.asciidoc
index 98fe694b..6515e145 100644
--- a/Documentation/mkfs.btrfs.asciidoc
+++ b/Documentation/mkfs.btrfs.asciidoc
@@ -263,18 +263,30 @@ There are the following block group types available:
.2+^.<h| Profile 3+^.^h| Redundancy .2+^.<h| Min/max devices
^.^h| Copies ^.^h| Parity ^.<h| Striping
| single | 1 | | | 1/any
-| DUP | 2 / 1 device | | | 1/any ^(see note)^
+| DUP | 2 / 1 device | | | 1/any ^(see note 1)^
| RAID0 | | | 1 to N | 2/any
| RAID1 | 2 | | | 2/any
| RAID10 | 2 | | 1 to N | 4/any
-| RAID5 | 1 | 1 | 2 to N - 1 | 2/any
-| RAID6 | 1 | 2 | 3 to N - 2 | 3/any
+| RAID5 | 1 | 1 | 2 to N - 1 | 2/any ^(see note 2)^
+| RAID6 | 1 | 2 | 3 to N - 2 | 3/any ^(see note 3)^
|=============================================================
-'Note:' DUP may exist on more than 1 device if it starts on a single device and
+WARNING: It's not recommended to build btrfs with RAID0/1/10/5/6 prfiles on
+partitions from the same device. Neither redundancy nor performance will be
+improved.
+
+'Note 1:' DUP may exist on more than 1 device if it starts on a single device and
another one is added. Since version 4.5.1, *mkfs.btrfs* will let you create DUP
on multiple devices.
+'Note 2:' It's not recommended to use 2 devices with RAID5. In that case,
+parity stripe will contain the same data as the data stripe, making RAID5
+degraded to RAID1 with more overhead.
+
+'Note 3:' It's also not recommended to use 3 devices with RAID6, unless you
+want to get effectively 3 copies in a RAID1-like manner (but not exactly that).
+N-copies RAID1 is not implemented.
+
DUP PROFILES ON A SINGLE DEVICE
-------------------------------
diff --git a/Makefile.in b/Makefile.in
index fd68b3ee..214b0428 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,6 +18,7 @@
# abort - call abort() on first error (dumps core)
# all - shortcut for all of the above
# asan - enable address sanitizer compiler feature
+# ubsan - undefined behaviour sanitizer compiler feature
# W=123 build with warnings (default: off)
# DEBUG_CFLAGS additional compiler flags for debugging build
# EXTRA_CFLAGS additional compiler flags
@@ -150,6 +151,10 @@ ifneq (,$(findstring asan,$(D)))
DEBUG_CFLAGS_INTERNAL += -fsanitize=address
endif
+ifneq (,$(findstring ubsan,$(D)))
+ DEBUG_CFLAGS_INTERNAL += -fsanitize=undefined
+endif
+
MAKEOPTS = --no-print-directory Q=$(Q)
# build all by default
diff --git a/btrfs-convert.c b/btrfs-convert.c
index c10dc172..5175f1f7 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2373,10 +2373,8 @@ static int do_convert(const char *devname, int datacsum, int packing,
mkfs_cfg.stripesize = blocksize;
mkfs_cfg.features = features;
/* New convert need these space */
- mkfs_cfg.fs_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
- mkfs_cfg.chunk_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
- *(mkfs_cfg.fs_uuid) = '\0';
- *(mkfs_cfg.chunk_uuid) = '\0';
+ memset(mkfs_cfg.chunk_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
+ memset(mkfs_cfg.fs_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
ret = make_btrfs(fd, &mkfs_cfg, &cctx);
if (ret) {
diff --git a/cmds-check.c b/cmds-check.c
index a453696e..df97d3b6 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -9063,9 +9063,10 @@ static int check_tree_block_backref(struct btrfs_fs_info *fs_info, u64 root_id,
free_extent_buffer(eb);
btrfs_init_path(&path);
+ path.lowest_level = level;
/* Search with the first key, to ensure we can reach it */
ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
- if (ret) {
+ if (ret < 0) {
err |= REFERENCER_MISSING;
goto release_out;
}
@@ -9948,6 +9949,8 @@ static int traverse_tree_block(struct btrfs_root *root,
struct extent_buffer *node)
{
struct extent_buffer *eb;
+ struct btrfs_key key;
+ struct btrfs_key drop_key;
int level;
u64 nr;
int i;
@@ -9993,6 +9996,7 @@ static int traverse_tree_block(struct btrfs_root *root,
}
nr = btrfs_header_nritems(node);
+ btrfs_disk_key_to_cpu(&drop_key, &root->root_item.drop_progress);
btree_space_waste += (BTRFS_NODEPTRS_PER_BLOCK(root) - nr) *
sizeof(struct btrfs_key_ptr);
@@ -10000,6 +10004,11 @@ static int traverse_tree_block(struct btrfs_root *root,
for (i = 0; i < nr; i++) {
u64 blocknr = btrfs_node_blockptr(node, i);
+ btrfs_node_key_to_cpu(node, &key, i);
+ if (level == root->root_item.drop_level &&
+ is_dropped_key(&key, &drop_key))
+ continue;
+
/*
* As a btrfs tree has most 8 levels (0..7), so it's quite safe
* to call the function itself.
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 76ea82ed..90eccf70 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -993,32 +993,35 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
int typeflag, struct FTW *ftwbuf)
{
int ret = 0;
- int e = 0;
+ int err = 0;
int fd = 0;
if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
if (defrag_global_verbose)
printf("%s\n", fpath);
fd = open(fpath, O_RDWR);
- if (fd < 0)
+ if (fd < 0) {
+ err = errno;
goto error;
+ }
ret = do_defrag(fd, defrag_global_fancy_ioctl, &defrag_global_range);
- e = errno;
close(fd);
- if (ret && e == ENOTTY && defrag_global_fancy_ioctl) {
+ if (ret && errno == ENOTTY && defrag_global_fancy_ioctl) {
error("defrag range ioctl not "
"supported in this kernel, please try "
"without any options.");
defrag_global_errors++;
return ENOTTY;
}
- if (ret)
+ if (ret) {
+ err = errno;
goto error;
+ }
}
return 0;
error:
- error("defrag failed on %s: %s", fpath, strerror(e));
+ error("defrag failed on %s: %s", fpath, strerror(err));
defrag_global_errors++;
return 0;
}
diff --git a/cmds-inspect-dump-super.c b/cmds-inspect-dump-super.c
index aab50752..0ae740a2 100644
--- a/cmds-inspect-dump-super.c
+++ b/cmds-inspect-dump-super.c
@@ -458,11 +458,18 @@ static int load_and_dump_sb(char *filename, int fd, u64 sb_bytenr, int full,
const char * const cmd_inspect_dump_super_usage[] = {
"btrfs inspect-internal dump-super [options] device [device...]",
"Dump superblock from a device in a textual form",
- "-f|--full print full superblock information",
- "-a|--all print information about all superblocks",
- "-i <super_mirror> specify which mirror to print out",
- "-F|--force attempt to dump superblocks with bad magic",
- "-s <bytenr> specify alternate superblock offset",
+ "-f|--full print full superblock information, backup roots etc.",
+ "-a|--all print information about all superblocks",
+ "-s|--super <super> specify which copy to print out (values: 0, 1, 2)",
+ "-F|--force attempt to dump superblocks with bad magic",
+ "--bytenr <offset> specify alternate superblock offset",
+ "",
+ "Deprecated syntax:",
+ "-s <bytenr> specify alternate superblock offset, values other than 0, 1, 2",
+ " will be interpreted as --bytenr for backward compatibility,",
+ " option renamed for consistency with other tools (eg. check)",
+ "-i <super> specify which copy to print out (values: 0, 1, 2), now moved",
+ " to -s|--super",
NULL
};
@@ -484,6 +491,7 @@ int cmd_inspect_dump_super(int argc, char **argv)
{"all", no_argument, NULL, 'a'},
{"full", no_argument, NULL, 'f'},
{"force", no_argument, NULL, 'F'},
+ {"super", required_argument, NULL, 's' },
{NULL, 0, NULL, 0}
};
@@ -493,11 +501,13 @@ int cmd_inspect_dump_super(int argc, char **argv)
switch (c) {
case 'i':
+ warning(
+ "option -i is deprecated, please use -s or --super");
arg = arg_strtou64(optarg);
if (arg >= BTRFS_SUPER_MIRROR_MAX) {
error("super mirror too big: %llu >= %d",
arg, BTRFS_SUPER_MIRROR_MAX);
- usage(cmd_inspect_dump_super_usage);
+ return 1;
}
sb_bytenr = btrfs_sb_offset(arg);
break;
@@ -512,7 +522,15 @@ int cmd_inspect_dump_super(int argc, char **argv)
force = 1;
break;
case 's':
- sb_bytenr = arg_strtou64(optarg);
+ arg = arg_strtou64(optarg);
+ if (BTRFS_SUPER_MIRROR_MAX <= arg) {
+ warning(
+ "deprecated use of -s <bytenr> with %llu, assuming --bytenr",
+ (unsigned long long)arg);
+ sb_bytenr = arg;
+ } else {
+ sb_bytenr = btrfs_sb_offset(arg);
+ }
all = 0;
break;
default:
diff --git a/cmds-inspect-tree-stats.c b/cmds-inspect-tree-stats.c
index c35f5887..cd7ef3ba 100644
--- a/cmds-inspect-tree-stats.c
+++ b/cmds-inspect-tree-stats.c
@@ -457,18 +457,14 @@ int cmd_inspect_tree_stats(int argc, char **argv)
usage(cmd_inspect_tree_stats_usage);
}
- /*
- if ((ret = check_mounted(argv[optind])) < 0) {
- fprintf(stderr, "Could not check mount status: %d\n", ret);
- if (ret == -EACCES)
- fprintf(stderr, "Maybe you need to run as root?\n");
- return ret;
+ ret = check_mounted(argv[optind]);
+ if (ret < 0) {
+ warning("unable to check mount status of: %s",
+ strerror(-ret));
} else if (ret) {
- fprintf(stderr, "%s is currently mounted. Aborting.\n",
- argv[optind]);
- return -EBUSY;
+ warning("%s already mounted, results may be inaccurate",
+ argv[optind]);
}
- */
root = open_ctree(argv[optind], 0, 0);
if (!root) {
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index e7ef67d3..b3f7cbcb 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -128,7 +128,7 @@ static int cmd_subvol_create(int argc, char **argv)
DIR *dirstream = NULL;
while (1) {
- int c = getopt(argc, argv, "c:i:v");
+ int c = getopt(argc, argv, "c:i:");
if (c < 0)
break;
@@ -245,6 +245,7 @@ static const char * const cmd_subvol_delete_usage[] = {
"",
"-c|--commit-after wait for transaction commit at the end of the operation",
"-C|--commit-each wait for transaction commit after deleting each subvolume",
+ "-v|--verbose verbose output of operations",
NULL
};
@@ -267,10 +268,11 @@ static int cmd_subvol_delete(int argc, char **argv)
static const struct option long_options[] = {
{"commit-after", no_argument, NULL, 'c'}, /* commit mode 1 */
{"commit-each", no_argument, NULL, 'C'}, /* commit mode 2 */
+ {"verbose", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
- c = getopt_long(argc, argv, "cC", long_options, NULL);
+ c = getopt_long(argc, argv, "cCv", long_options, NULL);
if (c < 0)
break;
diff --git a/configure b/configure
index d23f5b1b..bca05c94 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for btrfs-progs v4.7.2.
+# Generated by GNU Autoconf 2.69 for btrfs-progs v4.7.3.
#
# Report bugs to <linux-btrfs@vger.kernel.org>.
#
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='btrfs-progs'
PACKAGE_TARNAME='btrfs-progs'
-PACKAGE_VERSION='v4.7.2'
-PACKAGE_STRING='btrfs-progs v4.7.2'
+PACKAGE_VERSION='v4.7.3'
+PACKAGE_STRING='btrfs-progs v4.7.3'
PACKAGE_BUGREPORT='linux-btrfs@vger.kernel.org'
PACKAGE_URL='http://btrfs.wiki.kernel.org'
@@ -1290,7 +1290,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures btrfs-progs v4.7.2 to adapt to many kinds of systems.
+\`configure' configures btrfs-progs v4.7.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1355,7 +1355,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of btrfs-progs v4.7.2:";;
+ short | recursive ) echo "Configuration of btrfs-progs v4.7.3:";;
esac
cat <<\_ACEOF
@@ -1471,7 +1471,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-btrfs-progs configure v4.7.2
+btrfs-progs configure v4.7.3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1840,7 +1840,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by btrfs-progs $as_me v4.7.2, which was
+It was created by btrfs-progs $as_me v4.7.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -6684,7 +6684,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by btrfs-progs $as_me v4.7.2, which was
+This file was extended by btrfs-progs $as_me v4.7.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6747,7 +6747,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-btrfs-progs config.status v4.7.2
+btrfs-progs config.status v4.7.3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/ctree.h b/ctree.h
index 1d153ec5..297a98c5 100644
--- a/ctree.h
+++ b/ctree.h
@@ -490,8 +490,7 @@ struct btrfs_super_block {
#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
-#define BTRFS_FEATURE_COMPAT_RO_SUPP \
- (BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE)
+#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
#define BTRFS_FEATURE_INCOMPAT_SUPP \
(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \
diff --git a/debian/changelog b/debian/changelog
index 70c7d983..765dce32 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+btrfs-progs (4.7.3-1) UNRELEASED; urgency=medium
+
+ * New upstream release.
+
+ -- Dimitri John Ledkov <xnox@ubuntu.com> Thu, 22 Sep 2016 14:47:37 +0100
+
btrfs-progs (4.7.2-1) unstable; urgency=medium
* New upstream release. (Closes: #836778)
diff --git a/disk-io.c b/disk-io.c
index f5340c31..2fd3330f 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1149,7 +1149,9 @@ int btrfs_scan_fs_devices(int fd, const char *path,
dev_size = seek_ret;
lseek(fd, 0, SEEK_SET);
if (sb_bytenr > dev_size) {
- fprintf(stderr, "Superblock bytenr is larger than device size\n");
+ error("superblock bytenr %llu is larger than device size %llu",
+ (unsigned long long)sb_bytenr,
+ (unsigned long long)dev_size);
return -EINVAL;
}
@@ -1439,7 +1441,7 @@ static int check_super(struct btrfs_super_block *sb, unsigned sbflags)
csum_type = btrfs_super_csum_type(sb);
if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) {
- error("unsupported checksum algorithm %u\n", csum_type);
+ error("unsupported checksum algorithm %u", csum_type);
return -EIO;
}
csum_size = btrfs_csum_sizes[csum_type];
diff --git a/extent-tree.c b/extent-tree.c
index 6cc8d3f5..0607be66 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -3259,6 +3259,8 @@ int btrfs_read_block_groups(struct btrfs_root *root)
cache->cached = 0;
cache->pinned = 0;
key.objectid = found_key.objectid + found_key.offset;
+ if (found_key.offset == 0)
+ key.objectid++;
btrfs_release_path(path);
cache->flags = btrfs_block_group_flags(&cache->item);
bit = 0;
diff --git a/extent_io.h b/extent_io.h
index d9594c32..208c4fea 100644
--- a/extent_io.h
+++ b/extent_io.h
@@ -97,7 +97,7 @@ struct extent_buffer {
int refs;
u32 flags;
int fd;
- char data[];
+ char data[] __attribute__((aligned(8)));
};
static inline void extent_buffer_get(struct extent_buffer *eb)
diff --git a/mkfs.c b/mkfs.c
index b33e3688..4b88987c 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1193,13 +1193,13 @@ static int is_ssd(const char *file)
return 0;
}
- if (read(fd, &rotational, sizeof(char)) < sizeof(char)) {
+ if (read(fd, &rotational, 1) < 1) {
close(fd);
return 0;
}
close(fd);
- return !atoi((const char *)&rotational);
+ return rotational == '0';
}
static int _cmp_device_by_id(void *priv, struct list_head *a,
@@ -1735,7 +1735,7 @@ int main(int argc, char **argv)
}
mkfs_cfg.label = label;
- mkfs_cfg.fs_uuid = fs_uuid;
+ memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));
memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
mkfs_cfg.num_bytes = dev_block_count;
mkfs_cfg.nodesize = nodesize;
diff --git a/tests/common.convert b/tests/common.convert
index 4e3d49c9..1e00d389 100644
--- a/tests/common.convert
+++ b/tests/common.convert
@@ -123,6 +123,38 @@ convert_test_gen_checksums() {
count=1 >/dev/null 2>&1
run_check_stdout $SUDO_HELPER find $TEST_MNT -type f ! -name 'image' -exec md5sum {} \+ > "$CHECKSUMTMP"
}
+# list $TEST_MNT data set file permissions.
+# $1: path where the permissions will be stored
+convert_test_perm() {
+ local PERMTMP
+ PERMTMP="$1"
+ FILES_LIST=$(mktemp --tmpdir btrfs-progs-convert.fileslistXXXXXX)
+
+ run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/test bs=$nodesize \
+ count=1 >/dev/null 2>&1
+ run_check_stdout $SUDO_HELPER find $TEST_MNT -type f ! -name 'image' -fprint $FILES_LIST
+ # Fix directory entries order
+ sort $FILES_LIST -o $FILES_LIST
+ for file in `cat $FILES_LIST` ;do
+ run_check_stdout $SUDO_HELPER getfacl --absolute-names $file >> "$PERMTMP"
+ done
+ rm -- $FILES_LIST
+}
+# list acls of files on $TEST_MNT
+# $1: path where the acls will be stored
+convert_test_acl() {
+ local ACLSTMP
+ ACLTMP="$1"
+ FILES_LIST=$(mktemp --tmpdir btrfs-progs-convert.fileslistXXXXXX)
+
+ run_check_stdout $SUDO_HELPER find $TEST_MNT/acls -type f -fprint $FILES_LIST
+ # Fix directory entries order
+ sort $FILES_LIST -o $FILES_LIST
+ for file in `cat $FILES_LIST`;do
+ run_check_stdout $SUDO_HELPER getfattr --absolute-names -d $file >> "$ACLTMP"
+ done
+ rm -- $FILES_LIST
+}
# do conversion with given features and nodesize, fsck afterwards
# $1: features, argument of -O, can be empty
@@ -133,15 +165,68 @@ convert_test_do_convert() {
run_check $TOP/btrfs-show-super -Ffa $TEST_DEV
}
+# post conversion check, verify file permissions.
+# $1: file with ext permissions.
+convert_test_post_check_permissions() {
+ local EXT_PERMTMP
+ local BTRFS_PERMTMP
+
+ EXT_PERMTMP="$1"
+ BTRFS_PERMTMP=$(mktemp --tmpdir btrfs-progs-convert.permXXXXXX)
+ convert_test_perm "$BTRFS_PERMTMP"
+
+ btrfs_perm=`md5sum $BTRFS_PERMTMP | cut -f1 -d' '`
+ ext_perm=`md5sum $EXT_PERMTMP | cut -f1 -d' '`
+
+ if [ "$btrfs_perm" != "$ext_perm" ];
+ then
+ btrfs_perm_file=`md5sum $BTRFS_PERMTMP | cut -f2 -d' '`
+ ext_perm_file=`md5sum $EXT_PERMTMP | cut -f2 -d' '`
+ _fail "file permission failed. Mismatched BTRFS:$btrfs_perm_file:$btrfs_perm EXT:$ext_perm_file:$ext_perm"
+ fi
+
+ rm -- $BTRFS_PERMTMP
+}
+# post conversion check, compare BTRFS file acls against EXT.
+# $1: file with ext acls.
+convert_test_post_check_acl() {
+ local EXT_ACLTMP
+ local BTRFS_ACLTMP
+
+ EXT_ACLTMP="$1"
+ BTRFS_ACLTMP=$(mktemp --tmpdir btrfs-progs-convert.aclsXXXXXXX)
+ convert_test_acl "$BTRFS_ACLTMP"
+
+ btrfs_acl=`md5sum $BTRFS_ACLTMP | cut -f1 -d' '`
+ ext_acl=`md5sum $EXT_ACLTMP | cut -f1 -d' '`
+
+ if [ "$btrfs_acl" != "$ext_acl" ]
+ then
+ btrfs_acl_file=`md5sum $BTRFS_ACLTMP | cut -f2 -d' '`
+ ext_acl_file=`md5sum $EXT_ACLTMP | cut -f2 -d' '`
+ _fail "file acl failed. Mismatched BTRFS:$btrfs_acl_file:$btrfs_acl EXT:$ext_acl_file:$ext_acl"
+ fi
+
+ rm -- $BTRFS_ACLTMP
+}
# post conversion checks, verify md5sums
# $1: file with checksums
+# $2: file with permissions.
+# $3: file with acl entries.
convert_test_post_check() {
local CHECKSUMTMP
+ local EXT_PERMTMP
+ local EXT_ACLTMP
+
CHECKSUMTMP="$1"
+ EXT_PERMTMP="$2"
+ EXT_ACLTMP="$3"
run_check_mount_test_dev
run_check_stdout $SUDO_HELPER md5sum -c "$CHECKSUMTMP" |
grep -q 'FAILED' && _fail "file validation failed"
+ convert_test_post_check_permissions "$EXT_PERMTMP"
+ convert_test_post_check_acl "$EXT_ACLTMP"
run_check_umount_test_dev
}
@@ -161,6 +246,8 @@ convert_test() {
local nodesize
local msg
local CHECKSUMTMP
+ local EXT_PERMTMP
+ local EXT_ACLTMP
features="$1"
msg="$2"
@@ -170,13 +257,19 @@ convert_test() {
convert_test_prep_fs "$@"
populate_fs
CHECKSUMTMP=$(mktemp --tmpdir btrfs-progs-convert.XXXXXXXXXX)
+ EXT_PERMTMP=$(mktemp --tmpdir btrfs-progs-convert.permXXXXXX)
+ EXT_ACLTMP=$(mktemp --tmpdir btrfs-progs-convert.aclsXXXXXXX)
convert_test_gen_checksums "$CHECKSUMTMP"
+ convert_test_perm "$EXT_PERMTMP"
+ convert_test_acl "$EXT_ACLTMP"
run_check_umount_test_dev
convert_test_do_convert "$features" "$nodesize"
- convert_test_post_check "$CHECKSUMTMP"
+ convert_test_post_check "$CHECKSUMTMP" "$EXT_PERMTMP" "$EXT_ACLTMP"
rm $CHECKSUMTMP
+ rm $EXT_PERMTMP
+ rm $EXT_ACLTMP
convert_test_post_rollback
}
diff --git a/tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.img b/tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.img
new file mode 100644
index 00000000..345ef419
--- /dev/null
+++ b/tests/fsck-tests/021-partially-dropped-snapshot-case/dropped-snapshot.img
Binary files differ
diff --git a/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh b/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh
new file mode 100755
index 00000000..eb8d8849
--- /dev/null
+++ b/tests/fsck-tests/021-partially-dropped-snapshot-case/test.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# confirm whether btrfsck supports to check a partially dropped snapshot
+
+source $TOP/tests/common
+
+check_prereq btrfs
+
+for img in *.img
+do
+ image=$(extract_image $img)
+ run_check_stdout $TOP/btrfs check "$image" 2>&1 |
+ grep -q "Errors found in extent allocation tree or chunk allocation"
+ if [ $? -eq 0 ]; then
+ rm -f "$image"
+ _fail "unexpected error occurred when checking $img"
+ fi
+ rm -f "$image"
+done
diff --git a/tests/fuzz-tests/001-simple-unmounted/test.sh b/tests/fuzz-tests/001-simple-check-unmounted/test.sh
index 98fe7b0c..98fe7b0c 100755
--- a/tests/fuzz-tests/001-simple-unmounted/test.sh
+++ b/tests/fuzz-tests/001-simple-check-unmounted/test.sh
diff --git a/tests/fuzz-tests/002-simple-image/test.sh b/tests/fuzz-tests/002-simple-image/test.sh
new file mode 100755
index 00000000..42470ecc
--- /dev/null
+++ b/tests/fuzz-tests/002-simple-image/test.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# iterate over all fuzzed images and run 'btrfs-image'
+
+source $TOP/tests/common
+
+setup_root_helper
+check_prereq btrfs-image
+
+# redefine the one provided by common
+check_image() {
+ local image
+
+ image=$1
+ truncate -s0 target
+ run_mayfail $TOP/btrfs-image "$image" target
+ truncate -s0 target
+}
+
+check_all_images $TOP/tests/fuzz-tests/images
+
+rm -- target
+
+exit 0
diff --git a/tests/fuzz-tests/003-multi-check-unmounted/test.sh b/tests/fuzz-tests/003-multi-check-unmounted/test.sh
new file mode 100755
index 00000000..9fd7b8aa
--- /dev/null
+++ b/tests/fuzz-tests/003-multi-check-unmounted/test.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# iterate over all fuzzed images and run 'btrfs check', try various options to
+# get more code coverage
+
+source $TOP/tests/common
+
+setup_root_helper
+check_prereq btrfs
+
+# redefine the one provided by common
+check_image() {
+ local image
+
+ image=$1
+ run_mayfail $TOP/btrfs check -s 1 "$image"
+ run_mayfail $TOP/btrfs check --init-csum-tree "$image"
+ run_mayfail $TOP/btrfs check --init-extent-tree "$image"
+ run_mayfail $TOP/btrfs check --check-data-csum "$image"
+ run_mayfail $TOP/btrfs check --subvol-extents "$image"
+ run_mayfail $TOP/btrfs check --repair "$image"
+}
+
+check_all_images $TOP/tests/fuzz-tests/images
+
+exit 0
diff --git a/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.txt b/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.txt
new file mode 100644
index 00000000..4971f13e
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.txt
@@ -0,0 +1,5 @@
+URL: https://bugzilla.kernel.org/show_bug.cgi?id=155151
+Lukas Lueg 2016-08-27 20:19:24 UTC
+
+More news from the fuzzer. The attached image causes btrfsck to enter what
+seems to be an endless loop; using btrfs-progs v4.7-42-g56e9586.
diff --git a/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xz b/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xz
new file mode 100644
index 00000000..377b4d80
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155151-bad-block-group-offset.raw.xz
Binary files differ
diff --git a/tests/fuzz-tests/images/bko-155181-bad-backref.raw.txt b/tests/fuzz-tests/images/bko-155181-bad-backref.raw.txt
new file mode 100644
index 00000000..440641e9
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155181-bad-backref.raw.txt
@@ -0,0 +1,22 @@
+ULR: https://bugzilla.kernel.org/show_bug.cgi?id=155181
+Lukas Lueg 2016-08-28 10:52:32 UTC
+
+More news from the fuzzer. The attached image causes btrfsck to reach abort()
+in in cmds-check.c:add_tree_backref(); using btrfs-progs v4.7-42-g56e9586.
+
+[Thread debugging using libthread_db enabled]
+Using host libthread_db library "/lib64/libthread_db.so.1".
+Checking filesystem on crash2.bin
+UUID: 5cb33553-6f6d-4ce8-83fd-20af5a2f8181
+
+Program received signal SIGABRT, Aborted.
+0x00007ffff6fae6f5 in raise () from /lib64/libc.so.6
+#0 0x00007ffff6fae6f5 in raise () from /lib64/libc.so.6
+#1 0x00007ffff6fb02fa in abort () from /lib64/libc.so.6
+#2 0x000000000041fbe1 in add_tree_backref (extent_cache=extent_cache@entry=0x7fffffffdd20, bytenr=bytenr@entry=131200, parent=parent@entry=0, root=3, found_ref=found_ref@entry=0) at cmds-check.c:4869
+#3 0x0000000000423538 in process_extent_item (root=root@entry=0x6b2cf0, extent_cache=extent_cache@entry=0x7fffffffdd20, eb=eb@entry=0x6af7c0, slot=slot@entry=1) at cmds-check.c:5452
+#4 0x000000000042a605 in run_next_block (root=root@entry=0x6b2cf0, bits=bits@entry=0x6b4ff0, bits_nr=bits_nr@entry=1024, last=last@entry=0x7fffffffd878, pending=pending@entry=0x7fffffffdd00, seen=seen@entry=0x7fffffffdd10, reada=0x7fffffffdcf0, nodes=0x7fffffffdce0, extent_cache=0x7fffffffdd20, chunk_cache=0x7fffffffdd80, dev_cache=0x7fffffffdd90, block_group_cache=0x7fffffffdd60, dev_extent_cache=0x7fffffffdd30, ri=0x6b9000) at cmds-check.c:6280
+#5 0x000000000042afb6 in deal_root_from_list (list=list@entry=0x7fffffffda10, root=root@entry=0x6b2cf0, bits=bits@entry=0x6b4ff0, bits_nr=bits_nr@entry=1024, pending=pending@entry=0x7fffffffdd00, seen=seen@entry=0x7fffffffdd10, reada=0x7fffffffdcf0, nodes=0x7fffffffdce0, extent_cache=0x7fffffffdd20, chunk_cache=0x7fffffffdd80, dev_cache=0x7fffffffdd90, block_group_cache=0x7fffffffdd60, dev_extent_cache=0x7fffffffdd30) at cmds-check.c:8338
+#6 0x000000000042bb15 in check_chunks_and_extents (root=root@entry=0x6b2cf0) at cmds-check.c:8505
+#7 0x000000000042e3cb in cmd_check (argc=<optimized out>, argv=<optimized out>) at cmds-check.c:11430
+#8 0x000000000040a416 in main (argc=2, argv=0x7fffffffe218) at btrfs.c:243
diff --git a/tests/fuzz-tests/images/bko-155181-bad-backref.raw.xz b/tests/fuzz-tests/images/bko-155181-bad-backref.raw.xz
new file mode 100644
index 00000000..ff5fe859
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155181-bad-backref.raw.xz
Binary files differ
diff --git a/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.txt b/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.txt
new file mode 100644
index 00000000..e28d73fc
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.txt
@@ -0,0 +1,25 @@
+URL: https://bugzilla.kernel.org/show_bug.cgi?id=155621
+Lukas Lueg 2016-08-30 16:07:36 UTC
+
+More news from the fuzzer. The attached image causes btrfsck to enter what
+seems to be an endless loop; using btrfs-progs v4.7-42-g56e9586.
+
+Starting program: /home/lukas/dev/btrfsfuzz/bin/bin/btrfsck hang17.img
+[Thread debugging using libthread_db enabled]
+Using host libthread_db library "/lib64/libthread_db.so.1".
+
+Program received signal SIGINT, Interrupt.
+__find_space_info (info=info@entry=0x6ab3a0, flags=0, flags@entry=8589934592) at extent-tree.c:1796
+1796 list_for_each_entry(found, &info->space_info, list) {
+#0 __find_space_info (info=info@entry=0x6ab3a0, flags=0, flags@entry=8589934592) at extent-tree.c:1796
+#1 0x000000000044c66d in update_space_info (info=info@entry=0x6ab3a0, flags=8589934592, total_bytes=total_bytes@entry=0, bytes_used=17592186044416, space_info=space_info@entry=0x7fffffffdbd8)
+ at extent-tree.c:1835
+#2 0x0000000000451622 in btrfs_read_block_groups (root=0x6ab850) at extent-tree.c:3278
+#3 0x000000000044b157 in btrfs_setup_all_roots (fs_info=fs_info@entry=0x6ab3a0, root_tree_bytenr=<optimized out>, root_tree_bytenr@entry=0, flags=flags@entry=64) at disk-io.c:1055
+#4 0x000000000044b484 in __open_ctree_fd (fp=fp@entry=3, path=path@entry=0x7fffffffe4eb "hang17.img", sb_bytenr=65536, sb_bytenr@entry=0, root_tree_bytenr=root_tree_bytenr@entry=0,
+ chunk_root_bytenr=chunk_root_bytenr@entry=0, flags=flags@entry=64) at disk-io.c:1317
+#5 0x000000000044b611 in open_ctree_fs_info (filename=0x7fffffffe4eb "hang17.img", sb_bytenr=sb_bytenr@entry=0, root_tree_bytenr=root_tree_bytenr@entry=0, chunk_root_bytenr=chunk_root_bytenr@entry=0,
+ flags=64) at disk-io.c:1363
+#6 0x000000000042deca in cmd_check (argc=<optimized out>, argv=0x7fffffffe218) at cmds-check.c:11320
+#7 0x000000000040a416 in main (argc=2, argv=0x7fffffffe218) at btrfs.c:243
+quit
diff --git a/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xz b/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xz
new file mode 100644
index 00000000..2456780d
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.xz
Binary files differ
diff --git a/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.txt b/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.txt
new file mode 100644
index 00000000..c8279633
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.txt
@@ -0,0 +1,62 @@
+URL: https://bugzilla.kernel.org/show_bug.cgi?id=156471
+Lukas Lueg 2016-09-09 18:58:27 UTC
+
+More news from the fuzzer and (up to now) the only news from UBSAN using
+btrfs-progs v4.7-42-g56e9586. The attached image causes btrfsck to trigger
+undefined behavior by dereferencing a ptr to a long unsigned int that was cast
+from an uchar with no alignment guarantees.
+
+UBSAN complains:
+crc32c.c:75:19: runtime error: load of misaligned address 0x000001b3736c for
+type 'long unsigned int', which requires 8 byte alignment
+
+I've attached an image and a log, the behavior is triggered all the time and
+unspecific, though.
+
+AFAIC the problem is that *ptmp is cast from *data. This may actually not cause
+the CPU to fault due to how *data is de-facto aligned by it's callers. The code
+may still cause nose demons as the pure act of having *ptmp is undefined
+behavior.
+
+crc32c.c:75:19: runtime error: load of misaligned address 0x000001b3736c for type 'long unsigned int', which requires 8 byte alignment
+0x000001b3736c: note: pointer points here
+ 00 00 00 00 b7 0e 65 6c 64 61 40 4b a5 0d 0f ba 33 0c 75 27 00 00 02 00 00 00 00 00 01 00 00 00
+ ^
+ #0 0x4f4308 in crc32c_intel /home/lukas/dev/btrfsfuzz/src-ubsan/crc32c.c:75
+ #1 0x4f43f3 in crc32c_le /home/lukas/dev/btrfsfuzz/src-ubsan/crc32c.c:221
+ #2 0x486c39 in __csum_tree_block_size /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:139
+ #3 0x486c39 in csum_tree_block_size /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:159
+ #4 0x486d48 in csum_tree_block_fs_info /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:174
+ #5 0x48ba29 in read_tree_block_fs_info /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:348
+ #6 0x48d48d in read_tree_block /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.h:112
+ #7 0x48d48d in btrfs_setup_chunk_tree_and_device_map /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:1210
+ #8 0x48d95b in __open_ctree_fd /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:1322
+ #9 0x48dd80 in open_ctree_fs_info /home/lukas/dev/btrfsfuzz/src-ubsan/disk-io.c:1381
+ #10 0x45011a in cmd_check /home/lukas/dev/btrfsfuzz/src-ubsan/cmds-check.c:11449
+ #11 0x40a799 in main /home/lukas/dev/btrfsfuzz/src-ubsan/btrfs.c:243
+ #12 0x7fdf11c96730 in __libc_start_main (/lib64/libc.so.6+0x20730)
+ #13 0x40a1e8 in _start (/home/lukas/dev/btrfsfuzz/bin-ubsan/bin/btrfs+0x40a1e8)
+
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+parent transid verify failed on 4227072 wanted 3472328296227680304 found 4
+Ignoring transid failure
+checking extents
+Checking filesystem on ubsan_logs/id:000990,src:000816,op:flip1,pos:3845.img
+UUID: b70e656c-6461-404b-a50d-0fba330c7527
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+Invalid key type(ROOT_ITEM) found in root(3472328296227680304)
+ignoring invalid key
+Invalid key type(ROOT_ITEM) found in root(3472328296227680304)
+ignoring invalid key
+Invalid key type(ROOT_ITEM) found in root(3472328296227680304)
+ignoring invalid key
+Invalid key type(ROOT_ITEM) found in root(3472328296227680304)
+ignoring invalid key
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
+bad block 4202496
+Errors found in extent allocation tree or chunk allocation
+key (3472328296227680304 INODE_EXTREF 3472328296227680304)slot end outside of leaf 12360 > 3995
diff --git a/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz b/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz
new file mode 100644
index 00000000..ee5778a5
--- /dev/null
+++ b/tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz
Binary files differ
diff --git a/utils.c b/utils.c
index cec7c738..45fde2e9 100644
--- a/utils.c
+++ b/utils.c
@@ -250,16 +250,10 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
struct btrfs_super_block *super = (struct btrfs_super_block *)super_buf;
int ret;
- /*
- * We rely on cfg->chunk_uuid and cfg->fs_uuid to pass uuid
- * for other functions.
- * Caller must allocate space for them
- */
- BUG_ON(!cfg->chunk_uuid || !cfg->fs_uuid);
memset(super_buf, 0, BTRFS_SUPER_INFO_SIZE);
cfg->num_bytes = round_down(cfg->num_bytes, cfg->sectorsize);
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super->fsid) != 0) {
error("cound not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;
@@ -320,8 +314,6 @@ static int setup_temp_extent_buffer(struct extent_buffer *buf,
unsigned char chunk_uuid[BTRFS_UUID_SIZE];
int ret;
- /* We rely on cfg->fs_uuid and chunk_uuid to fsid and chunk uuid */
- BUG_ON(!cfg->fs_uuid || !cfg->chunk_uuid);
ret = uuid_parse(cfg->fs_uuid, fsid);
if (ret)
return -EINVAL;
@@ -1049,7 +1041,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg,
memset(&super, 0, sizeof(super));
num_bytes = (cfg->num_bytes / cfg->sectorsize) * cfg->sectorsize;
- if (cfg->fs_uuid && *cfg->fs_uuid) {
+ if (*cfg->fs_uuid) {
if (uuid_parse(cfg->fs_uuid, super.fsid) != 0) {
error("cannot not parse UUID: %s", cfg->fs_uuid);
ret = -EINVAL;
@@ -3280,6 +3272,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
u64 dev_cnt, int mixed, int ssd)
{
u64 allowed = 0;
+ u64 profile = metadata_profile | data_profile;
switch (dev_cnt) {
default:
@@ -3294,8 +3287,7 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
allowed |= BTRFS_BLOCK_GROUP_DUP;
}
- if (dev_cnt > 1 &&
- ((metadata_profile | data_profile) & BTRFS_BLOCK_GROUP_DUP)) {
+ if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {
warning("DUP is not recommended on filesystem with multiple devices");
}
if (metadata_profile & ~allowed) {
@@ -3315,6 +3307,12 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
return 1;
}
+ if (dev_cnt == 3 && profile & BTRFS_BLOCK_GROUP_RAID6) {
+ warning("RAID6 is not recommended on filesystem with 3 devices only");
+ }
+ if (dev_cnt == 2 && profile & BTRFS_BLOCK_GROUP_RAID5) {
+ warning("RAID5 is not recommended on filesystem with 2 devices only");
+ }
warning_on(!mixed && (data_profile & BTRFS_BLOCK_GROUP_DUP) && ssd,
"DUP may not actually lead to 2 copies on the device, see manual page");
diff --git a/utils.h b/utils.h
index da23bfcc..f4e11bf3 100644
--- a/utils.h
+++ b/utils.h
@@ -112,8 +112,8 @@ void btrfs_parse_features_to_string(char *buf, u64 flags);
struct btrfs_mkfs_config {
char *label;
- char *fs_uuid;
- char *chunk_uuid;
+ char fs_uuid[BTRFS_UUID_UNPARSED_SIZE];
+ char chunk_uuid[BTRFS_UUID_UNPARSED_SIZE];
u64 blocks[8];
u64 num_bytes;
u32 nodesize;
diff --git a/version.sh b/version.sh
index caf5dddc..5a99acfa 100755
--- a/version.sh
+++ b/version.sh
@@ -6,7 +6,7 @@
# Copyright 2008, Oracle
# Released under the GNU GPLv2
-v="v4.7.2"
+v="v4.7.3"
opt=$1