Ivan Jager [Fri, 17 Jan 2014 14:00:43 +0000 (15:00 +0100)]
btrfs-progs: Fix bus error on sparc
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>
Mitchel Humpherys [Tue, 14 Jan 2014 21:44:03 +0000 (13:44 -0800)]
btrfs-progs: fix minor grammar issues
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>
Anand Jain [Mon, 13 Jan 2014 13:14:55 +0000 (21:14 +0800)]
btrfs-progs: btrfsck operations should be exclusive
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>
Eryu Guan [Fri, 10 Jan 2014 14:50:02 +0000 (22:50 +0800)]
Btrfs-progs: check return value of read_tree_block() in 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>
Anand Jain [Thu, 19 Dec 2013 04:08:56 +0000 (12:08 +0800)]
btrfs-progs: sync-up with newly introduced ioctl number
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>
Josef Bacik [Tue, 22 Oct 2013 16:22:41 +0000 (12:22 -0400)]
Btrfs-progs: add support for the no holes incompat flag
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>
Pascal VITOUX [Thu, 9 Jan 2014 22:47:14 +0000 (23:47 +0100)]
btrfs-progs: skip non-regular files while defragmenting
Skip non-regular files to avoid ioctl errors while defragmenting.
They are silently ignored in recursive mode but reported as errors when
used as command-line arguments.
Signed-off-by: Pascal VITOUX <vitoux.pascal@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Wang Shilong [Thu, 9 Jan 2014 12:42:12 +0000 (20:42 +0800)]
Btrfs-progs: fix to make list specified directory's subvolumes work
Steps to reproduce:
# mkfs.btrfs -f /dev/sda8
# mount /dev/sda8 /mnt
# mkdir /mnt/subvolumes
# btrfs sub create /mnt/subvolumes/subv1
# btrfs sub create /mnt/subvolumes/subv1/subv1.1
# btrfs sub list -o /mnt/subvolumes/subv1 <----we did not list anything
The problem is that we don't set @top_id right, fix it.
Reported-by: Alex <alex@bpmit.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>
Anand Jain [Fri, 27 Dec 2013 05:56:29 +0000 (13:56 +0800)]
btrfs-progs: test_skip_this_disk() isn't needed anymore
add_seen_fsid() which was introduced lately will eliminate
the mounted disks, so we don't need test_skip_this_disk()
anymore
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>
Anand Jain [Wed, 18 Dec 2013 04:07:55 +0000 (12:07 +0800)]
btrfs-progs: handle error in the btrfs_prepare_device
this patch will handle the strerror reporting of the error instead of
printing errno, and also replaced the BUG_ON with the error handling
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>
Wang Shilong [Wed, 18 Dec 2013 09:56:33 +0000 (17:56 +0800)]
Btrfs-progs: receive: fix the case that we can not find the subvolume
If we change our default subvolume, btrfs receive will fail to find
subvolume. To fix this problem, we have three ideas:
1.make btrfs snapshot ioctl support passing source subvolume's objectid.
2.when we want to using interval subvolume path, we mount it other place
that use subvolume 5 as its default subvolume.
3.tell the user to mount the toplevel subvol by himself and run
receive
We's better use the third approach because first patch will bother kernel
change and the second approach is not very good for power users. So give this
option to users.
Reported-by: Michael Welsh Duggan <mwd@md5i.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Gui Hecheng [Wed, 18 Dec 2013 03:52:45 +0000 (11:52 +0800)]
btrfs-progs: fix btrfstune silence on failure
Originally, btrfstune will fail without any options, like this:
# btrfstune /dev/sdb
An error prompt & usage should show up upon this condition.
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>
David Sterba [Mon, 16 Dec 2013 15:47:10 +0000 (16:47 +0100)]
btrfs-progs: update send help strings and manpage
- send accepts multiple subvolumes
- add missing option -e to man
- minor man formatting fix
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
David Sterba [Thu, 12 Dec 2013 18:11:26 +0000 (19:11 +0100)]
btrfs-progs: add options to set commit mode after subvol delete
Subvolume deletion does not do a full transaction commit. This can lead
to an unexpected result when the system crashes between deletion and
commit, the subvolume directory will appear again. Add options to request
filesystem sync after each deleted subvolume or after the last one.
If the command with --commit option finishes succesfully, the
subvolume(s) deletion status is safely stored on the media.
Userspace approach is more flexible than in-kernel. Related discussions:
http://www.spinics.net/lists/linux-btrfs/msg22088.html
http://www.spinics.net/lists/linux-btrfs/msg27240.html
CC: Alex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Anand Jain [Mon, 16 Dec 2013 12:33:58 +0000 (20:33 +0800)]
btrfs-progs: use stripe_len define here
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>
Anand Jain [Mon, 16 Dec 2013 12:33:57 +0000 (20:33 +0800)]
btrfs-progs: don't replicate the stripe_len defines
a clean up patch, the BTRFS_STRIPE_LEN is been duplicated across
btrfs-progs, the kernel defines it in volume.h so do the same
for progs.
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>
Gui Hecheng [Thu, 12 Dec 2013 10:41:07 +0000 (18:41 +0800)]
btrfs-progs: remove NULL-ptr judge before free for btrfs-progs
free(3) already checks the pointer for NULL, no need to do it
on your own. This patch make the change globally.
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>
Wang Shilong [Thu, 12 Dec 2013 07:47:00 +0000 (15:47 +0800)]
Btrfs-progs: add sanity checks for btrfs device operations
Make sure we are a block device firstly, this can avoid some
unnecessary ioctls operations.
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>
Eric Sandeen [Thu, 12 Dec 2013 07:34:16 +0000 (15:34 +0800)]
btrfs-progs: fix resource leak in scrub_start()
Resolves-Coverity-CID: 1125934
Resolves-Coverity-CID: 1125935
Resolves-Coverity-CID: 1125936
Signed-off-by: Eric Sandeen <sandeen@redhat.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>
Josef Bacik [Tue, 7 Jan 2014 20:19:35 +0000 (15:19 -0500)]
Btrfs-progs: deal with invalid key orderings and bad orphan items V2
A user had a fs where the objectid of an orphan item was not the actual orphan
item objectid. This screwed up fsck because the block has keys in the wrong
order, also the fs scanning stuff will freak out because we have an inode with
nlink 0 and no orphan item. So this patch is pretty big but is all related.
1) Deal with bad key ordering. We can easily fix this up, so fix the checking
stuff to tell us exactly what it found when it said there was a problem. Then
if it's bad key ordering we can reorder the keys and restart the scan.
2) Deal with bad keys. If we find an orphan item with the wrong objectid it's
likely to screw with stuff, so keep track of these sort of things with a
bad_item list and just run through and delete any objects that don't make sense.
So far we just do this for orphan items but we could extend this as new stuff
pops up.
3) Deal with missing orphan items. This is easy, if we have a file with i_nlink
set to 0 and no orphan item we can just add an orphan item.
4) Add the infrastructure to corrupt actual key values. Needed this to create a
test image to verify I was fixing things properly.
This patch fixes the corrupt image I'm adding and passes the other make test
tests. 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>
Josef Bacik [Wed, 11 Dec 2013 16:17:52 +0000 (11:17 -0500)]
Btrfs-progs: reset balance before reiniting extent root
When we re-init the extent root we make it completely empty, so when we reset a
pending balance we will fail to find refs for any blocks we may cow, which will
result in errors and we will exit out. We need to reset the balance first so
the normal cow stuff doesn't freak out and then we can re-init the extent tree.
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>
Wang Shilong [Thu, 12 Dec 2013 07:46:18 +0000 (15:46 +0800)]
Btrfs-progs: make sure we are opening a file or dir with open_file_or_dir()
Previously, open_file_or_dir() will open block device successfully, however,
we should enhance such checks to make sure we are really opening a file or dir.
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>
Gui Hecheng [Wed, 11 Dec 2013 09:27:46 +0000 (17:27 +0800)]
btrfs-progs: fix improper error prompt for defragment
The error msg:
"ERROR: defrag range ioctl not supported in this kernel,
please try without any options."
should only show up when failing to do a range defraging,
not upon non-range defraging.
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>
David Sterba [Tue, 10 Dec 2013 17:17:10 +0000 (18:17 +0100)]
btrfs-progs: convert remaining uuid buffer declarations to BTRFS_UUID_UNPARSED_SIZE
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
David Sterba [Mon, 2 Sep 2013 15:22:24 +0000 (17:22 +0200)]
btrfs-progs: add fsck.btrfs stub and manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Gui Hecheng [Tue, 10 Dec 2013 11:16:31 +0000 (19:16 +0800)]
btrfs-progs: fix a manpage item for btrfstune
btrfstune operates on umounted devices <device>,
not mount points <mnt>. fix it.
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>
David Sterba [Fri, 6 Dec 2013 18:00:49 +0000 (19:00 +0100)]
btrfs-progs: send: check if parent or clone sources are read-only
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Wang Shilong [Fri, 29 Nov 2013 16:37:25 +0000 (00:37 +0800)]
Btrfs-progs: avoid using btrfs internal subvolume path to send
Steps to reproduce:
# mkfs.btrfs -f /dev/sda
# mount /dev/sda /mnt
# btrfs subvolume create /mnt/foo
# umount /mnt
# mount -o subvol=foo /dev/sda /mnt
# btrfs sub snapshot -r /mnt /mnt/snap
# btrfs send /mnt/snap > /dev/null
We will fail to send '/mnt/snap',this is because btrfs send try to
open '/mnt/snap' by btrfs internal subvolume path 'foo/snap' rather
than relative path based on mounted point, this will return us 'no
such file or directory',this is not right, fix it.
Reported-by: Thomas Scheiblauer <tom@sharkbay.at>
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>
Anand Jain [Mon, 2 Dec 2013 06:11:55 +0000 (14:11 +0800)]
btrfs-progs: qgroup destroy says create failed
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>
Wang Shilong [Wed, 4 Dec 2013 09:24:36 +0000 (17:24 +0800)]
Btrfs-progs: fix segfault when getting scrub status
I sometimes get segfault in cmd_scrub_status(), this is because
free_history() forgot to check whether pointer address is valid,fix it.
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>
Wang Shilong [Mon, 2 Dec 2013 06:42:25 +0000 (14:42 +0800)]
Btrfs-progs: add option to skip whether a scrub has started/resumed in userspace
I hit a problem that i can not start scrub when i am trying to track
superblock generation mismatch problems.
The fact is that we are trying to check whether we have started a scrub operation
in userspace, this will make us can't start scrub if that record file is damaged
itself. By adding a option to skip that check, everything will be fine.
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>
Anand Jain [Mon, 2 Dec 2013 06:11:54 +0000 (14:11 +0800)]
btrfs-progs: fix backref after init-csum-tree
btrfsck reports backref error after running init-csum-tree
btrfsck --init-csum-tree /dev/sdc
btrfsck /dev/sdc
::
ref mismatch on [
29474816 16384] extent item 1, found 0
Backref
29474816 root 7 not referenced back 0x1101d30
Incorrect global backref count on
29474816 found 1 wanted 0
backpointer mismatch on [
29474816 16384]
owner ref check failed [
29474816 16384]
Errors found in extent allocation tree or chunk allocation
::
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>
Anand Jain [Mon, 2 Dec 2013 06:11:53 +0000 (14:11 +0800)]
btrfs-progs: Turning ON incompat isn't an error
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>
Gui Hecheng [Thu, 28 Nov 2013 05:32:52 +0000 (13:32 +0800)]
btrfs-progs: scan devices in parallel for chunk-recover
Originally, multi devices are scanned one by one;
Now, one thread is used per device to scan.
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>
Gui Hecheng [Thu, 28 Nov 2013 05:32:51 +0000 (13:32 +0800)]
btrfs-progs: add chunk-recover raid0/5/6 data stripes rebuild routine
Decide the raid0/5/6 data stripes' order using checksums.
For one chunk, fetch each 64k logical stripe
1. search its checksum in the csum tree
2. read the physical stripe data on each device
3. calc the data checksums
4. if one checksum matches the value from the csum tree,
then the logical stripe resides in that device,
the stripe order index can be calculated.
5. if more than one checksums match,
then use the successive csum in the tree to compare again.
6. if equal stripes are encountered, just fetch next stripe.
7. if some devices' order are still not decided, then they
can not be recovered.
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>
Gui Hecheng [Thu, 28 Nov 2013 05:32:50 +0000 (13:32 +0800)]
btrfs-progs: skip chunk recover works when check chunks successfully
If no chunks need to be recovered, skip the recover works,
meanwhile the user won't be annoyed by the "ask_user".
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>
Wang Shilong [Thu, 28 Nov 2013 05:32:49 +0000 (13:32 +0800)]
Btrfs-progs: chunk-recover: add new flag to prepare recovering for ordered data chunk
When reading block groups we will searching it's corresponding chunk, however, at this
time, some chunks has not been built(data chunks raid0/raid10/raid56), don't bug_on here,
we will try to rebuild these chunks later.
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>
David Sterba [Wed, 27 Nov 2013 17:22:34 +0000 (18:22 +0100)]
btrfs-progs: use mntent functions in find_mount_root
getmntent should be used in context of *mntent functions, though
fopen/fclose works.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
David Sterba [Wed, 27 Nov 2013 17:14:58 +0000 (18:14 +0100)]
btrfs-progs: call endmntent in btrfs_scan_kernel
btrfs_scan_kernel() does a getmntent() but never releases the
filedescriptor it gets back from that.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64711
Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Liu Bo [Wed, 27 Nov 2013 16:08:24 +0000 (00:08 +0800)]
Btrfs-progs: fix the mismatch of extent buffer's space
Now we set @refs to 2 on creating a new extent buffer, meanwhile we
allocate the needed free space, but we don't give enough free_extent_buffer()
to reduce the eb's references to zero so that the eb can finally be freed,
so the problem is we has decrease the referene count of backrefs to zero, which
ends up releasing the space occupied by the eb, and this space can be allocated
again for something else(another eb or disk), usually a crash(core dump) will
occur, I've hit a crash in rb_insert() because another eb re-use the space while
the original one is floating around.
We should do the same thing as the kernel code does, it's necessary to initialize
@refs to 1 instead of 2, this helps us get rid of the above problem.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Wang Shilong [Wed, 27 Nov 2013 14:43:56 +0000 (22:43 +0800)]
Btrfs-progs: chunk-recover: use right size when allocating chunk root node
When allocating chunk root node, we should use nodesize rather than sectorsize,
this will casue regression when making other nodesize choice.(for example 16k size now)
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>
Ross Kirk [Wed, 2 Oct 2013 12:28:27 +0000 (13:28 +0100)]
btrfs-progs: Make btrfs_header_chunk_tree_uuid() return unsigned long
Internally, btrfs_header_chunk_tree_uuid() calculates an unsigned
long, but casts it to a pointer, while all callers cast it to unsigned
long again.
From btrfs commit
b308bc2f05a86e728bd035e21a4974acd05f4d1e
Signed-off-by: Ross Kirk <ross.kirk@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Anand Jain [Mon, 4 Nov 2013 07:17:41 +0000 (15:17 +0800)]
btrfs-progs: define BTRFS_UUID_UNPARSE_SIZE for uuid unparse buf size
we use 37 as the allocation size to hold the uuid_unparse, here
it defines BTRFS_UUID_UNPARSE_SIZE for the same.
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>
Filipe David Borba Manana [Tue, 12 Nov 2013 13:41:42 +0000 (13:41 +0000)]
Btrfs-progs: let get_label return the label instead of printing it
get_label prints the label at the moment. Change this so that
the label is returned and printing is done by the caller.
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>
Wang Shilong [Wed, 13 Nov 2013 09:25:46 +0000 (17:25 +0800)]
Btrfs-progs: try harder to make btrfs receive successfully
Steps to reproduce:
# mkfs.btrfs -f <dev>
# mount <dev> <mnt>
# mkdir <mnt>/backup
# btrfs sub create <mnt>/subv
# btrfs sub snapshot -r <mnt>/subv <mnt>/snap1
# btrfs sub snapshot -r <mnt>/subv <mnt>/snap2
# btrfs send <mnt>/snap2 -p <mnt>/snap1 -f sent_file
# btrfs receive -f sent_file <mnt>/backup
Above steps will make btrfs receive fails with "ERROR: can not find
parent subvolume", this is because we try to find parent subvolume by
RECEIVED_SUBVOL_KEY,and it will return ENOENT if parent snapshot has not
been sent or it has been deleted. Actually, we can try harder to find
whether parent subvolume exists by searching uuid key.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Anand Jain [Wed, 13 Nov 2013 08:19:39 +0000 (16:19 +0800)]
btrfs-progs: make it static if function isn't called outside
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>
Anand Jain [Thu, 7 Nov 2013 02:53:43 +0000 (10:53 +0800)]
btrfs-progs: use /proc/self/mounts
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>
David Sterba [Fri, 20 Sep 2013 16:52:18 +0000 (18:52 +0200)]
btrfs-progs: fix loop device mount checks
When creating a fs on a loop device, mkfs checks whether the same file
is not already mounted, but a backing file of another loop dev does not
exist, mkfs fails. This fixes a bug during openSUSE installation.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Miao Xie [Fri, 25 Oct 2013 09:30:45 +0000 (17:30 +0800)]
Btrfs-progs: don't output baffling message when checking a fresh fs
As we know, a new fs doesn't have space cache, so we set the cache generation
of the super block to be -1ULL, it is not equal to the fs generation. But the
check program didn't consider this case, and output the following message
cache and super generation don't match, space cache will be invalidated
directly, it would be baffling the users. So we should avoid outputing such
message. This patch fixes this problem.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Josef Bacik [Fri, 25 Oct 2013 18:01:40 +0000 (14:01 -0400)]
Btrfs-progs: allow --init-extent-tree to work when extent tree is borked
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>
Anand Jain [Thu, 24 Oct 2013 14:42:56 +0000 (22:42 +0800)]
btrfs-progs: make filesystem show by label work
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>
David Sterba [Fri, 25 Oct 2013 10:01:44 +0000 (12:01 +0200)]
btrfs-progs: remove cmds-chunk.c
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>
Gui Hecheng [Thu, 17 Oct 2013 06:25:29 +0000 (14:25 +0800)]
Btrfs-progs: fix btrfsck improper prompt on dropping snapshots
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>
Chris Mason [Mon, 25 Nov 2013 20:48:57 +0000 (15:48 -0500)]
Update the version
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Chris Mason [Fri, 22 Nov 2013 13:41:50 +0000 (08:41 -0500)]
Add -fno-strict-aliasing
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Chris Mason [Mon, 18 Nov 2013 19:18:08 +0000 (14:18 -0500)]
btrfs filesystem show: skip duplicate fsids
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>
Anand Jain [Fri, 15 Nov 2013 11:11:09 +0000 (19:11 +0800)]
btrfs-progs: for mixed group check opt before default raid profile is enforced
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>
David Sterba [Thu, 14 Nov 2013 14:09:53 +0000 (15:09 +0100)]
btrfs-progs: mkfs: enable extended refs by default
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>
David Sterba [Thu, 14 Nov 2013 13:40:43 +0000 (14:40 +0100)]
btrfs-progs: man: add rescue super-recover bits
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
David Sterba [Thu, 14 Nov 2013 13:30:45 +0000 (14:30 +0100)]
btrfs-progs: mkfs: extend -O syntax to disable features
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>
Emil Karlson [Mon, 11 Nov 2013 16:22:24 +0000 (18:22 +0200)]
btrfs-progs: remove extra uuid-tree.o in objects
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>
Chris Mason [Fri, 8 Nov 2013 18:51:52 +0000 (13:51 -0500)]
mkfs: change default metadata blocksize to 16KB
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:55 +0000 (17:15 -0600)]
btrfs-progs: annotate fallthroughs in parse_limit
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:54 +0000 (17:15 -0600)]
btrfs-progs: annotate fallthroughs in parse_size
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:53 +0000 (17:15 -0600)]
btrfs-progs: check for fstat failure in cmd_defrag
Resolves-Coverity-CID: 1125924
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Wed, 6 Nov 2013 23:15:52 +0000 (17:15 -0600)]
btrfs-progs: check btrfs_scan_one_device in btrfs_scan_lblkid()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:51 +0000 (17:15 -0600)]
btrfs-progs: remove more dead code from check_extent_refs
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:50 +0000 (17:15 -0600)]
btrfs-progs: pass positive errno to strerror in cmd_df()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:49 +0000 (17:15 -0600)]
btrfs-progs: Check for open failure in btrfs_scan_lblkid()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:48 +0000 (17:15 -0600)]
btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:46 +0000 (17:15 -0600)]
btrfs-progs: don't leak buffer on add_file_items() error
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:45 +0000 (17:15 -0600)]
btrfs-progs: fix leak of "buf" in make_btrfs() error paths
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:44 +0000 (17:15 -0600)]
btrfs-progs: don't leak fd in test_dev_for_mkfs() error paths
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:43 +0000 (17:15 -0600)]
btrfs-progs: fix test for return of realpath in find_mount_root()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:42 +0000 (17:15 -0600)]
btrfs-progs: use strncpy in btrfs_scan_lblkid()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:41 +0000 (17:15 -0600)]
btrfs-progs: fix error returns in get_df()
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>
Eric Sandeen [Wed, 6 Nov 2013 23:15:40 +0000 (17:15 -0600)]
btrfs-progs: fix potential double-frees in cmd_subvol_delete()
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>
Eryu Guan [Wed, 6 Nov 2013 10:49:12 +0000 (18:49 +0800)]
Btrfs-progs: set return value to 0 if subvolume get-default successfully
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>
Josef Bacik [Mon, 28 Oct 2013 18:28:43 +0000 (14:28 -0400)]
Btrfs-progs: rework open_ctree to take flags, add a new one V2
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>
Josef Bacik [Wed, 23 Oct 2013 20:24:03 +0000 (16:24 -0400)]
Btrfs-progs: add -b to btrfsck to look at backup roots
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>
David Sterba [Wed, 23 Oct 2013 17:00:09 +0000 (19:00 +0200)]
btrfs-progs: add filter for deleted but uncleanded subvolumes
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>
Josef Bacik [Wed, 23 Oct 2013 16:18:03 +0000 (12:18 -0400)]
Btrfs-progs: just return -ENOENT if we don't find the root item
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>
Josef Bacik [Tue, 22 Oct 2013 14:10:21 +0000 (10:10 -0400)]
Btrfs-progs: make pretty_sizes take u64 instead of a double
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>
Anand Jain [Tue, 22 Oct 2013 05:53:22 +0000 (13:53 +0800)]
btrfs-progs: filesystem show of specified mounted disk should work
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>
Anand Jain [Tue, 22 Oct 2013 05:53:21 +0000 (13:53 +0800)]
btrfs-progs: make get_btrfs_mount callable
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>
Josef Bacik [Mon, 21 Oct 2013 13:58:08 +0000 (09:58 -0400)]
Btrfs-progs: make sure we return an error when we can't add a device
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>
Chris Mason [Wed, 16 Oct 2013 14:36:55 +0000 (10:36 -0400)]
mkfs: fix mkfs -r to properly allocate space
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>
Anand Jain [Fri, 11 Oct 2013 11:52:54 +0000 (19:52 +0800)]
btrfs-progs: use the marco BTRFS_UPDATE_KERNEL where needed
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>
Anand Jain [Fri, 11 Oct 2013 11:52:53 +0000 (19:52 +0800)]
btrfs-progs: device scan use BTRFS_SCAN_LBLKID by default
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>
Anand Jain [Tue, 8 Oct 2013 03:41:40 +0000 (11:41 +0800)]
btrfs-progs: use BTRFS_SCAN_LBLKID as default scan in filesystem show
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>
Anand Jain [Tue, 8 Oct 2013 03:41:38 +0000 (11:41 +0800)]
btrfs-progs: use kernel for mounted disk for show
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>
Eryu Guan [Sat, 12 Oct 2013 15:47:52 +0000 (23:47 +0800)]
Btrfs-progs: check return value of realpath(3)
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>
Zach Brown [Fri, 11 Oct 2013 16:21:46 +0000 (09:21 -0700)]
btrfs-progs: check fopen failure in cmds-send
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>
Zach Brown [Mon, 7 Oct 2013 21:43:05 +0000 (14:43 -0700)]
btrfs-progs: free leaked roots in calc-size
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>
Zach Brown [Mon, 7 Oct 2013 21:43:04 +0000 (14:43 -0700)]
btrfs-progs: remove unused variables
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>
Zach Brown [Mon, 7 Oct 2013 21:43:03 +0000 (14:43 -0700)]
btrfs-progs: don't overflow colors[] in fragments
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>
Zach Brown [Mon, 7 Oct 2013 21:43:02 +0000 (14:43 -0700)]
btrfs-progs: don't deref pipefd[-1]
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>
Zach Brown [Mon, 7 Oct 2013 21:43:01 +0000 (14:43 -0700)]
btrfs-progs: don't leak path in verify_space_cache
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>
Zach Brown [Mon, 7 Oct 2013 21:43:00 +0000 (14:43 -0700)]
btrfs-progs: free eb in fixup_chunk_tree_block()
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>
Zach Brown [Mon, 7 Oct 2013 21:42:59 +0000 (14:42 -0700)]
btrfs-progs: remove dead block group checking
Don't carry around dead code. If its needed again, it's only a few git
commands away. 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>