summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* Btrfs-progs: allow --init-extent-tree to work when extent tree is borkedJosef Bacik2014-01-31
| | | | | | | | | | | Unfortunately you can't run --init-extent-tree if you can't actually read the extent root. Fix this by allowing partial starts with no extent root and then have fsck only check to see if the extent root is uptodate _after_ the check to see if we are init'ing the extent tree. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: make filesystem show by label workAnand Jain2014-01-31
| | | | | | | | | | with design revamp around filesystem show the fsid filter by label wasn't planned. but apparently that seemed to be necessary. this patch will fix it. 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: remove cmds-chunk.cDavid Sterba2014-01-31
| | | | | | | | | | Commit "btrfs-progs: separate command and implementation of chunk-recover code" moved contents of this file to chunk-recover.c but failed to remove the file cmds-chunk.c Reported-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 btrfsck improper prompt on dropping snapshotsGui Hecheng2014-01-31
| | | | | | | | | | | | Exec btrfsck on btrfs with snapshots that are under a dropping progress will cause prompt on "ref mismatch". However we do not want this kind of prompt, since an remount operation will continue the dropping progress. Here the prompt 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>
* Update the versionChris Mason2013-11-25
| | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Add -fno-strict-aliasingChris Mason2013-11-22
| | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs filesystem show: skip duplicate fsidsChris Mason2013-11-18
| | | | | | | | | If a given filesystem is mounted more than once, btrfs fi show will print dups. This adds a quick and dirty hash table of fsids it has already printed and makes sure we don't print any fsid more than once. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: for mixed group check opt before default raid profile is enforcedAnand Jain2013-11-15
| | | | | | | | | | | | This fixes the regression introduced with the patch btrfs-progs: avoid write to the disk before sure to create fs what happened with this patch is it missed the check to see if the user has the option set before pushing the defaults. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mkfs: enable extended refs by defaultDavid Sterba2013-11-14
| | | | | | | | | | | The feature has been introduced in kernel 3.7 and enabling it by default is desired. All features enabled by default are marked as such in 'mkfs.btrfs -O list-all' output. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: man: add rescue super-recover bitsDavid Sterba2013-11-14
| | | | | Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mkfs: extend -O syntax to disable featuresDavid Sterba2013-11-14
| | | | | | | | A way of disabling features that are on by default in case it's not wanted, eg. due to lack of support in the used kernel. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: remove extra uuid-tree.o in objectsEmil Karlson2013-11-11
| | | | | | | This fixes static compile target of btrfs-progs. Signed-off-by: Emil Karlson <jekarlson@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* mkfs: change default metadata blocksize to 16KBChris Mason2013-11-08
| | | | | | | | | | | | | | | | 16KB is faster and leads to less metadata fragmentation in almost all workloads. It does slightly increase lock contention on the root nodes in some workloads, but that is best dealt with by adding more subvolumes (for now). This uses 16KB or the page size, whichever is bigger. If you're doing a mixed block group mkfs, it uses the sectorsize instead. Since the kernel refuses to mount a mixed block group FS where the metadata leaf size doesn't match the data sectorsize, this also adds a similar check during mkfs. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: annotate fallthroughs in parse_limitEric Sandeen2013-11-07
| | | | | | | | | We intentionally fall through these case statements; just annotate it to be clear. Resolves-Coverity-CID: 1054884 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: annotate fallthroughs in parse_sizeEric Sandeen2013-11-07
| | | | | | | | | We intentionally fall through these case statements; just annotate it to be clear. Resolves-Coverity-CID: 1054887 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: check for fstat failure in cmd_defragEric Sandeen2013-11-07
| | | | | | Resolves-Coverity-CID: 1125924 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: check btrfs_scan_one_device in btrfs_scan_lblkid()Eric Sandeen2013-11-07
| | | | | | | | | | | | | Even if it's "definitely" btrfs at this point, btrfs_scan_one_device could fail for other reasons. Check the return value, warn if it fails, and skip the device register. Resolves-Coverity-CID: 1125925 Signed-off-by: Eric Sandeen <sandeen@redhat.com> reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: remove more dead code from check_extent_refsEric Sandeen2013-11-07
| | | | | | | | | | e0a04278 removed a bunch of dead code but left one little bit; reinit is always 0, so btrfs_read_block_groups is never called from here. Resolves-Coverity-CID: 1125926 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: pass positive errno to strerror in cmd_df()Eric Sandeen2013-11-07
| | | | | | | | | get_df returns a negative error number, but then we pass it to strerror, which wants a positive value... Resolves-Coverity-CID: 1125929 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: Check for open failure in btrfs_scan_lblkid()Eric Sandeen2013-11-07
| | | | | | | | | open can fail, of course. Resolves-Coverity-CID: 1125925 Resolves-Coverity-CID: 1125930 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: btrfs_scan_kernel(): fd==0 is not an errorEric Sandeen2013-11-07
| | | | | | | | | | The error return from open is -1, so test that, not 0, for success/failure. Resolves-Coverity-CID: 1125931 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: don't leak buffer on add_file_items() errorEric Sandeen2013-11-07
| | | | | | | | | add_file_items() leaked "buffer" on this error return. Free it first. Resolves-Coverity-CID: 1125937 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix leak of "buf" in make_btrfs() error pathsEric Sandeen2013-11-07
| | | | | | | | | | If any pwrite failed we leaked the allocated "buf" on return from the function. "goto out" takes care of those paths. Resolves-Coverity-CID: 1125938 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: don't leak fd in test_dev_for_mkfs() error pathsEric Sandeen2013-11-07
| | | | | | | | | Close fd before we return on error paths. Resolves-Coverity-CID: 1125939 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix test for return of realpath in find_mount_root()Eric Sandeen2013-11-07
| | | | | | | | | | find_mount_root() tries to test for realpath() failure, but tests the wrong value. Fix it. Resolves-Coverity-CID: 1125940 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use strncpy in btrfs_scan_lblkid()Eric Sandeen2013-11-07
| | | | | | | | | Use strncpy(... ,PATH_MAX) to be sure we don't overflow the path[PATH_MAX] array. Resolves-Coverity-CID: 1125941 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix error returns in get_df()Eric Sandeen2013-11-07
| | | | | | | | | | | | | | get_df returns -ERRNO, or maybe (+)errno, or even 0 in the case where we inexplicably got 0 total_spaces from the BTRFS_IOC_SPACE_INFO. Consistently return a negative error number, and return -ENOENT rather than 0 for total_spaces == 0, so that the caller will know that **sargs_ret hasn't been set up. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix potential double-frees in cmd_subvol_delete()Eric Sandeen2013-11-07
| | | | | | | | | | | | | If we "goto again" in cmd_subvol_delete(), and error out to out: before re-allocating the dupdname and dupvname pointers, we'll double-free them. Set them to NULL after freeing to avoid this. Resolves-Coverity-CID: 1125944 Resolves-Coverity-CID: 1125945 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: set return value to 0 if subvolume get-default successfullyEryu Guan2013-11-07
| | | | | | | | | | cmd_subvol_get_default() returns 1 even if finds default subvolume successfully. Set the correct return value. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: rework open_ctree to take flags, add a new one V2Josef Bacik2013-11-07
| | | | | | | | | | | So I needed to add a flag to not try to read block groups when doing --init-extent-tree since we could hang there, but that meant adding a whole other 0/1 type flag to open_ctree_fs_info. So instead I've converted it all over to using a flags setting and added the flag that I needed. This has been tested with xfstests and make test. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: add -b to btrfsck to look at backup rootsJosef Bacik2013-11-07
| | | | | | | | | | In some cases the tree root is so hosed we can't get anything useful out of it. So add the -b option to btrfsck to make us look for the most recent backup tree root to use for repair. Then we can hopefully get ourselves into a working state. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: add filter for deleted but uncleanded subvolumesDavid Sterba2013-10-24
| | | | | | | | | | | | | New option to subvolume list that acts as a global filter and applies the other filters to either live subvolumes or the uncleaned ones. The path to the deleted subvolumes is lost at the deletion time, sample output looks like: ID 259 gen 7 top level 0 path <FS_TREE>/DELETED Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: just return -ENOENT if we don't find the root itemJosef Bacik2013-10-24
| | | | | | | | We were bug_on(slot == 0), but that's just obnoxious, return -ENOENT so we can handle the situation properly. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: make pretty_sizes take u64 instead of a doubleJosef Bacik2013-10-24
| | | | | | | | | | | | | This got changed to a double but all the callers still use a u64, which causes us to segfault sometimes because of some weird C voodoo that I had to have explained to me. Apparently because we're using a double the compiler will use the floating point registers to hold our argument which ends up not being aligned properly if you don't actually give it a double so it will cause problems for other things, in our case it was screwing up str_bytes so it was larger than the actual size of the str. This patch fixes the segfault. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: filesystem show of specified mounted disk should workAnand Jain2013-10-24
| | | | | | | | | | Originally, thinking was user will use mount point if the disk is mounted. But thats not really true, actually user don't (or shouldn't) care to check if disk mounted, so whether disk is mounted/unmounted when disk path is specified it should work. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: make get_btrfs_mount callableAnand Jain2013-10-24
| | | | | | | | | get_btrfs_mount is reusable function but it is printing errors, this removes it. Here the parent function of open_path_or_dev_mnt does print error msg on error. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: make sure we return an error when we can't add a deviceJosef Bacik2013-10-24
| | | | | | | | | | I noticed xfstests was failing in a weird way but it was because our device add was failing but not actually returning an error so we were failing further down the test. Fix this by making sure we return an error if we fail the mkfs tests. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* mkfs: fix mkfs -r to properly allocate spaceChris Mason2013-10-16
| | | | | | | | | | | | | | | | mkfs -r wasn't creating chunks properly, making it very difficult to allocate space for anything except tiny filesystems. This changes it around to use more of the generic infrastructure, and to do actual logical->physical block number translation. It also allocates space to the files in smaller extents (max 1MB), which keeps the allocator from trying to allocate an extent bigger than a single chunk. It doesn't quite support multi-device mkfs -r yet, but is much closer. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use the marco BTRFS_UPDATE_KERNEL where neededAnand Jain2013-10-16
| | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: device scan use BTRFS_SCAN_LBLKID by defaultAnand Jain2013-10-16
| | | | | | | | | | | | | | | | | with this patch, BTRFS_SCAN_LBLKID (which leverages lblkid to look for btrfs disks) would be the default scan method to look for the btrfs disks. And thus the output as seen in the latest btrfs fi show and btrfs fi show -m for the mounted disks will have the consistent disks path. (it was inconsistent (across disks) because btrfs dev scan provided a different path from the mount command eg. below) devid 1 size 1.98GiB used 435.00MiB path /dev/mapper/mpatha devid 2 size 2.00GiB used 415.00MiB path /dev/dm-1 Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use BTRFS_SCAN_LBLKID as default scan in filesystem showAnand Jain2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs progs has to scan for the btrfs disks for two main reasons, one to register them with the btrfs kernel (under btrfs dev scan) 2nd to report btrfs disks to the user (under btrfs fi show) (there few more minor reasons like check_mounted etc..). To facilitate the scan, in total we have the following methods to scan for the btrfs BTRFS_SCAN_PROC which uses the /proc/partitions to look for the disks, when scanning it does it twice first would look for non dm- paths and in the 2nd scan it would pick only dm- paths. BTRFS_SCAN_DEV which scans all the block dev under /dev as they appear during scanning. BTRFS_SCAN_LBLKID this uses the library functions provided by the lblkid to get only disks which contains the btrfs SB. The better method to use would be BTRFS_SCAN_LBLKID for the obvious reasons we don't have to reinvent that feature with in btrfs-progs. For the btrfs fi show - This patch will.. - make BTRFS_SCAN_LBLKID as the default scan option (BTRFS_SCAN_DEV is accessible under the option --all-devices and BTRFS_SCAN_PROC won't be used by btrfs fi show any more) Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use kernel for mounted disk for showAnand Jain2013-10-16
| | | | | | | | | | | | | As of now btrfs filesystem show reads directly from disks. So sometimes output can be stale, mainly when user wants to cross verify their operation like, label or device delete or add... etc. so this patch will read from the kernel ioctl if it finds that disk is mounted. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: check return value of realpath(3)Eryu Guan2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I hit a segfault when deleting a subvolume with very long name(>4096), it's because cmd_subvol_delete() calls strdup() and passes NULL as argument, which is returned by realpath(3). I used the following script to reproduce #!/bin/bash mnt=$1 i=1 path=$mnt/subvol_$i # Create very deep subvolumes while btrfs sub create $path;do ((i++)) path="$path/subvol_$i" done last_vol=$(dirname $path) dir=$(dirname $last_vol) vol=$(basename $last_vol) # Try to delete tha last one, this would get segfault pushd $dir btrfs sub delete $vol popd Fix it by checking return value of realpath(3), also fix the one in find_mount_root(). Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: check fopen failure in cmds-sendZach Brown2013-10-16
| | | | | | | | | | Check for fopen() failure. This shows up in static analysis as a possible null pointer derference. Signed-off-by: Zach Brown <zab@redhat.com> Laughed-at-by: Stefan Behrens <sbehrens@giantdisaster.de> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: free leaked roots in calc-sizeZach Brown2013-10-16
| | | | | | | | This was found by static analysis. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: remove unused variablesZach Brown2013-10-16
| | | | | | | | | Presumably people missed these warnings because btrfs-fragments isn't built by default. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: don't overflow colors[] in fragmentsZach Brown2013-10-16
| | | | | | | | | | Stop iteration at the number of elements in the colors[] array when initializing the elements. Rather than a magic number. This was found by static analysis. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: don't deref pipefd[-1]Zach Brown2013-10-16
| | | | | | | | | | commit 4782e8ebdb583dfa3615f7b38dee729d34f62ec1 accidentally replaced [0] with [-1]. Put it back. This was found by static analysis. Signed-off-by: Zach Brown <zab@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: don't leak path in verify_space_cacheZach Brown2013-10-16
| | | | | | | | | This was found by static analysis. Signed-off-by: Zach Brown <zab@redhat.com> Reviewed-by: chandan <chandan@linux.vnet.ibm.com Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: free eb in fixup_chunk_tree_block()Zach Brown2013-10-16
| | | | | | | | This was found by static analysis. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>