summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: include <sys/xattr.h> instead of <attr/xattr.h>Christophe Vu-Brugier2014-03-21
| | | | | | | | | | | The `btrfs` and `mkfs.btrfs` binaries are not linked against libattr so the correct header to include is <sys/xattr.h>. This fixes the build when attr header files are not installed. Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: make sure to save mirror_num only if it is setJosef Bacik2014-03-21
| | | | | | | | | | | If we are cycling through all of the mirrors trying to find the best one we need to make sure we set best_mirror to an actual mirror number and not 0. Otherwise we could end up reading a mirror that wasn't the best and make everybody sad. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: record generation for tree blocks in fsckJosef Bacik2014-03-21
| | | | | | | | | | | | | | When working with a user who had a broken file system I noticed that we were reading a bad copy of a block when the other copy was perfectly fine. This is because we don't keep track of the parent generation for tree blocks, so we just read whichever copy we damned well please with no regards for which is best. This fixes this problem by recording the parent generation of the tree block so we can be sure to read the most correct copy before we check it, which will give us a better chance of fixing really broken filesystems. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Init root_item to avoid gcc 4.8.2 warningQu Wenruo2014-03-21
| | | | | | | | | | | When using gcc 4.8.2, -Wmaybe-uninitialized will report root_item may be used uninitialized. Since root_item_valid variant is used to determine the root_item valid, it's a false alert and to avoid the warning, just init it on allocation. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: use bitfield instead of integer for some variants in fs_infoWang Shilong2014-03-21
| | | | | | Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fix restore of files with compressed extentsFilipe David Borba Manana2014-03-21
| | | | | | | | | | | | | | The code was incorrectly adding the file extent items' data offset to the logical disk address of the extent (bytenr) when the extent is compressed. The offset is relative to the uncompressed data and not to what we store on disk (compressed). Also it attempted to copy ram_bytes to destination, which is incorrect when the data offset field is non-zero, it must use num_bytes instead. A test case for xfstests follows. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Fix bug when scanned for devid which was missing and deletedAnand Jain2014-03-21
| | | | | | | | | | | | | | | | | | | | | | | | get_fs_info() provides the info of the specific device/devid, however when we delete the missing disk the super-block on the disk isn't cleared, and since btrfs-progs makes its decision by reading the disk super block, so it doesn't know about the kernel previous action, And now when we tried to probe kernel for the devid it fails. reproducer: $ mkfs.btrfs -d raid1 -m raid1 /dev/sde /dev/sdf $ modprobe -r btrfs && modprobe btrfs $ mount -o degraded /dev/sde /btrfs $ btrfs dev add /dev/sdd /btrfs $ btrfs dev del missing /btrfs $ btrfs scrub start -B /dev/sdf btrfs: utils.c:1741: get_fs_info: Assertion `!(ndevs == 0)' failed. Aborted (core dumped) Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: latest_devid is not always the probed devidAnand Jain2014-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs-progs picks the latest_dev based on first probed greatest trans-id. However below test case proofs that approach is wrong. $ mkfs.btrfs -d raid1 -m raid1 /dev/sde /dev/sdf $ modprobe -r btrfs && modprobe btrfs $ mount -o degraded /dev/sde /btrfs $ touch /btrfs/testfile && btrfs fi sync /btrfs The above steps will make /dev/sdf not part of the btrfs. and as below when you use /dev/sdf the btrfs dev stat and dev scrub picks up wrong disk $ btrfs dev stat /dev/sdf [/dev/sde].write_io_errs 0 [/dev/sde].read_io_errs 0 [/dev/sde].flush_io_errs 0 [/dev/sde].corruption_errs 0 [/dev/sde].generation_errs 0 $ btrfs scrub start -B /dev/sdf scrub done for 2e99c881-6abd-4f8a-8290-e2f8d0acc575 scrub started at Mon Feb 24 14:45:06 2014 and finished after 0 seconds total bytes scrubbed: 256.00KiB with 0 errors Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: there is devid 0 when replace is runningAnand Jain2014-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as of now, when we replace a disk, it is added to the dev list with devid 0. And we fail to obtain details of devid 0 because we don't query devid 0 at all. reproducer: btrfs rep start /dev/sdb /dev/sdf /btrfs btrfs fi show Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd Total devices 3 FS bytes used 1.94GiB devid 1 size 1.10GiB used 1.10GiB path /dev/sdb devid 2 size 1.10GiB used 1.08GiB path /dev/sdc devid 0 size 0.00 used 0.00 path this patch will make it proper by querying devid 0. btrfs repl start /dev/sdb /dev/sdf /btrfs btrfs fi show /btrfs Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd Total devices 3 FS bytes used 1.94GiB devid 0 size 1.10GiB used 1.10GiB path /dev/sdf devid 1 size 1.10GiB used 1.10GiB path /dev/sdb devid 2 size 1.10GiB used 1.08GiB path /dev/sdc Its fine to query devid 0 when there is no replace activity as well, because we just skip the error ENODEV btrfs fi show /btrfs Label: none uuid: f8fb9819-16c8-47b7-b62f-0ff90f8c56cd Total devices 2 FS bytes used 1.94GiB devid 1 size 1.10GiB used 1.10GiB path /dev/sdf devid 2 size 1.10GiB used 1.08GiB path /dev/sdc Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fsck: fix wrong return value in check_block()Wang Shilong2014-03-21
| | | | | | | | | | | | | | We found btrfsck will output backrefs mismatch while the filesystem is defenitely ok. The problem is that check_block() don't return right value,which makes btrfsck won't walk all tree blocks thus we don't get a consistent filesystem, we will fail to check extent refs etc. Reported-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fsck: avoid overwritting existed space when initting csum treeWang Shilong2014-03-21
| | | | | | | | | | | | | | | | | | | Steps to reproduce: # mkfs.btrfs -f /dev/sda9 # btrfs check /dev/sda9 --init-extent-tree --init-csum-tree # btrfs check /dev/sda9 During reinitting extent tree, we will pin all metadata blocks to avoid overwritting existing metadata space. However, those space will be unpinned after committing transaction. If we try to reinit csum tree after reiniting extent tree, we may overwrite existing space. Fix this problem by making reinit extent tree and csum tree in same transaction. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Copyright string updateHidetoshi Seto2014-03-21
| | | | | | | | Fix corporate name for copyright. Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: mkfs.btrfs man page: update default metadata blocksizeRakesh Pandit2014-03-21
| | | | | | | | | Since commit c652e4ef changes default metadata blocksize, update corresponding options in man page. Signed-off-by: Rakesh Pandit <rakesh@tuxera.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: don't remove BTRFS_BLOCK_GROUP_DUP in chunk typeRakesh Pandit2014-03-21
| | | | | | | | | | | | | | | | | | | | | | | | | | During restoring of image (-r using btrfs-image) we zero out RAID profile in chunk type but forget to save BTRFS_BLOCK_GROUP_DUP if present. This results in some false messages being printed by btrfsck. $ ./mkfs.btrfs /dev/sdb2 -f $ ./btrfs-image /dev/sdb2 btrfs_image_output $ ./btrfs-image -r btrfs_image_output disk-image $ ./btrfsck disk-image Checking filesystem on disk-image UUID: e644be2d-7701-4bd4-8804-7487f560d2a7 checking extents Chunk[256, 228, 20971520]: length(8388608), offset(20971520), type(2) mismatch with block group[20971520, 192, 8388608]: offset(8388608), objectid(20971520), flags(34) Chunk[256, 228, 29360128]: length(1073741824), offset(29360128), type(4) mismatch with block group[29360128, 192, 1073741824]: offset(1073741824), objectid(29360128), flags(36) Block group[20971520, 8388608] (flags = 34) didn't find the relative chunk. Block group[29360128, 1073741824] (flags = 36) didn't find the relative chunk. Even though ./btrfsck on /dev/sdb2 seemed fine. This is due to type mismatch above and type mismatch occured because we zero'ed out BTRFS_BLOCK_GROUP_DUP while handling chunk trees. Signed-off-by: Rakesh Pandit <rakesh@tuxera.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Allow use of get_device_info()Goffredo Baroncelli2014-03-21
| | | | | | | | Allow the use of get_device_info() for different units. Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: fix wrong error msg for exec btrfsck as non-rootGui Hecheng2014-03-21
| | | | | | | | | | | | When exec btrfsck as non-root user on a disk, btrfsck will always warn that "No such file or directory", despite that a directory (e.g. /dev/vboxusb)actually exists. We just have no permission. In this case, return the -errno set by the opendir call in btrfs_scan_one_dir rather than blindly return -ENOENT. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: judge the return value of check_mounted more accuratelyGui Hecheng2014-03-21
| | | | | | | | | | | | | | | For btrfs-convert, btrfstune, btrfs rescue, they report "device busy" when given a device that does not actually exist e.g. # btrfstune -x abcdefg (this device does not exist) $ ...device busy... We deal with this case by add "ret < 0" error check when judging the return value of check_mounted. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: switch to arg_strtou64() part3Wang Shilong2014-03-21
| | | | | | | | | Switch to new helper arg_strtou64(), also check if user assign a valid super copy. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: switch to arg_strtou64() part2Wang Shilong2014-03-21
| | | | | | Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: switch to arg_strtou64() part1Wang Shilong2014-03-21
| | | | | | | | | switch to arg_strtou64 plus some cleanups to remove unnecessary codes. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: new helper to parse string to u64 for btrfsWang Shilong2014-03-21
| | | | | | | | | | | | | | | | | | There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's do everything more gracefully, we introduce a new helper arg_strtou64() which will do all the necessary checks.If we fail to parse string to u64, we will output message and exit directly, this is something like what usage() is doing. It is ok to not return erro to it's caller, because this function should be called when parsing arg (just like usage!) Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: fix fsck leaks on error returnsGui Hecheng2014-03-21
| | | | | | | | | Add close_ctree()s before the "returns" on errors after open_ctree() Also merge the err returns into the "goto + single return" pattern. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: add dry-run option to restore commandJustin Maggard2014-03-21
| | | | | | | | | | | Sometimes it is useful to see what btrfs restore is going to do before provisioning enough external storage to restore onto. Add a dry-run option so we can see what files and paths are found by restore, without actually restoring any data. Signed-off-by: Justin Maggard <jmaggard10@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: cleanup nonsense ret value assignmentGui Hecheng2014-03-21
| | | | | | | | | The "ret" will be soon used to hold the return value of another function, assign -1 to it before is nonsense. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: remove a dead break before usage()Gui Hecheng2014-03-21
| | | | | | | | | The usage() in help.c calls exit(1), so the break behind is nonsense and should be removed. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: use usage() to replace the warning msg on no-arg usageGui Hecheng2014-03-21
| | | | | | | | | To be consistent with the other cmds, replace the warning msg with usage() when send/receive are used without any args. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Remove superfluous BUG_ON check.Mitch Harder2014-03-21
| | | | | | | | | | | The function call that set the ret parameter evaluated in this BUG_ON was removed in a previous commit: 11be10f71e1af5256f221feb9e91300b3e28bbef Btrfs-progs: make fsck fix certain file extent inconsistencies Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Fix check_arg_type() which doesn't use realpath() result.Qu Wenruo2014-03-21
| | | | | | | | | | Fix a problem that does not use the result of realpath(), which caused check_arg_type() can't handle mount point which ends with a final '/'. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Cc: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Preserve process_one_leaf return value.Mitch Harder2014-03-21
| | | | | | | | | | | | | | | | | | | | The return value in process_one_leaf could be over-written while looping over the items in the leaf. This patch will preserve a non-zero return value to the calling function if a non-zero return value is encountered in the loop. The return value of one (1) is consistent with non-zero values that could be returned while processing the leaf. The only caller of this function (walk_down_tree) would ignore the return value anyway. But this patch will correct the behaviour in case future changes intend to utilize the return value. Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: receive: don't output normal message into stderrWang Shilong2014-03-21
| | | | | | | | | Don't output normal messages into stderr, this make xfstests filter output easier. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: move find_mount_root to utils.[ch]Qu Wenruo2014-03-21
| | | | | | | | Move find_mount_root to utils.[ch] for general use. Signed-off-by: Qu Wenruo <quwenruo@cn.fuijitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Change BUG() to use assert.Mitch Harder2014-03-21
| | | | | | | | | Change the definition of BUG() to use assert instead of abort to provide information about the location of the issue. Signed-off-by: Mitch Harder <mitch.harder@sabayonlinux.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Add missing devices check for mounted btrfs.Qu Wenruo2014-03-21
| | | | | | | | | | | | | | In btrfs/003 of xfstest, it will check whether btrfs fi show can find missing devices. But before the patch, btrfs-progs will not check whether device missing if given a mounted btrfs mountpoint/block device. This patch fixes the bug and will pass btrfs/003. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Cc: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* ioctl: add note regarding CLONE_RANGE(len=0) behaviourDavid Disseldorp2014-03-21
| | | | | | | | | | | | A BTRFS_IOC_CLONE_RANGE request with a src_length value of zero has the effect of cloning all data from src_offset through to end-of-file. Document this behaviour in the header file for those who (like me) incorrectly assume that no data is cloned in such a case. Signed-off-by: David Disseldorp <ddiss@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: fix typo in reported errorAnand Jain2014-03-21
| | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: enclose uuid tree compat code with ifdefsDavid Sterba2014-03-21
| | | | | | | | | | | Commit "Btrfs-progs: make send/receive compatible with older kernels" adds code that will become deprecated, let's clearly mark it in the sources. CC: Stefan Behrens <sbehrens@giantdisaster.de> CC: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: return non zero when label is not foundAnand Jain2014-01-31
| | | | | | | | btrfs filesystem show <not-found-label> should return non zero Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: lblkid wouldn't find non mapper path inputAnand Jain2014-01-31
| | | | | | | | | | | | A new test case when disk is unmounted and if the non mapper disk path is given as the argument to the btrfs filesystem show <arg> we still need this to work but lblkid will pull only mapper disks, it won't match. So this will normalize the input to find btrfs by fsid and pass it to the search. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: add support for the compression propertyFilipe David Borba Manana2014-01-31
| | | | | | | | | | | | | | | | | With this property, one can enable compression for individual files without the need to mount the filesystem with the compress or compress-force options, and specify the compression algorithm. When applied against a directory, files created under that directory will inherit the compression property. This requires the corresponding kernel patch, which adds the support for setting and getting properties and implements the compression property. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: add type root to label propertyFilipe David Borba Manana2014-01-31
| | | | | | | | | | | | | | | | | | | | | | So that we can get the label of a mounted filesystem. Before this change: $ btrfs prop get /mnt/btrfs label ERROR: object is not compatible with property $ btrfs prop get /dev/sdb3 label ERROR: dev /dev/sdb3 is mounted, use mount point ERROR: failed to set/get property for object. After this change: $ btrfs prop get /mnt/btrfs label label=foobar Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fix detection of root objects in cmds-property.cFilipe David Borba Manana2014-01-31
| | | | | | | | | | | | | | | | | | | Several fixes: 1) The function check_is_root() returns 0 if the object is root; 2) Don't treat any error from get fsid ioctl as meaning the target is root. Only -ENOTTY means it's a root (parent directory is not a btrfs fs) and a -ENOTDIR means our target object is not a directory, therefore it can be the root; 3) Fix the comparison of the target and target's parent fs ids. If they are different, it means the target is a mount point in a btrfs fs, therefore it's a root, otherwise it isn't. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: introduce btrfs property subgroupAlexander Block2014-01-31
| | | | | | | | | | | | | | | "btrfs filesystem property" is a generic interface to set/get properties on filesystem objects (inodes/subvolumes/filesystems /devs). This patch adds the generic framework for properties and also implements two properties. The first is the read-only property for subvolumes and the second is the label property for devices. Signed-off-by: Alexander Block <ablock84@googlemail.com> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: make send/receive compatible with older kernelsWang Shilong2014-01-31
| | | | | | | | | | | | | | | Some users complaint that with latest btrfs-progs, they will fail to use send/receive. The problem is new tool will try to use uuid tree while it dosen't work on older kernel. Now we first check if we support uuid tree, if not we fall into normal search as previous way.i copy most of codes from Alexander Block's previous codes and did some adjustments to make it work. Signed-off-by: Alexander Block <ablock84@googlemail.com> Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: fix double free when deleting subvolumesWang Shilong2014-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Steps to reproduce: # mkfs.btrfs -f /dev/sda8 # mount /dev/sda8 /mnt # btrfs sub create /mnt/a # touch /mnt/b # btrfs sub create /mnt/c # btrfs sub delete /mnt/* Above steps will trigger following abortion: ERROR: 'b' is not a subvolume *** Error in `btrfs': double free or corruption (out): 0x0000000002116060 *** ======= Backtrace: ========= /lib64/libc.so.6[0x3fa467cef8] /lib64/libc.so.6(closedir+0xd)[0x3fa46b846d] btrfs[0x43e608] btrfs[0x40622f] btrfs[0x403d19] btrfs[0x4062c6] btrfs[0x403f68] We try to fix it by resetting @fd && @dirstream before trying next subvolume deletion. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Fix bus error on sparcIvan Jager2014-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, as of 8cae1840afb3ea44dcc298f32983e577480dfee4 when running btrfs-convert I get a bus error. The problem is that struct btrfs_key has __attribute__ ((__packed__)) so it is not aligned. Then, a pointer to it's objectid field is taken, cast to a void*, then eventually cast back to a u64* and dereferenced. The problem is that the dereferenced u64* is not necessarily aligned (ie, not necessarily a valid u64*), resulting in undefined behavior. This patch adds a local u64 variable which would of course be properly aligned and then uses a pointer to that. I did not modify the call from btrfs_fs_roots_compare_roots as that uses struct btrfs_root which is a regular struct and would thus have it's members correctly aligned to begin with. After patching this I realized Liu Bo had already written a similar patch, but I think mine is cleaner, so I'm sending it anyway. Signed-off-by: Ivan Jager <aij+@mrph.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: fix minor grammar issuesMitchel Humpherys2014-01-31
| | | | | | | | Remove the extraneous `to' from `Can't access to X'. Signed-off-by: Mitchel Humpherys <mitch.special@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: btrfsck operations should be exclusiveAnand Jain2014-01-31
| | | | | | | | | this patch will make btrfsck operations to open disk in exclusive mode, so that mount will fail when btrfsck is running Signed-off-by: Anand Jain <Anand.Jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: check return value of read_tree_block() in ↵Eryu Guan2014-01-31
| | | | | | | | | | | | | | | | | | | check_chunks_and_extents() The following steps could trigger btrfs segfault: mkfs -t btrfs -m raid5 -d raid5 /dev/loop{0..3} losetup -d /dev/loop2 btrfs check /dev/loop0 The reason is that read_tree_block() returns NULL and add_root_to_pending() dereferences it without checking it first. Also replace a BUG_ON with proper error checking. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: sync-up with newly introduced ioctl numberAnand Jain2014-01-31
| | | | | | | | | | for now the manual sync up of new ioctls introduced in the btrfs kernel. For which there wasn't any btrfs-progs patch. however we might have better idea for the long run. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: add support for the no holes incompat flagJosef Bacik2014-01-31
| | | | | | | | | | This adds the flag to ctree.h, adds the feature option to mkfs to turn it on and fixes fsck so it doesn't complain about missing hole extents in files when this flag is set. Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>