summaryrefslogtreecommitdiff
path: root/cmds-receive.c
Commit message (Collapse)AuthorAge
* btrfs-progs: Remove deprecated _BSD_SOURCE macro.Qu Wenruo2014-12-19
| | | | | | | | | | | | | | | | Fix the following gcc(>4.9) and clang warning: In file included from cmds-receive.c:24: In file included from ./kerncompat.h:22: In file included from /usr/include/stdio.h:27: /usr/include/features.h:148:3: warning: "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-W#warnings] ^ 1 warning generated. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add missing descriptions of '--max-errors' in btrfs-receive ↵Satoru Takeuchi2014-08-22
| | | | | | | | | | documentation Fix the lack of description of "--max-erros" option in both man and command usage of btrfs receive. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Check fstype in find_mount_root()Qu Wenruo2014-08-22
| | | | | | | | | | | | | | When calling find_mount_root(), caller in fact wants to find the mount point of *BTRFS*. So also check ent->fstype in find_mount_root() and do special error string output in caller. This will suppress a lot of "Inapproiate ioctl for device" error message. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Remove fprintf() in find_mount_root().Qu Wenruo2014-08-22
| | | | | | | | | | | find_mount_root() function in utils.c should not print error string. Caller should be responsible to print error string. This patch will remove the only fprintf in find_mount_root() and modify the caller a little to use strerror() to prompt users. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: receive, allow to continue after errors happenFilipe David Borba Manana2014-08-22
| | | | | | | | | | | | | | | | | | | | Due to either bugs in send (kernel) that generate a command against a wrong path for example, or transient errors on the receiving side, we stopped processing the send stream immediately and exited with an error. It's often desirable to continue processing the send stream even if an error happens while processing a single command from the send stream. This change just adds a --max-errors <N> parameter, whose default value is 1 (preserving current behaviour), that allows to tolerate N errors before stopping. A value of 0 means to never stop no matter how many errors we get into while processing the send stream. Regardless of its value, errors are always printed to stderr when they happen, just like before this change. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: receive: remove return type of close_inode_for_writeRakesh Pandit2014-05-02
| | | | | | | | "close_inode_for_write" always returns 0, so just remove its return value and remove dead checking in caller. Signed-off-by: Rakesh Pandit <rakesh@tuxera.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use usage() to replace the warning msg on no-arg usageGui Hecheng2014-03-21
| | | | | | | | | To be consistent with the other cmds, replace the warning msg with usage() when send/receive are used without any args. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: receive: don't output normal message into stderrWang Shilong2014-03-21
| | | | | | | | | Don't output normal messages into stderr, this make xfstests filter output easier. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: receive: fix the case that we can not find the subvolumeWang Shilong2014-01-31
| | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: convert remaining uuid buffer declarations to ↵David Sterba2014-01-31
| | | | | | | BTRFS_UUID_UNPARSED_SIZE Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: try harder to make btrfs receive successfullyWang Shilong2014-01-31
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Btrfs-progs: fix magic return value in cmds-receive.cWang Shilong2013-10-16
| | | | | | 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: mark static & remove unused from non-kernel codeEric Sandeen2013-09-03
| | | | | | | | Mark many functions as static, and remove any resulting dead code. 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: drop weird indirections & dead code from send/receiveEric Sandeen2013-09-03
| | | | | | | | | | | | | cmds-recieve.c & cmds-send.c seem to have weird wrappers and indirections, and "groups" of commands which have only one member, which are never referenced in the code. I think these can be removed. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-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: Fix the receive code pathingAlex Lyakas2013-04-23
| | | | | | | | | | | | | The receive code was not distinguishing properly between the mount root and the directory to create the received subvolume in. Also make sure the find_mount_root reports an error if it cannot find a match at all. Reported-by: Robert Buhren <robert@robertbuhren.de> Reported-by: Rory Campbell-Lange <rory@campbell-lange.net> Reported-by: Stefan Priebe - Profihost AG <s.priebe@profihost.ag> Signed-off-by: Alex Lyakas <alex.btrfs@zadarastorage.com> Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: allow to receive to relative directoriesStefan Behrens2013-04-23
| | | | Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: Fix that BTRFS_FSID_SIZE is used instead of BTRFS_UUID_SIZEStefan Behrens2013-04-23
| | | | | | Both are 16 but it's wrong anyway to use FSID_SIZE for UUIDs. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: btrfs-receive optionally honors the end-cmdStefan Behrens2013-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new option is added to btrfs-receive to change the behavior when an <end cmd> is received in the Btrfs send stream. The traditional behavior (which still is the default) is to continue to read the stream until an EOF condition is encountered. If an <end cmd> is received, afterwards either an EOF or a new <stream header> is expected. The new behavior (if the -e option is set on the command line) is to terminate after an <end cmd> is read without the need for an EOF. This allows the stream (e.g. a single TCP stream) to carry additional data or even multiple Btrfs send streams. Old btrfs-send tools used to encode multiple snapshots like this (with 2 snapshots in this example): <stream header> + <sequence of commands> + <end cmd> + <stream header> + <sequence of commands> + <end cmd> + EOF If the new -e option is set, the expected format is like this: <stream header> + <sequence of commands> + <sequence of commands> + <end cmd> The btrfs-send tool is changed in a seperate commit to always use the new format, i.e. to send an <end cmd> only at the end. 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. The goal of changing the semantic of <end cmd> 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>
* Btrfs-progs: small parent_subvol cleanup for cmds-receive.cStefan Behrens2013-04-23
| | | | | | parent_subvol is local to process_snapshot() and not needed outside. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: Set the root-id for received subvols in btrfs receiveStefan Behrens2013-04-23
| | | | | | | | | When an entry was added to the subvol search tree, the root_id was always 0 (not set at all) and therefore only the first one was added, all the others had been ignored. This commit sets the root_id before the entry is added. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: btrfs-receive: different levels (amount) of debug outputStefan Behrens2013-04-23
| | | | | | | | | There used to be 2 levels of verbose output, now there are 3: - None at all (no -v option given). - Some information about received snapshots / subvolumes (-v option). - Each received command is printed (-vv option). Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: free memory and close file descriptor in btrfs receiveStefan Behrens2013-04-23
| | | | | | | Nothing really important since this is not part of the library and at the end exit() is called. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: cleanup subvol_uuid_search memory in btrfs send/receiveStefan Behrens2013-04-23
| | | | | | Call the cleanup function that was introduced with the other commit. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* btrfs-progs: fix overflows of ioctl name argsEric Sandeen2013-02-05
| | | | | | | | | 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>
* btrfs-progs: remove unused info_fdZach Brown2013-02-05
| | | | | | finish_subvol() initializes and tests info_fd but it is never used. Signed-off-by: Zach Brown <zab@redhat.com>
* Btrfs-progs: Complete the help information of btrfs send/receiveChen Yang2013-02-01
| | | | | | | | | | When typing command "btrfs send --help" or "btrfs receive --help", the help information of the commands is incomplete, which only shows a short usage. This patch helps to display the complete infomation of the commands. Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
* Btrfs-progs: correct btrfs receive usage stringUlrik2013-01-21
| | | | | | | | Fix the usage string to specify the correct '-f' option for input file, not '-i'. Signed-off-by: Ulrik Sverdrup <ulrik.sverdrup@gmail.com> Signed-off-by: Gene Czarcinski <gene@czarc.net>
* btrfs-progs: Receive: preserve ownership for symlinks, by using 'lchown'Alex Lyakas2013-01-17
| | | | Signed-off-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
* Btrfs-progs: Fix compiler warnings on PPC64Wade Cline2013-01-17
| | | | | | | | | | | | | | | | The kernel uses unsigned long long for u64, but PPC64 uses unsigned long by default. This results in compilation warnings such as: print-tree.c:333: warning: format '%llu' expects type 'long long unsigned int', but argument 4 has type 'u64' To fix this, the macro __KERNEL__ needs to be defined before including the file <asm/types.h>. This can be done by defining the macro in "kerncompat.h" and making it the first included file in the relevant header files; this fixes the compiler warnings on PPC64. Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Wade Cline <clinew@linux.vnet.ibm.com>
* Btrfs-progs: add btrfs send/receive commandsAlexander Block2012-07-26
Add user space commands for btrfs send/receive. Signed-off-by: Alexander Block <ablock84@googlemail.com> Reviewed-by: David Sterba <dave@jikos.cz> Reviewed-by: Arne Jansen <sensille@gmx.net> Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Reviewed-by: Alex Lyakas <alex.bolshoy.btrfs@gmail.com>