At least 2 user from mail list reported btrfsck reported false alert of
"bad metadata [XXXX,YYYY) crossing stripe boundary".
While the reported number are all inside the same 64K boundary.
After some check, all the false alert have the same bytenr feature,
which can be divided by stripe size (64K).
The result seems to be initial 'max_size' can be 0, causing 'start' +
'max_size' - 1, to cross the stripe boundary.
Fix it by always update extent_record->cross_stripe when the
extent_record is updated, to avoid temporary false alert to be reported.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
To accept DUP on multidev fs, in addition to the following
commit, we need to mark DUP as an allowed data/metadata
profile.
commit 42f1279bf8e9 ("btrfs-progs: mkfs: allow DUP on multidev fs, only warn")
* actual result
=============================================
# ./mkfs.btrfs -f -m DUP -d DUP /dev/sdb1 /dev/sdb2
btrfs-progs v4.5-24-ga35b7e6
See http://btrfs.wiki.kernel.org for more information.
WARNING: DUP is not recommended on filesystem with multiple devices
ERROR: unable to create FS with metadata profile DUP (have 2 devices but 1 devices are required)
=============================================
* expected result
=============================================
# ./mkfs.btrfs -f -m dup -d dup /dev/sdb1 /dev/sdb2
WARNING: DUP is not recommended on filesystem with multiple devices
btrfs-progs v4.5-25-g1a10a3c
See http://btrfs.wiki.kernel.org for more information.
Label: (null)
UUID: 010d72ff-c87c-4516-8916-5e635719d110
Node size: 16384
Sector size: 4096
Filesystem size: 28.87GiB
Block group profiles:
Data: DUP 1.01GiB
Metadata: DUP 1.01GiB
System: DUP 12.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Number of devices: 2
Devices:
ID SIZE PATH
1 953.00MiB /dev/sdb1
2 27.94GiB /dev/sdb2
==================================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
There's a mix of opencoded strncpy + null termination, strncpy, memcppy
without termination etc. Unify them and use the helper.
Resolves-coverity-id: 1357105
Signed-off-by: David Sterba <dsterba@suse.com>
The DUP profile can work on multiple filesystems, the limitation is
rather artificial. Let the user make the decision and print a warning.
Signed-off-by: David Sterba <dsterba@suse.com>
$ make clean
$ make btrfs-debug-tree
will fail because the dependency from $(btrfs_debug_tree_objects) is
missing. The variable standalone_deps magically collects all the deps
and will build them in advance. The simple fix to use the existing
substitution based on $@ does not work for pattern rules, as Noah found
out.
Reported-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
[ renamed from subvol_minus_mnt to subvol_strip_mountpoint ]
Signed-off-by: David Sterba <dsterba@suse.com>
get_subvol_info() is useful as we are adding more features around
subvolume. This function was inline with the function
cmd_subvol_show().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
The function test_issubvolume() provides the same check, and
has better logic.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
When `btrfs filesystem label /foo bar` command is invoked, it will pass
the buffer allocated in the argv array directly to set_label_mounted()
and then to the BTRFS_IOC_SET_FSLABEL ioctl.
However, the kernel code handling the ioctl will always try to copy
BTRFS_LABEL_SIZE bytes[1] from the userland pointer. Under certain
conditions and when the label is small enough, the command will fail
with:
[root@localhost /]# btrfs filesystem label /mnt f
ERROR: unable to set label Bad address
Fix this by making sure we pass a BTRFS_LABEL_SIZE sized buffer to the
ioctl containing the desired label.
[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/btrfs/ioctl.c?id=refs/tags/v4.5#n5231
Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Currently, btrfs fi du uses open_file_or_dir(), which tries to open
it's argument with O_RDWR. Because of POSIX semantics, this fails for
non-root users when the file is read-only or is an executable that
is being run currently, or for all users (including root) when the
filesystem is read-only. This results in a somewhat confusing 'Unknown
error -1' message when trying to check such files. Switch to using
open_file_or_dir3() with O_RDONLY passed in the flags, as this avoids
the limitations listed above, and we have no need to write to the files
anyway (and thus shouldn't be opening them writable).
Signed-off-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
commit b5e7979 "btrfs-progs: build: extend per-binary objects" allows
the standalone utilities to link against object files shared with the
main binary. However, the btrfs-*.static targets need to be adjusted
to build against the static versions of the common files.
Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Currently, open_ctree_fs_info will open whatever path you pass it and try
to interpret it as a BTRFS filesystem. While this is not nessecarily
dangerous (except possibly if done on a character device), it does
result in some rather cryptic and non-sensical error messages when
trying to run certain commands in ways they weren't intended to be run.
Add a check using stat(2) to verify that the path we've been passed is
in fact a regular file or a block device, or a symlink pointing to a
regular file or block device.
This causes the following commands to provide a helpful error message
when run on a FIFO, directory, character device, or socket:
* btrfs check
* btrfs restore
* btrfs-image
* btrfs-find-root
* btrfs inspect-internal dump-tree
stat(2) is used instead of lstat(2), as stat(2) follows symlinks just
like open(2) does, which means we check the same inode that open(2)
opens, and thus don't need special handling for symlinks.
Signed-off-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
"qgroup assign" is considered as working without any options
from the following commit.
commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")
However, we can pass options to this command.
* actual result
==================================================
# ./btrfs qgroup assign --rescan 0/260 1/261 /btrfs
btrfs qgroup assign: unrecognized option '--rescan'
usage: btrfs qgroup assign [options] <src> <dst> <path>
Assign SRC as the child qgroup of DST
--rescan schedule qutoa rescan if needed
--no-rescan
==================================================
* expected result
==================================================
# ./btrfs qgroup assign --rescan 0/260 1/261 /btrfs
#
==================================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
"inspect-internal subvolid-resolve" doesn't work from the following commit.
commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")
It's because 1st argument, subvolid, is also used for the pathname of
filesystem. 2nd argument should be used for this purpose instead.
* actual result
==================================================
# ./btrfs inspect-internal subvolid-resolve 260 /btrfs
ERROR: cannot access '260': No such file or directory
==================================================
* expected result
==================================================
# btrfs inspect-internal subvolid-resolve 260 /btrfs
snap
==================================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
"sub get-default" does't work since the following commit.
commit 176aeca9a148 ("btrfs-progs: add getopt stubs where needed")
* actual result
==================================================
# ./btrfs sub get-default /btrfs
btrfs subvolume get-default: too few arguments
usage: btrfs subvolume get-default <path>
Get the default subvolume of a filesystem
==================================================
* expected result
==================================================
# btrfs sub get-default /btrfs
ID 5 (FS_TREE)
==================================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Test for "btrfs-progs: subvol sync: fix memory corruption, undersized
array", a lot of deleted subvolumes in the 'subvol sync' will not fit
into the array, should result in a glibc report.
Signed-off-by: David Sterba <dsterba@suse.com>
The subvol sync command crashed randomly at the end with
*** glibc detected *** btrfs: double free or corruption (out): 0x00000000006ab040 ***
This is caused by running out of the ids array in case there are more
than 128 subvolumes. The array is increased in steps but does not
account the size of the item, so there was room for 1024 / 8 = 128
subvolume ids.
Fixes: c9f885ec89 ("btrfs-progs: subvol: let sync check only current deletions")
Signed-off-by: David Sterba <dsterba@suse.com>
This aims to decide whether a balance can reduce the number of
data block groups and if it is, this shows the '-dvrange' block
group's objectid.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>