Anand Jain [Thu, 14 Mar 2013 03:17:19 +0000 (11:17 +0800)]
btrfs-progs: print errno string when /dev/btrfs-control open fails
Of recently and intermittently I am seeing open fail
for /dev/btrfs-control (btrfs is loaded), and there are no
dmesg errors, this may not be a complete help in digging
this issue but something which is necessary.
Thanks
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Anand Jain [Thu, 14 Mar 2013 02:12:41 +0000 (10:12 +0800)]
btrfs-progs: update .gitignore file
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Hugo Mills [Tue, 12 Mar 2013 15:44:11 +0000 (15:44 +0000)]
btrfs-progs: add Makefile rule for static build of btrfs-find-root
btrfs-find-root isn't yet integrated into the main btrfs tool, and is
an important recovery tool, so it deserves to be built as a static
binary.
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Eric Sandeen [Tue, 12 Mar 2013 04:17:40 +0000 (23:17 -0500)]
btrfs-progs: rework get_fs_info to remove side effects
get_fs_info() has been silently switching from a device to a mounted
path as needed; the caller's filehandle was unexpectedly closed &
reopened outside the caller's scope. Not so great.
The callers do want "fdmnt" to be the filehandle for the mount point
in all cases, though - the various ioctls act on this (not on an fd
for the device). But switching it in the local scope of get_fs_info
is incorrect; it just so happens that *usually* the fd number is
unchanged.
So - use the new helpers to detect when an argument is a block
device, and open the the mounted path more obviously / explicitly
for ioctl use, storing the filehandle in fdmnt.
Then, in get_fs_info, ignore the fd completely, and use the path on
the argument to determine if the caller wanted to act on just that
device, or on all devices for the filesystem.
Affects those commands which are documented to accept either
a block device or a path:
* btrfs device stats
* btrfs replace start
* btrfs scrub start
* btrfs scrub status
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 11 Mar 2013 23:13:00 +0000 (18:13 -0500)]
btrfs-progs: don't open-code mountpoint discovery in scrub cancel
cmd_scrub_cancel had its own mountpoint discovery routine;
just use open_path_or_dev_mnt() for that now.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 11 Mar 2013 23:12:59 +0000 (18:12 -0500)]
btrfs-progs: three new device/path helpers
Add 3 new helpers:
* is_block_device(), to test if a path is a block device.
* get_btrfs_mount(), to get the mountpoint of a device,
if mounted.
* open_path_or_dev_mnt(path), to open either the pathname
or, if it's a mounted btrfs dev, the mountpoint. Useful
for some commands which can take either type of arg.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 11 Mar 2013 23:12:58 +0000 (18:12 -0500)]
btrfs-progs: close fd on return from label get/set functions
Somehow missed these 2 in the last round.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Josef Bacik [Tue, 12 Mar 2013 14:07:39 +0000 (10:07 -0400)]
Btrfs-progs: alloc our super copy in btrfs-find-root
Dave fixed the fs_info to allocate the super copy instead of embedding it, but
he failed to notice that I open code open_ctree in btrfs-find-root so we end up
with a super that's not allocated, so we segfault whenever you try to run
btrfs-find-root. I've fixed this up and now we don't segfault anymore. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Antoine Sirinelli [Mon, 11 Mar 2013 21:17:17 +0000 (21:17 +0000)]
btrfs-progs: Add a rule to build a static mkfs.btrfs
Static mkfs.btrfs can be used to "bootstrap" a system from a live CD
which does not provide mkfs.btrfs.
The executable produced is named mkfs.btrfs.static and built by invoking
the "static" make rule.
Signed-off-by: Antoine Sirinelli <antoine@monte-stello.com>
David Sterba [Wed, 6 Mar 2013 16:32:51 +0000 (17:32 +0100)]
btrfs-progs: separate super_copy out of fs_info
Allocate fs_info::super_copy dynamically of full BTRFS_SUPER_INFO_SIZE
and use it directly for saving superblock to disk.
This fixes incorrect superblock checksum after mkfs.
Signed-off-by: David Sterba <dsterba@suse.cz>
Anand Jain [Fri, 8 Mar 2013 15:25:45 +0000 (23:25 +0800)]
btrfs-progs: update the .gitignore file
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Eric Sandeen [Mon, 4 Mar 2013 22:49:40 +0000 (16:49 -0600)]
btrfs-progs: fix scrub error return from pthread_mutex_lock
If pthread_mutex_lock() fails it returns the error in ret,
and does not set errno.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:45:37 +0000 (16:45 -0600)]
btrfs-progs: Error handling in scrub_progress_cycle() thread
consolidate error handling to ensure that peer_fd
is closed on error paths. Add a couple comments
to the error handling after the thread is complete.
Note that scrub_progress_cycle returns negative
errnos on any error.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:40:03 +0000 (16:40 -0600)]
btrfs-progs: better option/error handling for btrfs-vol
Today wrong cmdlines give odd results:
# ./btrfs-vol /dev/sdb1
Unable to open device (null)
# ./btrfs-vol -a /dev/sdb1
usage: btrfs-vol [options] mount_point ...
Make it a bit more informative:
# ./btrfs-vol /dev/sdb1
No command specified
usage: btrfs-vol [options] mount_point ...
# ./btrfs-vol -a /dev/sdb1
No mountpoint specified
usage: btrfs-vol [options] mount_point ...
(even though it's deprecated ...)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:35:42 +0000 (16:35 -0600)]
btrfs-progs: Issue warnings if ioctls fail in sigint handlers
The two sigint handlers issue ioctls to clean up, but if
they fail, noone would know. I'm not sure there is
any other error handling to be done at this point, but a
notification seems wise.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:40:01 +0000 (16:40 -0600)]
btrfs-progs: check return of posix_fadvise
It seems highly unlikely that posix_fadvise could fail,
and even if it does, it was only advisory. Still, if
it does, we could issue a notice to the user.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:40:00 +0000 (16:40 -0600)]
btrfs-progs: Free resources when returning error from cmd_subvol_create()
cmd_subvol_create() currently returns without freeing resources
in almost every error case. Switch to a goto arrangement
so all cleanup can be done in one place.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:59 +0000 (16:39 -0600)]
btrfs-progs: tidy up cmd_subvol_create() whitespace & returns
Just whitespace fixes, and magical return value removal.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:58 +0000 (16:39 -0600)]
btrfs-progs: Free resources when returning error from cmd_snapshot()
cmd_snapshot() currently returns without freeing resources
in almost every error case. Switch to a goto arrangement
so all cleanup can be done in one place.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:57 +0000 (16:39 -0600)]
btrfs-progs: tidy up cmd_snapshot() whitespace & returns
Just whitespace fixes, and magical return value removal.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:56 +0000 (16:39 -0600)]
btrfs-progs: check for null string in parse_size
Because it's better than a segfault if it's called improperly,
and it makes static checkers happier.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:55 +0000 (16:39 -0600)]
btrfs-progs: free allocated metadump structure on restore failure
Don't return w/ "metadump" still allocated
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:53 +0000 (16:39 -0600)]
btrfs-progs: free resources on do_rollback error returns
close fd if open, and free allocated memory in buf
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:52 +0000 (16:39 -0600)]
btrfs-progs: close fd on do_convert error returns
stops an fd leak that Coverity found.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Mar 2013 22:39:51 +0000 (16:39 -0600)]
btrfs-progs: close fd on cmd_subvol_list return
stops an fd leak that Coverity found.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Zhi Yong Wu [Mon, 4 Mar 2013 01:37:28 +0000 (09:37 +0800)]
btrfs-progs: update mkfs.btrfs help info for raid5/6
Since raid5/6 support was introduced, we should update mkfs.btrfs help info.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Anand Jain [Fri, 1 Mar 2013 10:10:02 +0000 (18:10 +0800)]
btrfs-progs: usage should match what is coded
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Anand Jain [Fri, 1 Mar 2013 10:10:01 +0000 (18:10 +0800)]
btrfs-progs: from troubleshooting point of view messages must be unique
-----
cmds-device.c: fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
utils.c: fprintf(stderr, "ERROR: unable to scan the device '%s' - %s\n",
-----
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Anand Jain [Fri, 22 Feb 2013 06:59:24 +0000 (14:59 +0800)]
Btrfs-progs: add correct indentation
A trivial fix, corrects the indentation.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Tsutomu Itoh [Wed, 27 Feb 2013 02:31:54 +0000 (11:31 +0900)]
Btrfs-progs: fix segmentation fault of "btrfs check"
Segmentation fault occurred in the following command.
# btrfs check /dev/sdc7
No valid Btrfs found on /dev/sdc7
Segmentation fault (core dumped)
Fix it.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Wang Shilong [Wed, 27 Feb 2013 11:04:18 +0000 (19:04 +0800)]
Btrfs-progs: output the error reason when qgroup_show fails
The original code forgot to output the reason why the commands failed,
fix it.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Wang Shilong [Wed, 27 Feb 2013 11:03:21 +0000 (19:03 +0800)]
Btrfs-progs: let the error message outputed only once
If we fail to execute the command:
btrfs qgroup show <mnt>
It will output the follow messages:
ERROR: can't perform the search - Inappropriate ioctl for device
ERROR: can't list qgroups
The error is outputed twice, this is wrong, fix it.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
David Sterba [Tue, 12 Feb 2013 17:44:35 +0000 (18:44 +0100)]
btrfs-progs: don't link binaries to a dynamic library
Linking 'btrfs' and other binaries against the dynamic library makes it
tedious to use directly from the git repo. This is useful for testing
various fixes, but now it'd need to also set LD_LIBRARY_PATH or install
the library to a known path.
Add a target for static library and use it for linking, the dynamic
library is to be used by external users.
Signed-off-by: David Sterba <dsterba@suse.cz>
Mark Fasheh [Mon, 7 Jan 2013 22:24:35 +0000 (14:24 -0800)]
btrfs-progs: libify some parts of btrfs-progs
External software wanting to use the functionality provided by the btrfs
send ioctl has a hard time doing so without replicating tons of work. Of
particular interest are functions like btrfs_read_and_process_send_stream()
and subvol_uuid_search(). As that functionality requires a bit more than
just send-stream.c and send-utils.c we have to pull in some other parts of
the progs package.
This patch adds code to the Makefile and headers to create a library,
libbtrfs which the btrfs command now links to.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Eric Sandeen [Tue, 26 Feb 2013 21:50:22 +0000 (15:50 -0600)]
btrfs-progs: initialize save_ptr prior to strtok_r
The coverity runs had a false positive complaining that
save_ptr is uninitialized in the call to strtok_r.
Turns out that under the covers glibc was doing enough
to confuse the checker about what was being called.
Just to keep the noise down, do a harmless initialization,
with a comment as to why.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:49 +0000 (16:54 -0600)]
btrfs-progs: fix fd leak in cmd_subvol_set_default
Rearrange cmd_subvol_set_default() slightly so we
don't have to close the fd on an error return.
While we're at it, fix whitespace & remove magic
return values.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:48 +0000 (16:54 -0600)]
btrfs-progs: Tidy up resolve_root
Whitespace fixes and fix a variable declaration after
code.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:47 +0000 (16:54 -0600)]
btrfs-progs: fix mem leak in resolve_root
If we exit with error we must free the allocated memory
to avoid a leak.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:46 +0000 (16:54 -0600)]
btrfs-progs: close fd on cmd_subvol_get_default return
Without this we leak the fd when we return from the
function.
Also, remove the senseless random return values.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:45 +0000 (16:54 -0600)]
btrfs-progs: free allocated di_args in cmd_start_replace
We only freed this allocation in error paths, and leaked
a bit when it went out of scope normally.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:44 +0000 (16:54 -0600)]
btrfs-progs: provide positive errno to strerror in cmd_restore
check_mounted returns a negative errno, so it needs to be flipped
again before passing to strerror.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:43 +0000 (16:54 -0600)]
btrfs-progs: don't call close on error fd
In the error case where fd < 0, close(fd) is the wrong
thing to do.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:42 +0000 (16:54 -0600)]
btrfs-progs: free memory before error exit in read_whole_eb
Free the memory allocated to "multi" before the error
exit in read_whole_eb(). Set it to NULL after we free
it in the loop to avoid any potential double-free.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:41 +0000 (16:54 -0600)]
btrfs-progs: more scrub cancel error handling
If we request scrub cancel on an unmounted or
non-btrfs device, we still get a "scrub canceled"
success message:
# btrfs scrub cancel /dev/loop1
scrub cancelled
# blkid /dev/loop1
/dev/loop1: UUID="
7f586941-1d5e-4ba7-9caa-
b35934849957" TYPE="xfs"
Fix this so that if check_mounted_where returns 0
we don't report success.
While we're at it, use perror to report the reason for an open
failure, if we get one.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:40 +0000 (16:54 -0600)]
btrfs-progs: fix close of error fd in scrub cancel
If we retry opening the mountpoint and fail, we'll call
close on a filehandle w/ value -1. Rearrange so the
retry uses the same open and same error handling.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:39 +0000 (16:54 -0600)]
btrfs-progs: fix open error test in cmd_start_replace
open() returns a negative fd on failure, not 0.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:38 +0000 (16:54 -0600)]
btrfs-progs: avoid double-free in __btrfs_map_block
__btrfs_map_block() can possibly do the goto again: loop after
having allocated & freed the "multi" pointer. There are then
a couple error conditions where it will attempt to again kfree
the now non-NULL multi pointer. So before retrying, reset
multi to NULL after we free it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:37 +0000 (16:54 -0600)]
btrfs-progs: btrfs_list_get_path_rootid error handling
btrfs_list_get_path_rootid() tries to return a negative
number on error, but it's a u64 function. Callers which test
for a return < 0 will never see an error.
Change the function to fill in the rootid via a pointer,
and then return a simple int as error.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:36 +0000 (16:54 -0600)]
btrfs-progs: Remove write-only var fdres in cmd_dev_stats()
fdres is initialized to -1, then later tested, but never
set. Just remove it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 25 Feb 2013 22:54:35 +0000 (16:54 -0600)]
btrfs-progs: fix btrfs_get_subvol cut/paste error
in btrfs_get_subvol(), there is a cut and paste error:
if (ri->full_path)
the_ri->full_path = strdup(ri->full_path);
else
the_ri->name = NULL;
It should be setting the_ri->full_path to NULL here.
Do it in a function instead of the cpoy & paste to avoid future
errors.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Jeff Liu [Wed, 30 Jan 2013 08:32:47 +0000 (16:32 +0800)]
btrfs-progs: move btrfslabel.[c|h] stuff to utils.[c|h]
Clean btrfslabel.[c|h] out of the source tree and move those related
functions to utils.[c|h].
CC: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Jeff Liu [Wed, 30 Jan 2013 08:32:43 +0000 (16:32 +0800)]
btrfs-progs: refactor check_label()
Refactor check_label().
- Make it be static at first, this is a preparation step since we'll remove
btrfslabel.[c|h] and move those functions from there to utils.[c|h], we can
do pre-checking against the input label string with it.
- Fix the label length check up from BTRFS_LABEL_SIZE to BTRFS_LABEL_SIZE - 1.
- Kill the check of label contains an invalid character, see below commits for detail:
79e0e445fc2365e47fc7f060d5a4445d37e184b8
btrfs-progs: kill check for /'s in labels.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
CC: David Sterba <dsterba@suse.cz>
CC: Gene Czarcinski <gene@czarc.net>
Jeff Liu [Mon, 17 Dec 2012 11:35:29 +0000 (11:35 +0000)]
Btrfs-progs: fix cmd_label_usage to reflect this change.
Fix the command usage of "btrfs filesystem label" to reflect this change. i.e. so that
we can get/set the label of a mounted filesystem against the mountpoint.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Jeff Liu [Mon, 17 Dec 2012 11:35:27 +0000 (11:35 +0000)]
Btrfs-progs: Fix set_label_unmounted() with label length validation
Currently, we keeping silent if the label length is exceeding BTRFS_LABEL_SIZE - 1, and just
truncating the characters beyond that.
This patch make it return error and exit in this situation.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Jeff Liu [Mon, 17 Dec 2012 11:35:23 +0000 (11:35 +0000)]
Btrfs-progs: Change the label of a mounted file system
With this new ioctl(2), we can set/change the label for a mounted file system.
It still does normal process for an umounted file system.
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Mark Fasheh [Thu, 31 Jan 2013 18:57:53 +0000 (10:57 -0800)]
btrfsprogs: btrfstune support for extended inode refs
This patch adds an option to btrfstune, '-r' which will enable the extended
inode refs flag on the provided btrfs superblock. We don't have a disable
option at the moment as that would require far more work.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Liu Bo [Mon, 18 Feb 2013 10:05:17 +0000 (18:05 +0800)]
Btrfs-progs: fix segmentation fault of 'btrfs-debug-tree -e'
Due to some historical reasons, we remove 'printing leaf' part, which'd
lead to 'Segmentation fault' of btrfs-debug-tree -e, this patch adds it
back.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Eric Sandeen [Thu, 14 Feb 2013 18:30:03 +0000 (12:30 -0600)]
btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table
The core of this is shamelessly stolen from xfsprogs.
Use blkid to detect an existing filesystem or partition
table on any of the target devices. If something is found,
require the '-f' option to overwrite it, hopefully avoiding
disaster due to mistyped devicenames, etc.
# mkfs.btrfs /dev/sda1
WARNING! - Btrfs v0.20-rc1-59-gd00279c-dirty IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
/dev/sda1 appears to contain an existing filesystem (xfs).
Use the -f option to force overwrite.
#
This does introduce a requirement on libblkid.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Mark Fasheh [Thu, 14 Feb 2013 18:29:50 +0000 (10:29 -0800)]
btrfs-progs: Fix pointer math in __ino_to_path_fd
We are casting an array of u64 values into a char ** array so
when we dereference this array (as a char **) on a 32 bit system
we're then re-casting that back to a 32 bit value. This causes
problems when we try to print those strings.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Tsutomu Itoh [Thu, 14 Feb 2013 07:53:04 +0000 (16:53 +0900)]
Btrfs-progs: check out if the swap device
Currently, the following commands succeed.
# cat /proc/swaps
Filename Type Size Used Priority
/dev/sda3 partition 8388604 0 -1
/dev/sdc8 partition 9765884 0 -2
# mkfs.btrfs /dev/sdc8
WARNING! - Btrfs v0.20-rc1-165-g82ac345 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
fs created label (null) on /dev/sdc8
nodesize 4096 leafsize 4096 sectorsize 4096 size 9.31GB
Btrfs v0.20-rc1-165-g82ac345
# btrfs fi sh /dev/sdc8
Label: none uuid:
fc0bdbd0-7eed-460f-b4e9-
131273b66df2
Total devices 1 FS bytes used 28.00KB
devid 1 size 9.31GB used 989.62MB path /dev/sdc8
Btrfs v0.20-rc1-165-g82ac345
#
But we should check out the swap device. Fixed it.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Tested-by: David Sterba <dsterba@suse.cz>
Arvin Schnell [Wed, 30 Jan 2013 22:50:26 +0000 (14:50 -0800)]
btrfs-progs: make libbtrfs usable from C++
Please find attached a patch to make the new libbtrfs usable from
C++ (at least for the parts snapper will likely need).
Signed-off-by: Arvin Schnell <aschnell@suse.de>
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Ilya Dryomov [Tue, 12 Feb 2013 16:42:30 +0000 (18:42 +0200)]
Btrfs-progs: make 0 a valid usage filter argument
This is a progs counterpart to a "Btrfs: allow for selecting only
completely empty chunks". usage=0 now means "select only only
completely empty chunks and nothing else".
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Mark Fasheh [Wed, 30 Jan 2013 22:50:25 +0000 (14:50 -0800)]
btrfs-progs: add send-test
send-test.c links against libbtrfs and uses the send functionality provided
to decode and print a send stream to the console.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Mark Fasheh [Wed, 30 Jan 2013 22:50:23 +0000 (14:50 -0800)]
btrfs-progs: Add support for BTRFS_SEND_FLAG_NO_FILE_DATA
The flag and command are synced from kernel to user. Also, this patch adds a
callback for the BTRFS_SEND_C_UPDATE_EXTENT in struct btrfs_send_ops.
read_and_process_cmd() is updated to decode BTRFS_SEND_C_UPDATE_EXTENT and
send the values through the right callback. I did not add a callback
definition to cmds-receive.c as that code never uses
BTRFS_SEND_FLAG_NO_FILE_DATA.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Ian Kumlien [Fri, 8 Feb 2013 00:37:02 +0000 (01:37 +0100)]
Btrfs-progs: add restore command to btrfs
Add 'btrfs restore' command which previously existed as a separate
utility btrfs-restore.
Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Ian Kumlien [Fri, 8 Feb 2013 00:37:01 +0000 (01:37 +0100)]
Btrfs-progs: restore.c -> cmds-restore.c
The btrfs-restore functionality will be integrated in
btrs as "btrfs restore"
Signed-off-by: Ian Kumlien <pomac@demius.net>
David Sterba [Tue, 12 Feb 2013 16:39:44 +0000 (17:39 +0100)]
btrfs-progs: build btrsfck to keep compatibility
The command 'btrfsck' is commonly used and we should build it by
default.
Signed-off-by: David Sterba <dsterba@suse.cz>
Ilya Dryomov [Tue, 12 Feb 2013 19:24:50 +0000 (21:24 +0200)]
Btrfs-progs: add btrfsck name detection to btrfs
This patch adds a busybox-style name detection for the name "btrfsck" to
btrfs utility. The idea is to maintain backwards compatibility by
linking btrfsck to btrfs and have btrfs invoke the check sub-command
when called through the btrfsck link. This has been suggested on the
mailing list and approved by Dave and Chris.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Ilya Dryomov [Tue, 12 Feb 2013 19:24:50 +0000 (21:24 +0200)]
Btrfs-progs: move crc32c optimization init
Don't call crc32c_optimization_init() until we know that a command is
actually going to be invoked.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Ian Kumlien [Fri, 8 Feb 2013 00:36:58 +0000 (01:36 +0100)]
Btrfs-progs: add btrfsck functionality to btrfs
This patch includes the functionality of btrfs, it's
found as "btrfs check".
Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Ian Kumlien [Fri, 8 Feb 2013 00:36:57 +0000 (01:36 +0100)]
Btrfs-progs: Rename btrfsck.c -> cmds-check.c
In preparation for merging btrfsck functionality in to btrfs.
Signed-off-by: Ian Kumlien <pomac@demius.net>
Ian Kumlien [Tue, 5 Feb 2013 22:04:22 +0000 (23:04 +0100)]
Btrfs-progs: -U_FORTIFY_SOURCE before -D
My builds are cluttered with:
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by
default]
Which makes it hard to tell if something breaks or not.
Signed-off-by: Ian Kumlien <pomac@demius.net>
Ian Kumlien [Fri, 25 Jan 2013 23:12:28 +0000 (00:12 +0100)]
Btrfs-progs: add static compile target
Sometimes, when you least expect it, a static binary is what you need to
rescue your data... Or just get a good enough handle on things to make
it work again ;)
"make static" is a gift to you, dear user with filesystem problems!
Anyway, on a more serious note, changed the cflags and ldflags so that
we create a smaller binary, 1.1MB stripped on my 64 bit system
(2.7MB with debug data)
Signed-off-by: Ian Kumlien <pomac@demius.net>
Wang Sheng-Hui [Thu, 16 Aug 2012 14:25:20 +0000 (22:25 +0800)]
btrfs-progs: code cleanup for root-tree.c/btrfs_del_root
Remove the redundant if check on the condition ret > 0.
Leave BUG_ON check here.
Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Josef Bacik [Fri, 1 Feb 2013 20:21:04 +0000 (15:21 -0500)]
Btrfs-progs: return an error if we can't find an fs root
Instead of doing a BUG_ON() if we fail to find the last fs root just return
an error so the callers can deal with it how they like. Also we need to
actually return an error if we can't find the latest root so that the error
handling works. With this btrfsck was able to deal with a file system that
was missing a root item but still had extents that referred back to the
root. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Josef Bacik [Fri, 1 Feb 2013 20:18:24 +0000 (15:18 -0500)]
Btrfs-progs: fix double free of extent buffer
Noticed this while looking for an segfault related to our eb cache in
btrfsck. We free the eb in out: so we don't need this extra free. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Josef Bacik [Fri, 1 Feb 2013 20:17:07 +0000 (15:17 -0500)]
Btrfs-progs: handle errors reading fs roots
A user had a problem where btrfsck would bail out because it was finding
extents for a snapshot that had been deleted but not entirely cleaned up.
We can handle this case fine, we just need to report an error properly.
This patch allowed btrfsck to continue and eventually fix his file system.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Eric Sandeen [Mon, 4 Feb 2013 17:26:23 +0000 (11:26 -0600)]
btrfs-progs: remove unused bit-radix.[ch] files
fd53de4d Drop bit-radix.[ch] files
removed the files from the Makefile, but not the files themselves.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Mon, 4 Feb 2013 15:57:57 +0000 (10:57 -0500)]
Btrfs-progs print more informative error when we fail to open a device
print more informative error when we fail to open a device
If open() fails, we should let the user know why it failed.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Gene Czarcinski <gene@czarc.net>
Chris Mason [Wed, 6 Feb 2013 17:51:58 +0000 (12:51 -0500)]
Merge branch 'cov-fixes-v1-integration-
20130201' of git.zabbo.net/cgit/btrfs-progs into merged
Chris Mason [Wed, 6 Feb 2013 17:42:24 +0000 (12:42 -0500)]
Merge branch 'for-chris' of git://repo.or.cz/btrfs-progs-unstable/devel into raid56
Conflicts:
ctree.h
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Wed, 30 Jan 2013 07:11:46 +0000 (01:11 -0600)]
btrfs-progs: initialize pipefd[] for error path
Several goto out; paths will end up doing i.e.
if (pipefd[0])
close(pipefd[0]);
but we get there with uninitialized values in many cases.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 19:27:48 +0000 (13:27 -0600)]
btrfs-progs: fix overflows of ioctl name args
3 places where we copy pathnames into ioctl arguments
were not limited to the destination name size, and
could overflow. Use the new strncpy_null() macro
to make this safe.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 19:27:47 +0000 (13:27 -0600)]
btrfs-progs: simplify ioctl name copy and null termination
In the places where we copy a string into the name
member of btrfs_ioctl_vol_args or btrfs_ioctl_vol_args_v2,
we use strncopy (to not overflow the name array) and then
set the last position to the null character.
Howver, in both cases the arrays are defined with:
char name[MAX+1];
hence the last array position is name[MAX].
In most cases, we now insert the null at name[MAX-1]
which deprives us of one useful character.
Even the above isn't consistent through the code, so
make some helper code to make it simple, i.e.
strncpy_null(dest, src) which automatically does the
right thing based on the size of dest.
Thanks to Zach Brown for the macro suggestion.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 19:27:46 +0000 (13:27 -0600)]
btrfs-progs: fix name lengths in cmd_subvol_create
cmd_subvol_create() calls either BTRFS_IOC_SUBVOL_CREATE
or BTRFS_IOC_SUBVOL_CREATE_V2 depending on whether or
not inherit is set. However, these 2 ioctls have different
args structures with different length name[] members.
In the BTRFS_IOC_SUBVOL_CREATE case, the arg is
btrfs_ioctl_vol_args, with a BTRFS_PATH_NAME_MAX length
name, not a BTRFS_SUBVOL_NAME_MAX length name.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 00:18:57 +0000 (18:18 -0600)]
btrfs-progs: remove duplicate __setup_root
__setup_root() was present in find-root.c as well
as disk-io.c. No need for the cut and paste, just
use the one in disk-io.c
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 00:18:53 +0000 (18:18 -0600)]
btrfs-progs: fix mdresotre typo in function names
"mdresotre" sounds like it might be French, but most
likely it's a misspelling of mdrestore. Fix it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 00:18:51 +0000 (18:18 -0600)]
btrfs-progs: zero out inspect ioctl args
Mostly just to keep things like coverity happy about potentially
uninitialized structure members, since it doesn't grok the ioctl.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 00:18:50 +0000 (18:18 -0600)]
btrfs-progs: don't use closed fd
In the case that btrfs scrub cancel is given a device name,
we close the file handle, and then pass it to check_mounted_where()
which eventually preads from that (now closed) fd. Fix the logic
so that we close & re-open the discovered mountpoint properly.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Eric Sandeen [Fri, 25 Jan 2013 00:18:49 +0000 (18:18 -0600)]
btrfs-progs: don't double-close prg_fd
If scrub start discovers that scrub is already running,
we need to set prg_fd to -1 before goto out, or we'll
try to close it again in the error path.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Thu, 24 Jan 2013 18:53:49 +0000 (10:53 -0800)]
btrfs-progs: don't leak fds in logical resolve
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Thu, 24 Jan 2013 18:45:00 +0000 (10:45 -0800)]
btrfs-progs: close fd in inode resolve
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Thu, 24 Jan 2013 18:38:28 +0000 (10:38 -0800)]
btrfs-progs: don't leak multi-bio in find_root()
It wasn't freed if it didn't find metadata.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 23:18:14 +0000 (15:18 -0800)]
btrfs-progs: don't leak inherit on errors
A few paths returned errors before freeing their inherit allocation.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 23:15:09 +0000 (15:15 -0800)]
btrfs-progs: close ioctl fd in find new
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 23:11:24 +0000 (15:11 -0800)]
btrfs-progs: don't leak fd in resize
Argument validation failed to close the fd that was opened. So check
the arguments before opening anything.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 23:07:18 +0000 (15:07 -0800)]
btrfs-progs: free path before returning
One of the return statements in search_dir() didn't free everything it
was supposed to.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 23:00:46 +0000 (15:00 -0800)]
btrfs-progs: close fd in qgroup show
It wasn't closed in the error path.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 22:55:31 +0000 (14:55 -0800)]
btrfs-progs: free bits in check_extents()
As far as I can tell, nothing took the address of this.
Signed-off-by: Zach Brown <zab@redhat.com>
Zach Brown [Wed, 23 Jan 2013 22:54:35 +0000 (14:54 -0800)]
btrfs-progs: remove unused arguments
add_root_to_pending() took a bunch of arguments that it never used.
Signed-off-by: Zach Brown <zab@redhat.com>