summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* Btrfs-progs: optimize function btrfs_read_chunk_treeFilipe David Borba Manana2013-08-09
| | | | | | | | | | | | | | | | | | | After reading all device items from the chunk tree, don't exit the loop and then navigate down the tree again to find the chunk items. Instead just read all device items and chunk items with a single tree search. This is possible because all device items are found before any chunk item in the chunks tree. This is a port of the corresponding kernel patch to keep both kernel and btrfs-progs identical: https://patchwork.kernel.org/patch/2835529/ Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: remove incorrect slot decrementFilipe David Borba Manana2013-08-09
| | | | | | | | | | | | | | In btrfs_set_block_flags() we want to check if the slot in the leaf points to the first item in the leaf - if it doesn't check if the previous item in the leaf is an extent item. By removing this extra slot decrement we are indeed checking the item right before the slot, and not the second item before. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix optimization in btrfs_lookup_extent_infoFilipe David Borba Manana2013-08-09
| | | | | | | | | | | | | | | | | | | If we did a tree search with the goal to find a metadata item but the search failed with return value 1, we attempt to see if in the same leaf there's a corresponding extent item, and if there's one, just use it instead of doing another tree search for this extent item. The check in the leaf was wrong because it was seeking for a metadata item instead of an extent item. This optimization was also being triggered incorrectly, as it was evaluating path->slots which always evaluates to true. The goal was to see if the leaf level slot was greater than zero (i.e. not the first item in the leaf). Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: don't ignore errors in extent-tree.cFilipe David Borba Manana2013-08-09
| | | | | | | | Several function return values were being completely ignored. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: return error on write failure in make_btrfs()Filipe David Borba Manana2013-08-09
| | | | | | | | | | | Instead of aborting with a BUG_ON() statement, return a negated errno code. Also updated mkfs and convert tools to print a nicer error message when make_btrfs() returns an error. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: add missing write check for mkfsFilipe David Borba Manana2013-08-09
| | | | | | | | | | | | | | | | Assert that the writes of the device and chunk tree roots succeed. This verification is currently done for all other tree roots, however it was missing for those 2 trees. Would these tree root writes fail, but all others succeed, it would lead to a corrupted/incomplete btrfs filesystem, or, more likely some weird failure later on in mkfs.btrfs inside open_ctree(). Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix possible memory leak related to subvolume/snapshot creationWang Shilong2013-08-09
| | | | | | | | | The operation related qgroup inherit may fails, if it fails, we should free memory allocated,otherwise, memory leak happens. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: per-thread, per-call pretty bufferZach Brown2013-08-09
| | | | | | | | | | | | | | | | | We don't need callers to manage string storage for each pretty_sizes() call. We can use a macro to have per-thread and per-call static storage so that pretty_sizes() can be used as many times as needed in printf() arguments without requiring a bunch of supporting variables. This lets us have a natural interface at the cost of requiring __thread and TLS from gcc and a small amount of static storage. This seems better than the current code or doing something with illegible format specifier macros. Signed-off-by: Zach Brown <zab@redhat.com> Acked-by: Wang Shilong <wangs.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: remove unused codeFilipe David Borba Manana2013-08-09
| | | | | | | Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-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: add kstrdup() return value checkFilipe David Borba Manana2013-08-09
| | | | | | | | | | When allocating a btrfs_device structure, device_list_add() in volumes.c was not checking if the call to duplicate the label string succeeded or not. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: Cleanup unneeded extra variant in btrfs_read_sys_arrayQu Wenruo2013-08-09
| | | | | | | | | | | | | The btrfs_read_sys_array function uses 3 variants to read data from super block. But the three variants are related to each other, so the patch removes unneeded extra variants and make code a little simpler. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: Cleanup for using BTRFS_SETGET_STACK instead of raw convertQu Wenruo2013-08-09
| | | | | | | | | | | | Some codes still use the cpu_to_lexx instead of the BTRFS_SETGET_STACK_FUNCS declared in ctree.h. Also added some BTRFS_SETGET_STACK_FUNCS for btrfs_header and btrfs_super. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: kerncompat.h: remove offsetof redefinitionCristian Rodríguez2013-08-09
| | | | | | | | Must use the version provided by the compiler in stddef.h header Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix the comment for extent_io.c/clear_extent_bitsWang Sheng-Hui2013-08-09
| | | | | | | | It should be 'clear', not 'set'. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: update man page for btrfs filesystem labelGuangyu Sun2013-08-09
| | | | | | | | | | btrfs filesystem label can work on a mounted filesystem, also on a multi-devices filesystem. And the restriction of label name is changed, too. The man page should be updated accordingly. Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: add option to btrfs-debug-tree to print uuid tree onlyStefan Behrens2013-08-09
| | | | | | Signed-off-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: add uuid_tree_gen field to btrfs-show-superStefan Behrens2013-08-09
| | | | | | Signed-off-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: use UUID tree for send/receiveStefan Behrens2013-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the btrfs send/receive commands to use the UUID tree to map UUIDs to subvolumes, and to use the root tree to map subvolume IDs to paths. Now these tools start fast and are independent on the number of subvolules/snapshot that exist. Before this commit, mapping UUIDs to subvolume IDs was an operation with a high effort. The algorithm even had quadratic effort (based on the number of existing subvolumes). E.g. with 15,000 subvolumes it took much more than 5 minutes on a state of the art XEON CPU to start btrfs send or receive before these tools were able to send or receive the first byte). Even linear effort instead of the current quadratic effort would be too much since it would be a waste. And these data structures to allow mapping UUIDs to subvolume IDs had been created every time a btrfs send/receive instance was started. It is much more efficient to maintain a searchable persistent data structure in the filesystem, one that is updated whenever a subvolume/snapshot is created and deleted, and when the received subvolume UUID is set by the btrfs-receive tool. Therefore kernel code was added that is able to maintain data structures in the filesystem that allow to quickly search for a given UUID and to retrieve data that is assigned to this UUID, like which subvolume ID is related to this UUID. Signed-off-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: add UUID tree lookup methodsStefan Behrens2013-08-09
| | | | | | | | | This commit adds UUID tree lookup methods that make use of the search ioctl. The code is based on the kernel code. Signed-off-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: Support UUID tree and UUID items in btrfs-debug-treeStefan Behrens2013-08-09
| | | | | | | | Support printing these things. Signed-off-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: commit the csum_root if we do --init-csum-treeJosef Bacik2013-08-09
| | | | | | | | | | | | | This is just an oddity with the commit stuff in btrfs-progs. It will just update the generation of the root you call with, which in btrfsck case would have been the fs_root. But because we didn't actually update the fs_root we wouldn't have cow'ed the fs root and therefore the generation will not match the node which will make the file system unmountable. Fix this by calling with the csum_root which is the one we're messing with. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: pretty print dir_item typeFilipe David Borba Manana2013-08-09
| | | | | | | | | | Instead of printing an integer, print a symbolic name which is more human friendly. Particularly useful when using the program btrfs-debug-tree. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: Add missing close_ctree() calls to debug-treeFilipe David Borba Manana2013-08-09
| | | | | | Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: Add missing free_extent_buffer() call to debug-treeFilipe David Borba Manana2013-08-09
| | | | | | Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix compile warning in btrfs_free_block_groups()Wang Shilong2013-08-09
| | | | | | | | | | extent-tree.c: In function 'btrfs_free_block_groups': extent-tree.c:3190:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mkfs: add -O option to specify fs featuresDavid Sterba2013-08-09
| | | | | | | | Extend mkfs options to specify optional or potentially backwards incompatible features. Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: detect when scrub is started twiceStefan Behrens2013-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check whether any involved device is already busy running a scrub. This would cause damaged status messages and the state "aborted" without the explanation that a scrub was already running. Therefore check it first, prevent it and give some feedback to the user if scrub is already running. Note that if scrub is started with a block device as the parameter, only that particular block device is checked. It is a normal mode of operation to start scrub on multiple single devices, there is no reason to prevent this. Here is an example: /mnt2 is the mountpoint of a filesystem. /dev/sdk and /dev/sdl are the block devices for that filesystem. case 1: btrfs scrub start /mnt2 btrfs scrub start /mnt2 -> complain case 1: btrfs scrub start /dev/sdk btrfs scrub start /dev/sdk -> complain case 3: btrfs scrub start /dev/sdk btrfs scrub start /dev/sdl -> don't complain case 4: btrfs scrub start /dev/sdk btrfs scrub start /mnt2 -> complain case 5: btrfs scrub start /mnt2 btrfs scrub start /dev/sdk -> complain if the scrub on /dev/sdk is still running. -> don't complain if the scrub on /dev/sdk is finished, the status messages will be fine. Reported-by: David Sterba <dsterba@suse.cz> Signed-off-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: restore: use long option for the path regexDavid Sterba2013-08-09
| | | | | | | | | | | Current way of specifying the path to match is not very comfortable, but the feature itself is very useful. Let's save the short option -m for a more user friendly syntax and keep a long option --path-regex with the current syntax. CC: Peter Stuge <peter@stuge.se> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix regexec to only work if we actually have a regexecJosef Bacik2013-08-09
| | | | | | | | | | We were unconditionally executing our regular expression, even though we may not have one, so check to make sure mreg is not null before calling regexec. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* restore: Add regex matching of paths and files to be restoredPeter Stuge2013-08-09
| | | | | | | | | | | | | | | | | | | The option -m is used to specify the regex string. -c is used to specify case insensitive matching. -i was already taken. In order to restore only a single folder somewhere in the btrfs tree, it is unfortunately neccessary to construct a slightly nontrivial regex, e.g.: restore -m '^/(|home(|/username(|/Desktop(|/.*))))$' /dev/sdb2 /output This is needed in order to match each directory along the way to the Desktop directory, as well as all contents below the Desktop directory. Signed-off-by: Peter Stuge <peter@stuge.se> Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: pass up return value of walk_down_treeLin Ming2013-08-09
| | | | | | | | | Pass up return value of walk_down_tree, so the caller can handle it. This also fixes a segfault when read_tree_block fails with NULL returned. Signed-off-by: Lin Ming <mlin@kernel.org> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: update manpage to add filesystem show command in synopsisEryu Guan2013-08-09
| | | | | | | | filesystem show was missing in SYNOPSIS section. 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>
* libbtrfs: Set SONAME to "libbtrfs.so.0" (instead of "libbtrfs.so").Richard W.M. Jones2013-08-09
| | | | | | Signed-off-by: Richard W.M. Jones <rjones@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: add send option for using new end-cmd semanticStefan Behrens2013-08-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a command line option to enable sending streams which make use of the new end-cmd semantic if multiple snapshots are sent back-to-back. The goal is to use the <end cmd> as an indication to stop reading the input stream. So far, the receiver could only use EOF to recognize the end. If the new command line option '-e' is set, this commit requires a kernel which is able to support the new flags in the send ioctl. New bits in the flags of the send ioctl will be set which cause EINVAL on old kernels. However, if the option '-e' is not set, it works with old and new kernels without any errors or any changed behavior. This used to be the encoding (with 2 snapshots in this example): <stream header> + <sequence of commands> + <end cmd> + <stream header> + <sequence of commands> + <end cmd> + EOF The new format (if the two new flags are used) is this one: <stream header> + <sequence of commands> + <sequence of commands> + <end cmd> Note that the currently existing receivers treat <end cmd> only as an indication that a new <stream header> is following. This means, you can just skip the sequence <end cmd> <stream header> without loosing compatibility. As long as an EOF is following, the currently existing receivers handle the new format (if the two new flags are used) exactly as the old one. Also note that the kernel interface was changed in a way that is backward compatible to old btrfs-progs tools. You set one or two bits in the flags field of the ioctl to enable the new behavior. Old tools set these flags to zero, thus getting exactly the same as they got with older kernels. And this is exactly what happens if the new '-e' option is not set, the new bits in the flags are not set and thus old kernels and new kernels are both supported. So what is the benefit of this change? The goal is to be able to use a single stream (one TCP connection) to multiplex a request/response handshake plus Btrfs send streams, all in the same stream. In this case you cannot evaluate an EOF condition as an end of the Btrfs send stream. You need something else, and the <end cmd> is just perfect for this purpose. Signed-off-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: make btrfsck a hardlink at install timeEric Sandeen2013-08-09
| | | | | | | | | | | | | btrfsck gets hardlinked to btrfs during the build, but the install phase simply copies them both to the destination without preserving the link. Just force-link btrfsck in the destination again during install so that the installed btrfsck is a link as well. Signed-off-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: remove btrfs_init_path calls from ctree.cEric Sandeen2013-08-09
| | | | | | | | | | | | | | | | | | btrfs_init_path was initially used when the path objects were on the stack. Now all the work is done by btrfs_alloc_path and btrfs_init_path isn't required. This patch removes it, and just uses kmem_cache_zalloc to zero out the object. [Eric Sandeen: port kernel commit e00f730 to userspace] (Note, the rest of userspace has an on-stack path, so the actual function remains for now). Signed-off-by: Chris Mason <chris.mason@oracle.com> Signed-off-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: remove the unnecessary 'return -1;' at the end of bin_searchEric Sandeen2013-08-09
| | | | | | | | | | | The code path should not reach there. Remove it. [Eric Sandeen: port kernel commit 3fed40c to userspace] Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-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: make extent_ref_type() match kernelspaceEric Sandeen2013-08-09
| | | | | | | | | | extent_ref_type() contains inconsequential differences between kernelspace and userspace, and has since the initial commits to each. Just make userspace look like kernelspace. Signed-off-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: cleanup duplicated division functionsEric Sandeen2013-08-09
| | | | | | | | | | | | | div_factor has been implemented for two times, cleanup it. And I move them into a independent file named math.h because they are common math functions. [Eric Sandeen: port kernel commit 3fed40c to userspace] Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-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: remove some dead/unbuilt codeEric Sandeen2013-08-09
| | | | | | | | | | | | | | | | | Remove some commented-out & #if 0'd code: * close_blocks() * btrfs_drop_snapshot() * btrfs_realloc_node() * btrfs_find_dead_roots() There are still some #if 0'd functions in there, but I'm hedging on those for now, they have been copied to cmds-check.c and I want to see if they can be brough back into ctree.c eventually. Signed-off-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: move btrfs_fsck_reinit_root to cmds-check.cEric Sandeen2013-08-09
| | | | | | | | | | | cmds-check.c contains the only caller of btrfs_fsck_reinit_root; moving it to the caller's source file gets ctree.c a little closer to kernelspace, although it does require exporting add_root_to_dirty_list(), which is not done in kernelspace. Signed-off-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: fix array bound checkingEric Sandeen2013-08-09
| | | | | | | | | | | Otherwise we can execced the array bound of path->slots[]. [Eric Sandeen: port kernel commit a05a9bb to userspace] Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-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: remove dead btrfs-defrag.cEric Sandeen2013-08-09
| | | | | | | | | | Files with only #include directives are boring. :) This is just a leftover after the move to the btrfs tool. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-restore: deal with NULL returns from read_node_slotChris Mason2013-07-05
| | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-restore: use the correct leafsize when reading the FS locationChris Mason2013-07-05
| | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Add options to btrfs-find-root to control generation and levelChris Mason2013-07-05
| | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfsck: fix incorrect casting on items in the corrupt_blocks treeChris Mason2013-07-05
| | | | | | | check_extent_refs is pinning down all the corrupt tree blocks it finds, but it is incorrectly casting these to an extent_record first. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix closing of devicesFilipe David Borba Manana2013-07-05
| | | | | | | | | | | | | | | | | | | | | | | If a device could not be opened in volumes.c:read_one_dev(), a btrfs_device instance was allocated and added to the list of devices of the fs - however this device instance had its fd, name and label fields not initialized. This is problematic in disk-io.c:close_all_devices() as it tried to sync, fadvise and close the (invalid) fd of the device, and kfree() its name and label, which pointed to random memory locations. Thread 1 (Thread 0x7f0a3d2d1740 (LWP 23585)): #0 __GI___libc_free (mem=0xa5a5a5a5a5a5a5a5) at malloc.c:2970 #1 0x000000000042054b in close_all_devices (fs_info=0x1e92bf0) at disk-io.c:1276 #2 0x0000000000421dcd in close_ctree (root=<optimized out>) at disk-io.c:1336 #3 0x0000000000418cfa in cmd_check (argc=<optimized out>, argv=<optimized out>) at cmds-check.c:4171 #4 0x0000000000403ed4 in main (argc=2, argv=0x7fff9a583d28) at btrfs.c:295 v2: Added Liu Bo's review mention. Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Merge branch 'liubo-image-restore'Chris Mason2013-07-03
|\ | | | | | | | | | | | | | | Signed-off-by: Chris Mason <chris.mason@fusionio.com> Conflicts: disk-io.c volumes.h
| * Btrfs-progs: enhance btrfs-image to restore image onto multiple disksLiu Bo2013-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a 'btrfs-image -m' option, which let us restore an image that is built from a btrfs of multiple disks onto several disks altogether. This aims to address the following case, $ mkfs.btrfs -m raid0 sda sdb $ btrfs-image sda image.file $ btrfs-image -r image.file sdc --------- so we can only restore metadata onto sdc, and another thing is we can only mount sdc with degraded mode as we don't provide informations of another disk. And, it's built as RAID0 and we have only one disk, so after mount sdc we'll get into readonly mode. This is just annoying for people(like me) who're trying to restore image but turn to find they cannot make it work. So this'll make your life easier, just tap $ btrfs-image -m image.file sdc sdd --------- then you get everything about metadata done, the same offset with that of the originals(of course, you need offer enough disk size, at least the disk size of the original disks). Besides, this also works with raid5 and raid6 metadata image. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>