summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* Btrfs-progs: add an option to btrfs-image to walk the treesJosef Bacik2013-04-23
| | | | | | | | | | | | When working with a user with a broken file system I noticed I wasn't able to read some of the blocks properly from the restored image. This is because his extent tree was corrupt and was missing references to some of the blocks, which means they weren't copied into the image when he generated it. So add a -w option which will walk all of the trees manually and copy them into the image. This way we can run fsck against a complete file system image and fix any bugs in fsck. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs-progs: use clearer var names in is_ssd()Eric Sandeen2013-04-23
| | | | | | | | | | | | | | is_ssd() uses nondescript variable names; path - to what? disk - it's a dev_t not a disk name, unlike dev, which is a name not a dev_t! Rename some vars to make things hopefully clearer: wholedisk - the name of the node for the entire disk devno - the dev_t of the device we're mkfs'ing sysfs_path - the path in sysfs we ultimately check Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: replace blkid_probe_get_wholedisk_devnoEric Sandeen2013-04-23
| | | | | | | | | | | | | | blkid_probe_get_wholedisk_devno() isn't available in some older versions of libblkid. It was used to work around an old bug in blkid_devno_to_wholedisk(), but that has been fixed since 5cd0823 libblkid: fix blkid_devno_to_wholedisk(), present in util-linux 2.17 and beyond. If we happen to be missing that fix, the worst that happens is that we'd fail to detect that a device is an ssd; the upside is that this code compiles on older systems. Signed-off-by: Eric Sandeen <sandeen@redhat.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: remove some unused codeStefan 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: don't allocate one byte too much each timeStefan Behrens2013-04-23
| | | | | | | | | | str1 + '/' + str2 + '\0' requires a buffer with the size strlen(str1) + strlen(str2) + 2 bytes. str1 + '/' + str2 + '/' + str3 + '\0' requires a buffer with the size strlen(str1) + strlen(str2) + strlen(str3) + 3 bytes. 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: fix bug in find_root_genStefan Behrens2013-04-23
| | | | | | A copy & paste error. 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: add a function to free subvol_uuid_search memoryStefan Behrens2013-04-23
| | | | | | | | There was no way to free the memory that was used for the subvol_uuid_search functions. Since this is part of the libbtrfs, add such a cleanup function. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: fix a small memory leak in btrfs-list.cStefan Behrens2013-04-23
| | | | | | valgrind found this very obvious issue. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: close file descriptor in cmds-send.cStefan Behrens2013-04-23
| | | | | | valgrind found this very obvious issue. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: ignore subvols above BTRFS_LAST_FREE_OBJECTIDStefan Behrens2013-04-23
| | | | Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* btrfs-progs: add quota-related info to usage messagesKoen De Wit2013-04-23
| | | | | | | | | | | Extending usage messages with some info on the quota functionality: - The -i option of "subvol create" and "subvol snapshot" was not documented - The -c option of "qgroup limit" is the default option - The "qouta rescan" command is not yet implemented, while it should be executed after enabling quota on a non-empty filesystem. Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
* Btrfs-progs: add a free space cache checker to fsck V2Josef Bacik2013-04-23
| | | | | | | | | | | | | In trying to track down a weird tree log problem I wanted to make sure that the free space cache was actually valid, which we currently have no way of doing. So this patch adds a bunch of support for the free space cache code and then a checker to fsck. Basically we go through and if we can actually load the free space cache then we will walk the extent tree and verify that the free space cache exactly matches what is in the extent tree. Hopefully this will always be correct, the only time it wouldn't is if the extent tree is corrupt or we have some sort of awful bug in the free space cache. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs-progs: do not enable extended refs in mkfs by defaultDavid Sterba2013-04-23
| | | | | | | | | | | This extref feature (lifting the single file hardlink limitation) is new and not backward compatible with older kernels that are still in wide use. For now, use btrfstune to enable the feature, in the future it will be possible to turn it on within mkfs by -O option. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: revert skinny extents changes from mkfsDavid Sterba2013-04-23
| | | | | | | We are going to unify enabling filesystem features via option -O. For now, use btrfstune to enable the features. Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: add skinny metadata support to progs V3Josef Bacik2013-04-23
| | | | | | | | | This fixes up the progs to properly deal with skinny metadata. This adds the -x option to mkfs and btrfstune for enabling the skinny metadata option. This also makes changes to fsck so it can properly deal with the skinny metadata entries. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs-progs: re-add send-testMark Fasheh2013-04-23
| | | | | | | | | | | | | send-test.c links against libbtrfs and uses the send functionality provided to decode and print a send stream to the console. 66819df "btrfs-progs: add send-test" contained this file when submitted, but somehow got lost on commit. [sandeen@redhat.com: Resurrect lost send-test.c from original commit] Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
* btrfs-progs: btrfs-select-super output is confusing when it failsAnand Jain2013-04-23
| | | | | | | | | | | | | | | Trivial patch: ./btrfs-progs/btrfs-select-super -s 0 /dev/sdc using SB copy 0, bytenr 65536 No valid Btrfs found on /dev/sdc Open ctree failed The line 'using..' is confusing which gives an indication that command is successful This patch will avoid that when command fails Signed-off-by: Anand Jain <anand.jain@oracle.com>
* btrfs-progs: mkfs should first check all disks before writing to a diskAnand Jain2013-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | In the cases where one of the disk is not suitable for btrfs, then we would fail the mkfs, however we determine that after we have written btrfs to the preceding disks. At this time if user changes mind for not to use btrfs will left with no choice. So this patch will check if all the provided disks are suitable for the btrfs at once before proceeding to create btrfs on a disk. Further this patch also removed duplicate code to check device suitability for the btrfs. Next, there is an existing bug about the -r mkfs option, which this patch would carry forward most of it. Ref: [PATCH 2/2, RFC] btrfs-progs: overhaul mkfs.btrfs -r option Signed-off-by: Anand Jain <anand.jain@oracle.com> to merg prev Signed-off-by: Anand Jain <anand.jain@oracle.com>
* btrfs-progs: no pending balance is not an errorAnand Jain2013-04-23
| | | | | | | | Having no balance running/ paused/completed is a normal situation, so the current output message should be positive with return val zero. Signed-off-by: Anand Jain <anand.jain@oracle.com>
* btrfs-progs: fix btrfs scrub start helpAnand Jain2013-04-23
| | | | | | a very trivial fix Signed-off-by: Anand Jain <anand.jain@oracle.com>
* btrfs-progs: delete unused function get_mountptAnand Jain2013-04-23
| | | | | | and get_btrfs_mount has replaced it Signed-off-by: Anand Jain <anand.jain@oracle.com>
* Btrfs-progs: Use /proc/mounts instead of /etc/mtabStefan Behrens2013-04-09
| | | | | | | | /etc/mtab is not working correctly in situations where multiple mount namespaces are used. Use /proc/mounts instead like the rest of the code is doing it. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: add btrfs-crc toolJan Schmidt2013-04-09
| | | | | | | | This tool can be used to compute btrfs' style crc32c checksums for filenames as done by the kernel. Additionally, there is -c mode to do a brute force search for file names with a given checksum. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
* btrfs-progs: add missing qgroup synopsis in btrfsZhi Yong Wu2013-04-09
| | | | Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
* btrfs-progs: fix one bracket issue in mkfs.btrfs manpageZhi Yong Wu2013-04-09
| | | | | | | | In "[ \fB\-f\fP\fI ]", the "\fI" will result in the front half "["of "[ -f ]" doesn't the back half "]"; When you issue the command "man mkfs.btrfs", you will see the difference. Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
* Btrfs-progs: make btrfs-image restore with a valid chunk tree V2Josef Bacik2013-04-09
| | | | | | | | | | | | | | | | | | | | Previously btrfs-image would set a METADUMP flag and would make one big system chunk to cover the entire file system in the super in order to get around the unpleasant business of having to adjust the chunk tree. This meant that you could use the progs stuff on a restored file system, which is great for testing btrfsck and other such things. But we want to be able to run the tree log replay on a file system that is not able to run the tree log replay. So in order to do this we need to fixup the super's chunk array and the chunk tree itself. This is pretty easy since we restore using the logical offsets of the metadata, so we just have to set the chunk items to have 1 stripe and have the stripes point at the primary device and then use the logical offset of the chunk as the physical offset. With this patch I can restore a file system image that had a tree log and mount the file system and have the log be replayed successfully. This patch also gives you the -o option in case you want the old restore way, in the case where we want to make sure the system chunks as they were given to us are correct. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* Btrfs-progs: make btrfs-image grab the free space cacheJosef Bacik2013-03-21
| | | | | | | | | A lot of tree log replay bugs are because of strange space cache setups, so make btrfs-image scrape the free space cache as well so we can better replicate what a user is seeing if they have a tree log bug or anything related to free space cache. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* Btrfs-progs: make btrfs-image copy the tree logs if they existJosef Bacik2013-03-21
| | | | | | | | | | Currently btrfs-image doesn't copy the tree logs, which doesn't help me when we're trying to debug log replay bugs. Since we don't have entries in the extent root for the blocks we have to walk down all of the trees in order to copy them. With this patch I can image a file system with a tree log and it works fine. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* Btrfs-progs: cleanup error handling in btrfs-imageJosef Bacik2013-03-21
| | | | | | | | | We use BUG_ON() everywhere in btrfs-image. When users are going to use this command things are pretty dire, so I'd rather have really good error messages so I know what happened rather than figure out which one of the 20 BUG_ON()'s made the stupid thing exit early. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* Btrfs-progs: tool to visualize fragmentationArne Jansen2013-03-19
| | | | | | | | | | | | | | | | | | | This tool draws per-chunk pngs representing the allocation map. A black or colored dot means the block is allocated. The output is written to a subdirectory, together with an index.html to be viewed in a browser. There are options to control whether color should be used and which block group types should be printed. To build, you need to have libpng and libgd installed. It is not part of the 'all' target, so please build it explicitely with make btrfs-fragments. A (rather untypical) example can be seen at http://sensille.com/fragments Please regard this as a first scratch version and feel free to improve it :) Signed-off-by: Arne Jansen <sensille@gmx.net>
* Btrfs-progs: make scrub IO priority configurableStefan Behrens2013-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The btrfs tool is changed in order to support command line parameters to configure the IO priority of the scrub tasks. Also the default is changed. The default IO priority for scrub is the idle class now. The behavior is the same as when one would type 'ionice ... btrfs scrub start ...' or 'ionice ... btrfs scrub resume ...' (without this patch applied). The only reason for adding this to the btrfs tool is that it was not documented and not obvious that it worked like this, that all internal scrub tasks inherited the IO priority values of the btrfs tool that is starting or resuming the scrub operation. Note that after applying the patch it is no longer possible to set the IO priority using ionice since the btrfs tool always configures the priority in order to run in the idle class by default. Some basic performance measurements have been done with the goal to measure which IO priority for scrub gives the best overall disk data throughput. The kernel was configured to use the CFQ IO scheduler with default configuration and without support for throttling. The summary is, that the more the disk head movements are avoided, the faster the overall disk transfer capacity is, which is not really a big surprise. Therefore it makes sense that the best data throughput was measured setting the scrub IO priority and the scrub readahead IO priority to the idle class priority. Running with idle class IO priority means that scrub and scrub readahead IO is paused while other tasks access the disk. Doing the tasks one after the other instead of concurrently avoids many disk head movements. The overall data throughput of rotating disks is improved this way. However, if it is desired to have the scrub task done within a reasonable time, and if at the same time the filesystem is heavily loaded, the idle IO priority should be avoided. Otherwise the scrub operation will never take place and thus never terminate. The best effort IO priority class with the subclass 7 (the lowest one in the best effort class) is recommended in the case of always heavily loaded hard disks. If the filesystem is not loaded all the time and leaves some idle slots for scrub, the idle class IO priority is recommended. The idle class now is the default if the scrub operation is started with the btrfs-progs tools. Note that the patch that sets the scrub readahead IO priority to the idle class is a seperate patch, this needs to be done in the kernel. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* btrfs-progs: makefile: clean static targetsDavid Sterba2013-03-19
| | | | | | | | | * create .static.o version from the library objects as well and use them for building static targets * remove build dependencies on libbtrfs.* * other minor cleanups Signed-off-by: David Sterba <dsterba@suse.cz>
* Removing btrfsctl, btrfs-vol, btrfs-showGoffredo Baroncelli2013-03-19
| | | | | | | | | | | | | | With the commit 002d021c (committed October 2011) btrfsctl, btrfs-vol, btrfs-show were declared deprecated. The last patches related to these commands are dated December 2010. These tools are replaced by the "btrfs" tool in all the functionality. This commit removes all the related code. Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it> Signed-off-by: David Sterba <dsterba@suse.cz>
* Makefile: allow user set LDFLAGS for libbtrfs.so as wellSergei Trofimovich2013-03-19
| | | | | | | | | | Detected by gentoo's QA checker: * QA Notice: Files built without respecting LDFLAGS have been detected * Please include the following list of files in your report: * /usr/lib/libbtrfs.so.0.1 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Btrfs-progs: fix memory leaks on cleanupJosef Bacik2013-03-18
| | | | | | | | | I've been working on btrfs-image and I kept seeing these leaks pop up on valgrind so I'm just fixing them. We don't properly cleanup the device cache, the chunk tree mapping cache, or the space infos on close. With this patch valgrind doesn't complain about any memory leaks running btrfs-image. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs-progs: defrag return zero on successAnand Jain2013-03-18
| | | | Signed-off-by: Anand Jain <anand.jain@oracle.com>
* Btrfs-progs: fix segfault when using tools fs with tree logJosef Bacik2013-03-18
| | | | | | | | | | We just free the log root after we set it up when we open a ctree in the tools. This isn't nice, it makes double free's and leaks eb's, makes segfaults with btrfs-image. So fix this to be correct, and fix the cleanup if the buffer is not uptodate. With this fix I no longer segfault trying to do btrfs-image on a file system with a log tree. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com>
* btrfs-progs: convert: access name_len and file_type the old wayDavid Sterba2013-03-18
| | | | | | | | | | | | We can't use ext2_dir_entry_2 typecast on big endian machines directly. The bytes do not get converted during extX block read due to missing flag EXT2_DIRBLOCK_V2_STRUCT passed down to ext2fs_read_dir_block4 from ext2fs_process_dir_block. Fixing on the ext2 side needs updating callers and (maybe) the library interfaces. We'll fix it on the convert side for now. CC: Jan Kara <jack@suse.cz> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: give restore a list roots optionJosef Bacik2013-03-18
| | | | | | | | Since restore has the ability to open really really screwed up file systems, add a list roots option to it so we can still get the contents of the tree root on a horribly broken fs. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* btrfs-progs: add lzo compression support to restoreJosef Bacik2013-03-18
| | | | | | This patch simply adds support to decompress lzo compressed extents in restore. Signed-off-by: Josef Bacik <josef@redhat.com>
* restore: Split output directory and btrfs-local path search_dir() parametersPeter Stuge2013-03-18
| | | | | | | | | | | | search_dir() recurses down the btrfs tree, and used to take the output path for every item (i.e. in the running system, output root directory concatenated with btrfs-local pathname) passed as the only path parameter. Moving the output root directory to a separate parameter and passing the btrfs-local pathname for each file and directory separately allows easy filtering based on the btrfs-local pathname. Signed-off-by: Peter Stuge <peter@stuge.se> Signed-off-by: Josef Bacik <josef@redhat.com>