summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: move test_isdir() to utils.cSatoru Takeuchi2014-08-22
| | | | | | | | | | | | Since test_isdir() is a utility function, it's better to move it to utils.c. In addition, "const char *" is more appropriate type as its "path" argument because this argument is not changed in this function. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Cc: David Sterba <dsterba@suse.cz> Cc: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: introduce test_issubvolname() for simplicitySatoru Takeuchi2014-08-22
| | | | | | | | | | | There are many duplicated codes to check if the given string is correct subvolume name. Introduce test_issubvolname() for this purpose for simplicity. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Cc: David Sterba <dsterba@suse.cz> Cc: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add mount status check for btrfs-imageGui Hecheng2014-08-22
| | | | | | | | | | | When btrfs-image run on a mounted filesystem, the undergoing fs operations may change what you have imaged a while ago. In this case, give a warning to remind the user that he may not get a consistent image he wants. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> [tweaked the message] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: remove unnecessary NULL check after get_df()Satoru Takeuchi2014-08-22
| | | | | | | | If get_df() returns 0, "sargs" surely points to malloc'ed region. So NULL check of sargs is not necessary. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix improper return value check for is_existing_blk_or_reg_fileGui Hecheng2014-08-22
| | | | | | | | | | | | | The function @is_existing_blk_or_reg_file has a return value of -errno, which indicate the @stat call fails with non-ENOENT errors. In this condition, we should not continue the following work. But -errno evaluates to true and will let the following work go. So we should judge more accurately whether the return value of @is_existing_blk_or_reg_file is > 0 or not to decide our behavior. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: remove unnecessary return value check in btrfs-propertyGui Hecheng2014-08-22
| | | | | | | | The function @parse_prop() returns either -1 or 0, no need to check for other values. Just return the unnecessary check. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: init variables which are checked later in btrfs-propertyGui Hecheng2014-08-22
| | | | | | | | | | The local variable @object etc. in btrfs-property get/set functions are to be checked whether to be NULL or not, but the @parse_args() don't guarantee to assign a value to it, so it is better to init it to NULL. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: mkfs: remove experimental tagDavid Sterba2014-08-22
| | | | | | | Make it consistent with kernel status and documentation. Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add always option to restore's looping promptJustin Maggard2014-08-22
| | | | | | | | | | | | | If you are using btrfs restore to try to recover a very large or fragmented file, you may encounter _lots_ of prompts requiring you to press 'y' to continue because we are looping a lot. Add the option to press 'a', to supress these prompts for the rest of the file. Signed-off-by: Justin Maggard <jmaggard10@gmail.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix some build warnings on 32bit platformWang Shilong2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix following build warnings on 32bit platform: ... utils.c:1708:3: warning: left shift count >= width of type [enabled by default] if (x << i & (1UL << 63)) ^ qgroup-verify.c:393:9: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] return (struct tree_block *)unode->aux; ^ qgroup-verify.c:407:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] if (ulist_add(tree_blocks, bytenr, (unsigned long long)block, 0) >= 0) ^ cmds-restore.c:120:4: warning: format %lu expects argument of type long unsigned int, but argument 3 has type size_t [-Wformat=] fprintf(stderr, "bad compress length %lu\n", in_len); ... BTW, this patch also switches other castings with new helpers. Signed-off-by: Wang Shilong <wangshilong1991@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Unify the messy error message formatsSatoru Takeuchi2014-08-22
| | | | | Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: remove author and copyright info from man pageWang Shilong2014-08-22
| | | | | | | | | | | | | | | | | | | >From: http://man7.org/linux/man-pages/man7/man-pages.7.html ... AUTHORS lists authors of the documentation or program.Use of an AUTHORS section is strongly discouraged. Generally, it is better not to clutter every page with a list of (over time potentially numerous) authors; if you write or significantly amend a page, add a copyright notice as a comment in the source file. If you are the author of a device driver and want to include an address for reporting bugs, place this under the BUGS section. ... Suggested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: Wang Shilong <wangsl.fnst@cn.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: fix wrong manpage of defrag commandLiu Bo2014-08-22
| | | | | | | | | | | | | | | | | | | | | | 'btrfs filesystem defrag' has an option '-t', whose manpage says "Any extent bigger than threshold given by -t option, will be considered already defragged. Use 0 to take the kernel default, and use 1 to say every single extent must be rewritten." Here 'use 0' still works, it refers to the default value(256K), however, 'use 1' is an obvious typo, it should be -1, which means the largest value it can be. Right now, we use parse_size() which no more allow value '-1', so in order to keep the manpage correct, this updates it to only keep value '0'. If you want to make sure every single extent is rewritten, please use a fairly large size, say 1G. Reported-by: Sebastian Ochmann <ochmann@informatik.uni-bonn.de> Signed-off-by: Liu Bo <bo.li.liu@oracle.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: Add uninstall targets to Makefiles.Nils Steinger2014-08-22
| | | | | Signed-off-by: Nils Steinger <git@n-st.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: replace a confusing raw number with a macroGui Hecheng2014-08-22
| | | | | | | | | The raw number 36 for the uuid string length is somewhat confusing, use a macro to define replace it. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> [Use BTRFS_UUID_UNPARSED_SIZE] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix wrong message about forcing the mixed group profileAnand Jain2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | When the added disk is small, the function btrfs_prepare_device() would print message indicating that mixed group is forced, apparently thats not true reproducer: mkfs.btrfs -f -draid1 -mraid1 /dev/sdd /dev/sdc :: SMALL VOLUME: forcing mixed metadata/data groups <---- WRONG mount /dev/sdd /btrfs btrfs fi df /btrfs Data, RAID1: total=126.25MiB, used=128.00KiB Data, single: total=8.00MiB, used=0.00B System, RAID1: total=8.00MiB, used=16.00KiB System, single: total=4.00MiB, used=0.00B Metadata, RAID1: total=126.25MiB, used=112.00KiB Metadata, single: total=8.00MiB, used=0.00B GlobalReserve, single: total=16.00MiB, used=0.00B Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix build of static targetDavid Sterba2014-08-22
| | | | | | | | | | | | | A user repoted that static buid fails with utils-lib.static.o: In function `arg_strtou64': /home/dsterba/labs/btrfs-progs/utils-lib.c:17: multiple definition of `arg_strtou64' utils-lib.static.o:/home/dsterba/labs/btrfs-progs/utils-lib.c:17: first defined here utils-lib.o was mistakenly added to linker twice. Signed-off-by: David Sterba <dsterba@suse.cz> Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
* btrfs-progs: correct manpage option description for scrubGui Hecheng2014-08-22
| | | | | | | | | | | | | | | | | | The -f option of scrub means to "force starting new scrub even if a scrub is already running" *not* "force to check whether scrub has started or resumed in userspace" as described originally. So replace the orignal description in the manpage and code. Also, add description of the potential failure as follows "If a scrub is already running, it fails." Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Cc: David Sterba <dsterba@suse.cz> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: remove unnecessary judgment for fd in scrubGui Hecheng2014-08-22
| | | | | | | | | The scrub_read_file function is always on a branch, which has (fd >= 0), so there is not need to judgment the pasted in arg. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: adjust the return values for scrubGui Hecheng2014-08-22
| | | | | | | | | | | o Return 0 to indicate success, when detected errors were corrected during scrubbing. P.s. This is also to facilitate scripting when return value is to be checked. o Warn the users if there are uncorrectable errors detected. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: mkfs: don't zero extend small filesZach Brown2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mkfs can try to write outside of small devices. The zeroing code doesn't test the device size and runs before mkfs tests for small devices and exits. Testers experienced this as small regular files being extended as mkfs failed: $ truncate -s 1m /tmp/some-file $ strace -epwrite ./mkfs.btrfs /tmp/some-file SMALL VOLUME: forcing mixed metadata/data groups WARNING! - Btrfs v3.14.2 IS EXPERIMENTAL WARNING! - see http://btrfs.wiki.kernel.org before using pwrite(3, ..., 2097152, 0) = 2097152 pwrite(3, ..., 4096, 65536) = 4096 pwrite(3 ..., 2097152, 18446744073708503040) = -1 EINVAL (Invalid argument) ERROR: failed to zero device '/tmp/some-file' - Input/output error $ ls -lh /tmp/some-file -rw-rw-r--. 1 zab zab 2.0M Jul 16 13:49 /tmp/some-file This simple fix adds a helper that clamps a region to be zeroed to the size of the device. It doesn't address the larger questions of whether to modify the device before the size test or whether or zero regions that have been trimmed. Finally, the error handling mess after the zeroing calls is cleaned up. zero_blocks() and its callers only return -errno. Signed-off-by: Zach Brown <zab@zabbo.net> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: define BTRFS_MKFS_SMALL_VOLUME_SIZE for small volumeAnand Jain2014-08-22
| | | | | | | | mkfs cut of size '1024 * 1024 * 1024' to mark dev as small volume so to force mixed group. Use a define for that. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: dont break the stringAnand Jain2014-08-22
| | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: doc: fix incorrect subvol nameTsutomu Itoh2014-08-22
| | | | | | | Subvolume name is wrong. Fix it. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: ignore orphaned qgroups by defaultMark Fasheh2014-08-22
| | | | | | | | | | | | | | | qgroup items are not deleted by btrfs when the underlying subvolume goes away. As a result, btrfsck will print those as inconsistent. This can clutter up the printout so we ignore them by default. They are still printed if a full report (via --qgroup-report) is requested. This patch and the ones it depends on (to do qgroup verification) can be found at: https://github.com/markfasheh/btrfs-progs-patches/tree/qgroup-verify Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix Segmentation fault of btrfs-convertLiu Bo2014-08-22
| | | | | | | | | | Recently we merge a memory leak fix, which fails xfstests/btrfs/012, the cause is that it only frees @fs_devices but leaves it on the global fs_uuid list, which cause a 'Segmentation fault' over running command btrfs-convert. This fixes the problem. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Allow btrfs_read_dev_super() to read all 3 super for super_recover.Qu Wenruo2014-08-22
| | | | | | | | | | | | | | Btrfs-progs superblock checksum check is somewhat too restricted for super-recover, since current btrfs-progs will only read the 1st superblock and if you need super-recover the 1st superblock is possibly already damaged. The fix is introducing super_recover parameter for btrfs_read_dev_super() and callers to allow scan backup superblocks if needed. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: show extent state for a subvolumeMark Fasheh2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The qgroup verification code can trivially be extended to provide extended information on the extents which a subvolume root references. Along with qgroup-verify, I have found this tool to be invaluable when tracking down extent references. The patch adds a switch to the check subcommand '--subvol-extents' which takes as args a single subvolume id. When run with the switch, we'll print out each extent that the subvolume references. The extent printout gives standard extent info you would expect along with information on which other roots reference it. Sample output follows - this is a few lines from a run on a subvolume I've been testing qgroup changes on: Print extent state for subvolume 281 on /dev/vdb2 UUID: 8203ca66-9858-4e3f-b447-5bbaacf79c02 Offset Len Root Refs Roots 12582912 20480 12 257 279 280 281 282 283 284 285 286 287 288 289 12603392 8192 12 257 279 280 281 282 283 284 285 286 287 288 289 12611584 12288 12 257 279 280 281 282 283 284 285 286 287 288 289 <snip a bunch of extents to show some variety> 124583936 16384 4 281 282 283 280 125075456 16384 4 280 281 282 283 126255104 16384 11 257 280 281 282 283 284 285 286 287 288 289 4763508736 4096 3 279 280 281 In case it wasn't clear, this applies on top of my qgroup verify patch: "btrfs-progs: add quota group verify code" A branch with all this can be found on github: https://github.com/markfasheh/btrfs-progs-patches/tree/qgroup-verify Please apply, Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: limit minimal num of args for btrfs-imageGui Hecheng2014-08-22
| | | | | | | | | | | The btrfs-image requires at least 2 args to run, one for the source dev/file, the other for the target dev/file. This patch depends on patch: btrfs-progs: move the check_argc_* functions into utils.c Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: move the check_argc_* functions into utils.cGui Hecheng2014-08-22
| | | | | | | | | | | | | | To let the independent tools(e.g. btrfs-image, btrfs-convert, etc.) share the convenience of check_argc_* functions, just move it into utils.c. Also add a new function "set_argv0" to set the correct tool name: *btrfs-image*: too few arguments The original btrfs* tools work as before. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> [moved argv0 and check_argc to utils.*] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: balance filter: add limit of processed chunksDavid Sterba2014-08-22
| | | | | | | | | | | | | | | Add more control to the balance behaviour. Usage filter may not be finegrained enough and can lead to moving too many chunks at once. Another example use is in connection with drange+devid or vrange filters that allow to work with a specific chunk or even with a chunk on a given device. The limit filter applies last, the value of 0 means no limiting. CC: Ilya Dryomov <idryomov@gmail.com> CC: Hugo Mills <hugo@carfax.org.uk> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add X inode flag to btrfs(5)David Sterba2014-08-22
| | | | | | | | | | After the discussion in http://thread.gmane.org/gmane.comp.file-systems.btrfs/36334 the 'X' will be mentioned in the manpage because new e2fsprogs/lsattr will display it and represents the NOCOMPRESS bit of an inode. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: cleanup unnecessary free if malloc fails in btrfs-imageGui Hecheng2014-08-22
| | | | | | | Don't bother free the buffer if the malloc failed. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fsck: reduce memory usage for extents checkWang Shilong2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Steps to reproduce: # mkfs.btrfs -f /dev/sda9 -b 2g # mount /dev/sda9 /mnt # dd if=/dev/zero of=/mnt/data bs=4k oflag=direct # btrfs file df /mnt Data, single: total=1.66GiB, used=1.66GiB System, single: total=4.00MiB, used=16.00KiB Metadata, single: total=200.00MiB, used=67.88MiB For a filesystem without snapshots, 70M metadata, extent checking eats max memory about 110M, this is a nightmare for some system with low memory. It is very likely that extent record can be freed quickly for a filesystem without snapshots, improve this by trying if it can free memory after adding data/tree backrefs. This patch reduces max memory cost from 110M to 40M for extents checking for the above case. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix btrfs-image old_restore fsck failureGui Hecheng2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Steps to reproduce: # mkfs.btrfs -f <dev1> # btrfs-image <dev1> <image_file> # btrfs-image -r -o <image_file> <dev2> # btrfs check <dev2> btrfs check output: : read block failed check_tree_block : Couldn't read tree root : Couldn't open file system The btrfs-image should not mess with the chunk tree under the old_restore way. The new restore way was introduced by: commit d6f7e3da0dae7b60cb7565f8a47c3b9045c52d1d Btrfs-progs: make btrfs-image restore with a valid chunk tree V2 ... And the following commit enhanced the new restore on the valid chunk tree building stuff: commit ef2a8889ef813ba77061f6a92f4954d047a78932 Btrfs-progs: make image restore with the original device offsets ... But the second commit should not effect the old_restore way since the old_restore way doesn't try to build a valid chunk tree at all. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Avoid double-free of fs_devices->listSatoru Takeuchi2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found the following patch is insufficient. =============================================================================== commit 6e6b32ddf58db54f714d0f263c2589f4859e8b5e Author: Adam Buchbinder <abuchbinder@google.com> Date: Fri Jun 13 16:43:56 2014 -0700 btrfs-progs: Fix a use-after-free in the volumes code. =============================================================================== "btrfs filesystem show <dev>" with this patch causes segmentation fault if "<dev>" is a not-mounted Btrfs filesystem. =============================================================================== Label: none uuid: <cut here> Total devices 1 FS bytes used 112.00KiB devid 1 size 59.12GiB used 2.04GiB path /dev/sdd1 Segmentation fault (core dumped) =============================================================================== It's due to double-free of fs_devices->list as follows. =============================================================================== cmd_show -> list_del(&fs_devices->list) # 1st one. -> btrfs_close_devices(fs_devices) -> list_del(&fs_devices->list) # <- 2nd one introduced at 6e6b32dd. Double-free happens here. =============================================================================== First list_del() can safely be removed because fs_devices->list will be deleted by second one, soon. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Cc: Adam Buchbinder <abuchbinder@google.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use BTRFS_SUPER_INFO_SIZE to replace raw 4096 in btrfs-imageGui Hecheng2014-08-22
| | | | | Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: cleanup possible silent failure in btrfs-imageGui Hecheng2014-08-22
| | | | | | | | | | If the malloc above fails, the btrfs-image will exit directly without any error messages. Now just return the ENOMEM errno and let the caller prompt the error message. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: deal with malloc failure in btrfs-imageGui Hecheng2014-08-22
| | | | | | | | Handle the malloc failure for dump_worker in the same way as the restore worker. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: replace BTRFS_NUM_MIRRORS with BTRFS_MAX_MIRRORSGui Hecheng2014-08-22
| | | | | | | | | | | | | | | The chunk-recover.c/BTRFS_NUM_MIRRORS in the userspace means the same thing as ctree.h/BTRFS_MAX_MIRRORS in the kernelspace, so to stay consistent with the kernelspace, just make this movement in the userspace: chunk-recover.c/BTRFS_NUM_MIRRORS ===> ctree.h/BTRFS_MAX_MIRRORS This provides convenience for future use. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add supported attr flags to btrfs(5)Eric Sandeen2014-08-22
| | | | | | | | | | | | | | | The chattr(1) manpage suffers from the same problems mount(1) had: many options listed, not kept up to date for various filesystems. I've submitted a manpage update for chattr(1) which says to refer to filesystem-specific manpages for supported attributes; this patch updates btrfs(5) to list the attributes supported by btrfs. Signed-off-by: Eric Sandeen <sandeen@redhat.com> [added some asciidoc markups, adjusted formatting] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add minimum device size checkQu Wenruo2014-08-22
| | | | | | | | | | | | | | | | | | | Btrfs has global block reservation, so even mkfs.btrfs can execute without problem, there is still a possibility that the filesystem can't be mounted. For example when mkfs.btrfs on a 8M file on x86_64 platform, kernel will refuse to mount due to ENOSPC, since system block group takes 4M and mixed block group takes 4M, and global block reservation will takes all the 4M from mixed block group, which makes btrfs unable to create uuid tree. This patch will add minimum device size check before actually mkfs. The minimum size calculation uses a simplified one: minimum_size_for_each_dev = 2 * (system block group + global block rsv) and global block rsv = leafsize << 10 Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: check: Fix wrong level accessHugo Mills2014-08-22
| | | | | | | | | | There's no reason to assume that the bad key order is in a leaf block, so accessing level 0 of the path is going to be an error if it's actually a node block that's bad. Reported-by: Chris Mason <clm@fb.com> Signed-off-by: Hugo Mills <hugo@carfax.org.uk> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fsck: add tests for extent tree rebuildingWang Shilong2014-08-22
| | | | | | | | | | | | We need test to verify extent tree rebuilding work, this test create a strange filesystem with some snapshots, destroy extent root node, and run fsck with "--init-extent-tree". Since this tests need btrfs internal tool(btrfs-corrupt-block),so i add this test into btrfs-progs. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: delete invalid output file when btrfs-image failedGui Hecheng2014-08-22
| | | | | | | | When btrfs-image failed to create an image, the invalid output file had better be deleted to prevent being used mistakenly in the future. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: deal with invalid option combinations for btrfs-imageGui Hecheng2014-08-22
| | | | | | | | | | | | For btrfs-image, dump may not come with option '-o' -r may not come with option '-c', '-s', '-w', dev_cnt != 1 -m may not come with dev_cnt < 2 All of the above should be regarded as invalid combinations, and the usage will show up. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: update manpage for btrfs-image with -m option addedGui Hecheng2014-08-22
| | | | | | | The btrfs-image support multiple devices with -m specified. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>