summaryrefslogtreecommitdiff
path: root/btrfstune.c
Commit message (Collapse)AuthorAge
* btrfs-progs: Add all missing btrfs_close_all_devices to standalone toolsZhao Lei2015-11-02
| | | | | | | | This patch add all missing btrfs_close_all_devices() to standalone tools in btrfs progs, to avoid memory leak. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: btrfstune: remove unnecessary fsid checksDavid Sterba2015-09-02
| | | | | | | | | The new fsid members were switched from dynamically allocated to on-stack in e737a9d56b2cec644f1462bf540cb78f858d146d ("btrfs-progs: btrfstune: rework change_uuid"), we don't have to do the checks in the helpers. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: btrfstune: print correct current uuid during rewriteDavid Sterba2015-06-18
| | | | | | | | uuid_unparse is supposed to take the ASCII representation of a UUID, so we have to pass the raw fsid buffer. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: print lowercase uuid during uuid rewriteDavid Sterba2015-06-18
| | | | | | | We're using lowercase everywhere else. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: accept --help as option in the standalone utilitiesDavid Sterba2015-06-11
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: make uuid rewrite progress more verboseDavid Sterba2015-06-03
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: add option to enable NO_HOLESDavid Sterba2015-06-03
| | | | | | New option -n to enable the NO_HOLES feature. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: rework option handlingDavid Sterba2015-06-03
| | | | | | Simplify the code, gather the incompat flag bits and set them at once. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: add '-U' and '-u' option to change fsidQu Wenruo2015-05-26
| | | | | | | | | | | | | | | | | Add two options, '-U' and '-u' for btrfstune. For '-u', it is used to change fsid to a random new UUID. For '-U', it is used to change fsid to a specified UUID. Both will also change the internal use only chunk_tree_uuid to a random new UUID. Although there is a GNU getopt extension "::" to get optional option-argument, but is forbidden by POSIX.1-2008, so use split options here. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: add ability to restore unfinished fsid changeQu Wenruo2015-05-26
| | | | | | | | Now change_uuid() can auto detected unfinished fsid change and restore it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: rework change_uuidQu Wenruo2015-05-26
| | | | | | | | | | | | | | | | | | | Change the change_uuid(): 1) Remove new_chunk_tree_uuid parameter As chunk_tree_uuid is only internal used, no need to manual specify it. Use random generated UUID instead. 2) Don't use heap allocated memory for fs_info->new_fsid/chunk_tree_id. It's easy to forgot free or double free heap memory. Use stack memory instead. (In fact, I forgot to free them in previous patchset) 3) Print destination fsid. As now it's possible to change fsid to random uuid, it's better to print it out. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_uuid functionQu Wenruo2015-05-14
| | | | | | | This function does all the needed things for changing filesystem uuid. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_fsid_prepare and change_fsid_done functionsQu Wenruo2015-05-14
| | | | | | | | | | These two functions will write flags to all supers before and after fsid/chunk tree id change, informing kernel not to mount a inconsistent fs. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [removed chunk tree super flag] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_devices_uuid function.Qu Wenruo2015-05-14
| | | | | | | This function will change all device items' fsid. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_device_uuid functionQu Wenruo2015-05-14
| | | | | | | This function changes a device items uuid. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_extents_uuid functionQu Wenruo2015-05-14
| | | | | | | | | | This is the function which iterates all metadata extents and changes their fsid. This function also does it without transaction. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_header_uuid functionQu Wenruo2015-05-14
| | | | | | | | | | This function is used to change fsid and chunk_tree_uuid of a node/leaf. The function does it without transaction protection. This is the basis of offline uuid change. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: autoconf: use standard PACKAGE_* macrosKarel Zak2015-01-28
| | | | | | | | | | | | | - use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros rather than homemade BTRFS_BUILD_VERSION - don't #include version.h, now the file is necessary for library API only Note that "btrfs version" returns "btrfs-progs <version>" instead of the original confusing "btrfs <version>". Signed-off-by: Karel Zak <kzak@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: drop feature defines from C files, in favour of CFLAGS definesDimitri John Ledkov2015-01-27
| | | | | | | | | | | | | | | | | | | | | | glibc 2.10+ (5+ years old) enables all the desired features: _XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a single _GNU_SOURCE define in the makefile alone. For portability to other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also defined. This also resolves Debian bug report filed by Michael Tautschnig - "Inconsistent use of _XOPEN_SOURCE results in conflicting declarations". Whilst I was not able to reproduce the results, the reported fact is that _XOPEN_SOURCE set to 500 in one set of files (e.g. cmds-filesystem.c) generates/defines different struct stat from other files (cmds-replace.c). This patch thus cleans up all feature defines, and sets them at a consistent level. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969 Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: force to set seeding flagsFan Chengniang2015-01-19
| | | | | | | | | | Now we can use -f with -S option when setting seeding flags or clearing seeding flags Reported-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> [updated docs] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: fix multiple options errorFan Chengniang2015-01-14
| | | | | | | | | | | | | | when we use multiple options, error return status will be override by the last option status. example: btrfstune -S 1 -r /dev/loop0 when -S option fails and -r option succeeds, return value is 0, rather than 1, where 1 is the right return status. Reported-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com> Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add ask_user confirmation for btrfstune clear seeding flagGui Hecheng2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we do the following: # mkfs.btrfs -f <dev> # mount <dev> <mnt> # dd if=/dev/urandom of=<mnt>/data bs=1M count=100 # umount <dev> # btrfstune -S 1 <dev> <--- make seeding device # mount <dev> <mnt> # btrfs dev add -f <dev2> <mnt> # umount <dev> # btrfstune -S 0 <dev> <--- clear seeding flag # mount <dev2> <mnt> <=== new device not mountable When mounting the new device, btrfs will check whether the seeding flag is set when try to open seeding device. If the user clears the seeding flag of the seeding device, the new device will not be mountable. Even set the seeding flag back will not recovery this problem, because the generation has been changed. So clear the seeding flag has the chance to damage the derived new fs. So I add user confirmation check when clearing seeding flag. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use check_argc_* to check arg number for all toolsGui Hecheng2014-08-22
| | | | | | | | | | | | Since this patch: btrfs-progs: move the check_argc_* functions into utils.c All tools including the independent tools(e.g. btrfs-image, btrfs-convert) can share the convenience of the check_argc_* functions, so this patch adopt the argc check functions globally. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: clarify manpage for btrfstune seeding optionGui Hecheng2014-08-22
| | | | | | | | | | The btrfstune -S option accepts a positive value to enable seeding, and a zero to disable seeding, negtive is not allowed. Add "positive, zero, negative" sentences to btrfstune manpage. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: judge the return value of check_mounted more accuratelyGui Hecheng2014-03-21
| | | | | | | | | | | | | | | For btrfs-convert, btrfstune, btrfs rescue, they report "device busy" when given a device that does not actually exist e.g. # btrfstune -x abcdefg (this device does not exist) $ ...device busy... We deal with this case by add "ret < 0" error check when judging the return value of check_mounted. 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: switch to arg_strtou64() part3Wang Shilong2014-03-21
| | | | | | | | | Switch to new helper arg_strtou64(), also check if user assign a valid super copy. 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: fix btrfstune silence on failureGui Hecheng2014-01-31
| | | | | | | | | | | | Originally, btrfstune will fail without any options, like this: # btrfstune /dev/sdb An error prompt & usage should show up upon this condition. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: rework open_ctree to take flags, add a new one V2Josef Bacik2013-11-07
| | | | | | | | | | | So I needed to add a flag to not try to read block groups when doing --init-extent-tree since we could hang there, but that meant adding a whole other 0/1 type flag to open_ctree_fs_info. So instead I've converted it all over to using a flags setting and added the flag that I needed. This has been tested with xfstests and make test. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* 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: 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: 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: separate super_copy out of fs_infoDavid Sterba2013-03-10
| | | | | | | | | 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>
* btrfsprogs: btrfstune support for extended inode refsMark Fasheh2013-02-21
| | | | | | | | 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>
* btrfs-progs: Handle errors returned from open_ctreeDanny Kukawka2013-01-21
| | | | | Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* update btrfs-progs for seed device supportYan Zheng2008-11-18
This patch does the following: 1) Update device management code to match the kernel code. 2) Allocator fixes. 3) Add a program called btrfstune to set/clear the SEEDING super block flags.