aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2016-01-18Btrfs progs v4.4HEADv4.4masterDavid Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-15btrfs-progs: docs: update balance manual pageDavid Sterba1-31/+37
Make the new balance filters' syntax more explicit. Other rewording and reformatting. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-15btrfs-progs: debug-tree: tweak tree node checksDavid Sterba1-2/+2
The tree root and chunk root base pointers are verified in open_ctree so we don't get NULL here. We still check the node pointers to get better error message. Resolves-coverity-id: 1348450 Resolves-coverity-id: 1348451 Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-15btrfs-progs: fix static buildNoah Massey1-2/+2
Change in "btrfs-progs: introduce helper for parsing args without options" added a dependency on help.o that was duplicated for the static build. Signed-off-by: Noah Massey <noah.massey@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: Use AC_CHECK_TOOL to find ARMike Gilbert1-1/+1
AC_CHECK_TOOL takes the --host option into account for cross-compiling. Signed-off-by: Mike Gilbert <floppym@gentoo.org> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14Btrfs progs v4.4-rc1v4.4-rc1David Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: subvol show: use clean_args_no_options instead of opencodingDavid Sterba1-14/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: introduce helper for parsing args without optionsDavid Sterba3-3/+32
All commands should support the "--" option separator. This is transparently handled by getopt, but we don't use that everywhere. Introduce a helper for commands that take no options (just the path). The object file dependencies need to be adjusted a bit. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: move prefixcmp to utilsDavid Sterba2-9/+10
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: receive: don't leak open find handleDavid Sterba1-0/+2
Resolves-coverity-id: 1348121 Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: also check filesystem type in test_issubvolumeDavid Sterba1-2/+11
A subvolume is a directory with inode number 256 on a btrfs filesytem. Add the missing check to test_issubvolume for completeness, otherwise we always do that in btrfs_open_dir. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: more verbose errors from test_issubvolumeDavid Sterba2-5/+6
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: let test_issubvolume return the exact errorDavid Sterba2-9/+9
Return any error from stat, minor cleanups. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: use symbolic name for subvolume inode number in test_issubvolumeDavid Sterba1-1/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14btrfs-progs: handle errors from test_isdirDavid Sterba1-0/+8
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-13btrfs-progs: let test_isdir return the exact errorDavid Sterba1-8/+8
Return any error from stat, normalize the return value in case the path is a directory. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-13btrfs-progs: debug-tree: teach -t option about the chunk and root treesDavid Sterba1-0/+23
A user on IRC wanted to dump the chunk tree using the -t option. As the -t option enumerates only trees pointed by the tree_root, the chunk tree is skipped. Similar for th tree of tree roots. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-13btrfs-progs: subvol show: handle options by getoptDavid Sterba1-3/+18
The subvolume show command does not take any optios but at least it should honor "--", as reported. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110181 Reported-by: <moviuro+kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-13btrfs-progs: fi usage: support mixed blockgroupsDavid Sterba1-6/+20
Properly account the duplicated block groups and global reserve. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110111 Reported-by: Chris Murphy <bugzilla@colorremedies.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs: enhance btrfs-filesystem manual pageDavid Sterba1-39/+175
Wording, formatting, explanations, examples. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: tests: add missing prerequisitesDavid Sterba16-4/+29
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-porgs: fi usage: rename variable to avoid shadowingDavid Sterba1-2/+2
Reported by gcc -Wshadow . Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-porgs: check: rename variable to avoid shadowingDavid Sterba1-4/+4
Reported by gcc -Wshadow . Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-porgs: qgroup: rename variable to avoid shadowingDavid Sterba1-3/+3
Reported by gcc -Wshadow . Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: add function attributes for the printf-likeDavid Sterba2-0/+5
Reported by gcc -Wsuggest-attribute=format . Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: build: fix builds with extra warnings, W=1David Sterba1-1/+1
Wrong variable name used in the main makefile. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: check for negative return value from ioctlDavid Sterba11-20/+24
Handle only negative values returned by ioctl syscalls, with exception of the device remove. It returns positive values that are handled later. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: remove unnecessary errno temp variablesDavid Sterba12-69/+35
We can read errno directly if it's not clobbered by any intermediate calls. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: free-space-tree: minor message adjustmentsDavid Sterba1-6/+12
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfsprogs: corrupt-blocks: include limits.h to define PATH_MAXKhem Raj1-0/+1
limits.h is needed for PATH_MAX definition Fixes | btrfs-corrupt-block.c: In function 'corrupt_dir_item': | btrfs-corrupt-block.c:478:12: error: 'PATH_MAX' undeclared (first use in this function) | char name[PATH_MAX]; Signed-off-by: Khem Raj <raj.khem@gmail.com> [ minor changelog edits ] Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs: document new mount option fragmentDavid Sterba1-0/+8
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs: sort mount options alphabeticallyDavid Sterba1-65/+68
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: check the free space tree in btrfsckOmar Sandoval10-8/+459
This reuses the existing code for checking the free space cache, we just need to load the free space tree. While we do that, we check a couple of invariants on the free space tree itself. This requires pulling in some code from the kernel to exclude the super stripes. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: add basic awareness of the free space treeOmar Sandoval4-2/+92
To start, let's tell btrfs-progs to read the free space root and how to print the on-disk format of the free space tree. However, we're not adding the FREE_SPACE_TREE read-only compat bit to the set of supported bits because progs doesn't know how to keep the free space tree consistent. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs: rename btrfs-mount to btrfs-man5David Sterba2-5/+5
The page does will not contain only mount options but other stuff. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs, btrfs-mount: enhance file attributes sectionDavid Sterba1-14/+43
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cleanup, move usage help strings closer to the command callbacksDavid Sterba3-46/+46
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd property: use correct usage stringsDavid Sterba1-2/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd fi usage: switch to common error message wrapperDavid Sterba1-25/+18
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd filesystem: switch to common error message wrapperDavid Sterba1-42/+28
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd replace: switch to common error message wrapperDavid Sterba1-23/+14
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd subvolume: switch to common error message wrapperDavid Sterba1-59/+41
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd send: switch to common error message wrapperDavid Sterba1-73/+44
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd receive: switch to common error message wrapperDavid Sterba1-114/+78
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd qgroup: switch to common error message wrapperDavid Sterba1-15/+10
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd property: switch to common error message wrapperDavid Sterba1-20/+14
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd balance: switch to common error message wrapperDavid Sterba1-62/+40
Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd quota: switch to common error message wrapperDavid Sterba1-5/+3
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: cmd rescue: switch to common error message wrapperDavid Sterba1-12/+10
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: catch memory allocation failure in btrfs_split_itemDavid Sterba1-0/+1
Do the dumb BUG_ON now, the function needs more changes to handle all errors. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: handler memory allocation failure in add_extent_recDavid Sterba1-0/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: catch memory allocation failure from alloc_data_backrefDavid Sterba1-1/+6
Do the dumb BUG_ON now, the function needs more changes to handle all errors. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: catch memory allocation failure from alloc_tree_backrefDavid Sterba1-1/+6
Do the dumb BUG_ON now, the function needs more changes to handle all errors. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: catch memory allocation failure in splice_shared_nodeDavid Sterba1-0/+1
Do the dumb BUG_ON now, the function needs more changes to handle all errors. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: handle errors in get_inode_backref and fail in the callerDavid Sterba1-0/+3
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: handle errors in get_root_backref and fail in the callerDavid Sterba1-0/+3
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: return errors from get_root_rec, fail in callersDavid Sterba1-1/+8
get_root_rec return value is enahanced, callers will just BUG_ON now and will be fixed one by one. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: handle errors in add_shared_node and fail in the callerDavid Sterba1-3/+7
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: return errors from clone_inode_rec, fail in callersDavid Sterba1-2/+30
clone_inode_rec return value is enahanced, callers will just BUG_ON now and will be fixed one by one. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: return errors from get_inode_rec, fail in callersDavid Sterba1-1/+15
get_inode_rec return value is enahanced, callers will just BUG_ON now and will be fixed one by one. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs, enhance the mount option manual pageDavid Sterba1-95/+197
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs, btrfs-mount: enhance fatal_errosDavid Sterba1-2/+7
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs, btrfs-mount: put NOTE tag to new paragraphDavid Sterba1-0/+1
Otherwise it's not rendered properly. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: docs, btrfs-mount: unindent descriptionsDavid Sterba1-135/+135
Asciidoc ignores special keywords like WARNING or NOTE if they're not at the beginning of the line and they're not renedered very visibly in the end. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: document snapshot unaware defragChristoph Anton Mitterer2-4/+14
In btrfs-filesystem(8), improved the documentation of snapshot unaware defragmentation and included the exact kernel version numbers being affected as well as the possible effects. No longer use the word "unlink" which is easily understood as "deleting a file". Moved the warning more to the beginning of "defragment" subcommand's documentation where it's more visible to readers. Added the same warning to the "autodefrag" option of btrfs-mount(5). Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2016-01-12btrfs-progs: docs, update btrfs(8) manual pageDavid Sterba1-9/+15
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12Btrfs-progs: fix typo in parse_rangeLiu Bo1-1/+1
s/*end/*start. This makes 'btrfs balance start -dvrange=xxx..yyy' really work. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: use on-stack buffer in add_symbolic_linkDavid Sterba1-5/+3
Also get rid of the unhandled memory allocation. Resolves-coverity-id: 1338298 Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs: only free root_path if it was allocated from the heapNeil Horman1-1/+3
Noticed this while doing some snapshots in a chroot environment btrfs receive can set root_path to either realmnt, which is passed in from the command line, or to a heap allocated via find_mount_root in do_receive. We should only free the later, not the former, as the former results in an invalid pointer warning from glibc during free. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: fix using on-disk structure to store in memory dataByongho Lee1-11/+17
In 'qgroup_count' structure 'diskinfo' and 'info' are used to store only in memory data but its types are for on-disk structure as a result sparse warns it (different base types). So fix it by adding new structure 'qgroup_info' to store in memory data and replace on-disk structure 'btrfs_qgroup_info_item' by 'qgroup_info'. In addition in alloc_cnt() 'generation' is set but not used after that so remove the relevant code. Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: fix endian bug in update_super()Byongho Lee1-2/+1
In update_super() 'chunk->stripe.devid' and 'super->dev_item.devid' both are little endian. So we should not use endian helper btrfs_set_stack_stripe_devid(). Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: fix endian bugs in chunk rebuildingByongho Lee1-4/+4
This is a same patch as Zach Brown's but we lost so I resend it based on current code. - 'commit 2cd95f945a61 ("fix endian bugs in chunk rebuilding")' Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: make private symbols to staticByongho Lee2-6/+6
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: use NULL instead of 0Byongho Lee4-11/+13
Fix the code assigning 0 to pointer instead of NULL. Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: get sparse checking workingByongho Lee1-1/+1
When I run sparse checking it gives the following error: $ make C=1 V=1 gcc -MM -MG -MF cmds-fi-usage.o.d -MT cmds-fi-usage.o -MT \ cmds-fi-usage.static.o -MT cmds-fi-usage.o.d -g -O1 -Wall \ -D_FORTIFY_SOURCE=2 -include config.h -DBTRFS_FLAT_INCLUDES \ -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC cmds-fi-usage.c [SP] ctree.c sparse -g -O1 -Wall -D_FORTIFY_SOURCE=2 -include config.h \ -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC \ -include -D__CHECKER__ -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized \ -Wshadow -Wundef -U_FORTIFY_SOURCE ctree.c builtin:1:15: error: unable to open '-D__CHECKER__' Makefile:177: recipe for target 'ctree.o' failed make: *** [ctree.o] Error 1 It means '$(check_defs)' is passed to sparse as NULL and looks '$(check_defs)'should be assigned before assigning '$(CHECKER_FLAGS)'. BTW, I'm not familiar with make tool so there could be some my misunderstanding and better solution. Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: Enhance chunk validation checkQu Wenruo3-3/+36
Enhance chunk validation: 1) Num_stripes We already have such check but it's only in super block sys chunk array. Now check all on-disk chunks. 2) Chunk logical It should be aligned to sector size. This behavior should be *DOUBLE CHECKED* for 64K sector size like PPC64 or AArch64. Maybe we can found some hidden bugs. 3) Chunk length Same as chunk logical, should be aligned to sector size. 4) Stripe length It should be power of 2. 5) Chunk type Any bit out of TYPE_MAS | PROFILE_MASK is invalid. With all these much restrict rules, several fuzzed image reported in mail list should no longer cause btrfsck error. Reported-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: ftw_add_entry_size: Round up file size to sectorsizeChandan Rajendra1-4/+4
ftw_add_entry_size() assumes 4k as the block size of the underlying filesystem and hence the file sizes computed is incorrect for non-4k sectorsized filesystems. Fix this by rounding up file sizes to sectorsize. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: balance: enhance the usage filter with rangeDavid Sterba1-5/+24
We can do more with the balance usage filter. Enhance it so we can specify also the minimum usage of the block groups to process. The 'usage' filter now accepts a range (a..b, can be partial) and needs kernel support. The 'usage=value' filter is equivalent to 'limit=..value' but works on older kernels as well. The min/max values are 32bit, unlike the single-value limit which is 64bit. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: extend balance args to take min/max usage filterDavid Sterba4-1/+25
Add the overlapping usage and [usage_min, usage_max] members to the balance args. The min/max values are interpreted iff the corresponding flag BTRFS_BALANCE_ARGS_USAGE_RANGE is set. The minimum boundary is inclusive, maximum is exclusive: * usage_min <= chunk_usage < usage_max Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: balance: add stripes filterGabríel Arthúr Pétursson4-1/+26
Add new balance filter 'stripes=<range>' to process only chunks that are spread accross given number of chunks. The range minimum and maximum are inclusive. Signed-off-by: Gabríel Arthúr Pétursson <gabriel@system.is> [ reworked a bit to use the range helpers, dropped the single value for stripes ] Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: balance: enhance the limit fiter with rangeDavid Sterba1-4/+12
We can do more with the balance filter. Enhance it so we can specify also the minimum number of block groups to process. The 'limit' filter now accepts a range (a..b, can be partial) and needs kernel support. The 'limit=value' filter is equivalent to 'limit=..value' but works on older kernels as well. The min/max values are 32bit, unlike the single-value limit which is 64bit. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: extend balance args to take min/max limit filterDavid Sterba4-1/+23
Add the overlapping limit and [limit_min, limit_max] members to the balance args. The min/max values are interpreted iff the corresponding flag BTRFS_BALANCE_ARGS_LIMIT_RANGE is set. The minimum and maximum are inclusive. Note that the values are only 32bit, but this should be enough for the foreseeable future. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: tests: test multiple-linked file corruptionNaohiro Aota2-4/+7
This commit extends the leaf corruption test to try to repair a file linked from multiple directory. It stresses a case that some links to a file is broken but others kept valid. Signed-off-by: Naohiro Aota <naota@elisp.net> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: Introduce new members for btrfs_convert_contextQu Wenruo2-0/+33
Introduce 3 new members for btrfs_convert_context: 1) struct cache_tree used Records accurate byte ranges which are used by old filesystem. This will be used to create old filesystem image. 2) struct cache_tree data_chunks Records batched ranges which must be covered by data chunks. The bytenr range is optimized to meet all the chunk requirement. 3) u64 total_bytenr Records how large the filesystem is in bytenr. Yes, we can calculate it easy, but that's for old blocks based filesystem. This will make it more friendly for extent based filesystem. And later cctx->block_counts and may be removed And 2 for mkfs_config: 1) char *chunk_uuid. Used as temporary chunk_uuid (unparsed) string for later make_convert_btrfs() 2) u64 super_bytenr Records the new temporary super bytenr after make_btrfs(). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: extent-tree: Add add_merge_cache_extent functionQu Wenruo2-0/+65
This add_merge_cache_extent() function will try to merge adjusted cache_extent. This is used for later btrfs-convert ext2 free space cache. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: extent-cache: Add comments for search/lookup functionsQu Wenruo1-0/+31
There are quite a lot search/lookup functions with different behavior, add comments for them, as it will take extra time to view source to understand the behavior difference. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: check, properly reset nlink of multi-linked fileNaohiro Aota1-2/+3
If a file is linked from more than one directory and only one of the links is corrupted, btrfs check dose not reset the nlink properly. Actually it can go into infinite loop to link the broken file into lost+found. This patch fix two part of the code. The first one delay the freeing valid (no error, found inode ref, directory index, and directory item) backrefs. Freeing valid backrefs earier prevent reset_nlink() to add back all valid links. The second fix is obvious: passing `ref_type' to btrfs_add_link() is just wrong. It should be `filetype' instead. The current code can break all valid file links. Signed-off-by: Naohiro Aota <naota@elisp.net> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12btrfs-progs: tests: print test typeDavid Sterba5-7/+7
Makes it a bit more clear: [TEST/conv] ext4 32k nodesize, btrfs no-holes [TEST/conv] ext2 64k nodesize, btrfs no-holes [TEST/conv] ext3 64k nodesize, btrfs no-holes [TEST/conv] ext4 64k nodesize, btrfs no-holes [TEST] misc-tests.sh [TEST/misc] 001-btrfstune-features [TEST/misc] 002-uuid-rewrite [TEST/misc] 003-zero-log [TEST/misc] 004-shrink-fs [TEST/misc] 005-convert-progress-thread-crash [TEST/misc] 006-image-on-missing-device [TEST/misc] 007-subvolume-sync [TEST/misc] 008-leaf-crossing-stripes [TEST/misc] 009-subvolume-sync-must-wait [TEST/misc] 010-convert-delete-ext2-subvol [TEST/misc] 011-delete-missing-device [TEST] fuzz-tests.sh [TEST/fuzz] 001-simple-unmounted Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: show-super: copy implementation of btrfs_read_sys_arrayDavid Sterba1-15/+54
btrfs-show-super has own implementation to read the sys array and it lacks all the sanity checks. Copy and adapt the improved implementation from btrfs_read_sys_array. This will fix crashes on a fuzzed/corrupted images. It's duplicating code but at the moment looks easier than refactoring and restructuring btrfs_read_sys_array that now almost matches the kernel code, which we want in the long term. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: tests: add sys-array-num-stripes-0.raw.xzDavid Sterba2-0/+30
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: verbose error when we find an unexpected item in sys_arrayDavid Sterba1-1/+5
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: handle invalid num_stripes in sys_arrayDavid Sterba1-0/+8
We can handle the special case of num_stripes == 0 directly inside btrfs_read_sys_array. The BUG_ON in btrfs_chunk_item_size is there to catch other unhandled cases where we fail to validate external data, like in btrfs-show-super. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: add more checks to btrfs_read_sys_arrayDavid Sterba1-3/+23
Port of kernel commit e3540eab29e1b2260bc4b9b3979a49a00e3e3af8 Verify that the sys_array has enough bytes to read the next item. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: cleanup, rename a few variables in btrfs_read_sys_arrayDavid Sterba1-15/+16
Port of kernel commit 1ffb22cf8c322bbfea6b35fe23d025841b49fede There's a pointer to buffer, integer offset and offset passed as pointer, try to find matching names for them. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: update btrfs_read_sys_array to match kernel implementationDavid Sterba1-15/+16
There are some sanity checks missing on both sides, kernel/userspace. Preparation to port the missing changes. Sync code with parent of kernel commit 1ffb22cf8c322bbfea6b35fe23d025841b49fede ("btrfs: cleanup, rename a few variables in btrfs_read_sys_array") This effectively reverts progs commit be96777126d283773e4397278a5662d90676ab88 ("btrfs-progs: Cleanup unneeded extra variant in btrfs_read_sys_array") so we can apply more of the kernel patches. Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: tests: mkfs, check sectorsize and nodesize combinationsQu Wenruo1-0/+49
Add mkfs selftest for invalid and valid sectorsize/nodesize combinations. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ switched to TEST_DEV ] Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: install to /usr/local by default againDavid Sterba1-1/+1
The conversion to autotools changed the default prefix to /usr. There's no reason to diverge. Distributions builds set prefix the /usr path and local builds are supposed to go to /usr/local . Reference: https://bugzilla.kernel.org/show_bug.cgi?id=108571 Reported-by: Karl Richter <krichter722@aol.de> Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-04btrfs-progs: docs: mkfs, implications of DUP on devicesDavid Sterba2-5/+29
We offer DUP but still depend on the hardware, to do the right thing. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26btrfs-progs: tests: enhance 001-basic-profiles with --data DUPDavid Sterba1-0/+2
Add the remaining valid combinations. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26btrfs-progs: mkfs: allow --data DUP for single deviceZhao Lei3-10/+7
Current code don't support DUP profile on single device, except it is in mixed mode, because of following reasons: 1: Some SSD do deduplication internally, so the duplication on the filesystem side has no effect. 2: On a physical device, if the entire disk broken, --data DUP does not help. 3: Half performance compared to single profile. 4: We have a workaround: create multi-partition on a single device, and btffs will treat them as multi device. Instead of refusing --data DUP, we give the user a choice and print a wrning. Test: 1: Tested by xfstests Run with modified xfstests, I add test items of -d dup in single device into btrfs/* and common/rc, run tests of btrfs/*, with all mount option, no regression diffed with v4.3. 2: Tested by btrfs-progs Checked following commands in "-m dup -d dup" fs with memleck checking, all passed: mkfs.btrfs -f --data dup --metadata dup /dev/sda6 btrfs filesystem show /dev/sda6 btrfs filesystem label /dev/sda6 btrfs_label_test btrfs filesystem label /dev/sda6 btrfs device scan --all-devices btrfs device scan /dev/sda6 btrfs device scan /dev/sda6 btrfs device ready /dev/sda6 btrfs check /dev/sda6 btrfs check -s 1 /dev/sda6 btrfs check --repair /dev/sda6 btrfs check --init-csum-tree /dev/sda6 btrfs check --init-extent-tree /dev/sda6 btrfs check --check-data-csum /dev/sda6 btrfs check --qgroup-report /dev/sda6 btrfs rescue super-recover -y /dev/sda6 btrfs rescue zero-log /dev/sda6 btrfs restore -l /dev/sda6 btrfs restore /dev/sda6 / btrfs restore -s /dev/sda6 / btrfs restore -x /dev/sda6 / btrfs restore -m /dev/sda6 / btrfs restore -S /dev/sda6 / btrfs restore -v /dev/sda6 / btrfs restore -i /dev/sda6 / btrfs restore -o /dev/sda6 / btrfs restore -u0 /dev/sda6 / btrfs restore -u1 /dev/sda6 / btrfs restore -D /dev/sda6 / btrfs property list /dev/sda6 btrfs property get /dev/sda6 label btrfs property set /dev/sda6 label test btrfs property set /dev/sda6 label btrfs_label_test btrfs help btrfs help --full btrfs version btrfsck /dev/sda6 btrfs-find-root /dev/sda6 btrfs-find-root -a /dev/sda6 btrfs-map-logical -l1 /dev/sda6 btrfs-map-logical -l1 -c1 /dev/sda6 btrfs-map-logical -l1 -o /tmp/btrfs-map-logic-out /dev/sda6 btrfs-map-logical -l1 -b1 /dev/sda6 btrfs-select-super -s 0 /dev/sda6 btrfs-select-super -s 1 /dev/sda6 btrfstune -S 1 /dev/sda6 btrfstune -f -S 0 /dev/sda6 btrfstune -r /dev/sda6 btrfstune -x /dev/sda6 btrfstune -n /dev/sda6 btrfstune -f -U 00000000-0000-0000-0000-000000000000 /dev/sda6 btrfstune -f -u /dev/sda6 btrfs-calc-size /dev/sda6 btrfs-calc-size -v /dev/sda6 btrfs-calc-size -b /dev/sda6 btrfs-debug-tree /dev/sda6 btrfs-debug-tree -e /dev/sda6 btrfs-debug-tree -d /dev/sda6 btrfs-debug-tree -r /dev/sda6 btrfs-debug-tree -R /dev/sda6 btrfs-debug-tree -u /dev/sda6 btrfs-debug-tree -b 0 /dev/sda6 btrfs-debug-tree -t 0 /dev/sda6 btrfs-debug-tree -t 2 /dev/sda6 btrfs-show-super /dev/sda6 btrfs-show-super -i 0 /dev/sda6 btrfs-show-super -i 1 /dev/sda6 btrfs-show-super -i 2 /dev/sda6 btrfs-show-super -a /dev/sda6 btrfs-show-super -f /dev/sda6 btrfs-show-super -F /dev/sda6 btrfs subvolume list /mnt/btrfs-progs-tests btrfs subvolume create /mnt/btrfs-progs-tests/mysubvol btrfs subvolume list /mnt/btrfs-progs-tests btrfs subvolume get-default /mnt/btrfs-progs-tests btrfs subvolume set-default 258 /mnt/btrfs-progs-tests btrfs subvolume get-default /mnt/btrfs-progs-tests btrfs subvolume set-default /mnt/btrfs-progs-tests btrfs subvolume snapshot /mnt/btrfs-progs-tests/mysubvol /mnt/btrfs-progs-tests/mysubvol_snap btrfs subvolume list /mnt/btrfs-progs-tests btrfs subvolume find-new /mnt/btrfs-progs-tests 0 btrfs subvolume find-new /mnt/btrfs-progs-tests 0 btrfs subvolume find-new /mnt/btrfs-progs-tests/mysubvol 0 btrfs subvolume find-new /mnt/btrfs-progs-tests/mysubvol 0 btrfs subvolume show /mnt/btrfs-progs-tests btrfs subvolume show /mnt/btrfs-progs-tests/mysubvol btrfs subvolume show /mnt/btrfs-progs-tests/mysubvol_snap btrfs subvolume sync /mnt/btrfs-progs-tests btrfs subvolume delete /mnt/btrfs-progs-tests/mysubvol_snap btrfs subvolume delete /mnt/btrfs-progs-tests/mysubvol btrfs subvolume sync /mnt/btrfs-progs-tests btrfs filesystem df /mnt/btrfs-progs-tests btrfs filesystem show /mnt/btrfs-progs-tests btrfs filesystem sync /mnt/btrfs-progs-tests btrfs filesystem label /mnt/btrfs-progs-tests btrfs_label_test btrfs filesystem label /mnt/btrfs-progs-tests btrfs filesystem usage /mnt/btrfs-progs-tests btrfs filesystem defragment -s 1024 -l 2048 /mnt/btrfs-progs-tests/filesystem_test_dir/test_dir_0/test_file_0 btrfs filesystem defragment /mnt/btrfs-progs-tests/filesystem_test_dir/test_dir_0/test_file_1 btrfs filesystem defragment -f /mnt/btrfs-progs-tests/filesystem_test_dir/test_dir_0/test_file_2 btrfs filesystem defragment -czlib /mnt/btrfs-progs-tests/filesystem_test_dir/test_dir_0/test_file_3 btrfs filesystem defragment -clzo /mnt/btrfs-progs-tests/filesystem_test_dir/test_dir_0/test_file_4 btrfs filesystem defragment /mnt/btrfs-progs-tests/filesystem_test_dir btrfs filesystem defragment -r /mnt/btrfs-progs-tests/filesystem_test_dir btrfs filesystem defragment /mnt/btrfs-progs-tests btrfs filesystem resize 1:-10M /mnt/btrfs-progs-tests btrfs filesystem resize 1:max /mnt/btrfs-progs-tests btrfs balance start /mnt/btrfs-progs-tests btrfs balance start -v /mnt/btrfs-progs-tests btrfs balance start -f /mnt/btrfs-progs-tests btrfs balance status -v /mnt/btrfs-progs-tests btrfs balance pause /mnt/btrfs-progs-tests btrfs balance status /mnt/btrfs-progs-tests btrfs balance resume /mnt/btrfs-progs-tests btrfs balance status -v /mnt/btrfs-progs-tests btrfs balance cancel /mnt/btrfs-progs-tests btrfs balance start -dprofiles=single /mnt/btrfs-progs-tests btrfs balance start -dconvert=single /mnt/btrfs-progs-tests btrfs balance start -ddevid=1 /mnt/btrfs-progs-tests btrfs balance start -f -mprofiles=single /mnt/btrfs-progs-tests btrfs balance start -f -mconvert=single /mnt/btrfs-progs-tests btrfs balance start -f -mdevid=1 /mnt/btrfs-progs-tests btrfs balance start -f -sprofiles=single /mnt/btrfs-progs-tests btrfs balance start -f -sconvert=single /mnt/btrfs-progs-tests btrfs balance start -f -sdevid=1 /mnt/btrfs-progs-tests btrfs device add -f /dev/sda10 /mnt/btrfs-progs-tests btrfs device del /dev/sda10 /mnt/btrfs-progs-tests btrfs device stats /dev/sda6 btrfs device stats -z /dev/sda6 btrfs device stats /mnt/btrfs-progs-tests btrfs device stats -z /mnt/btrfs-progs-tests btrfs device usage /mnt/btrfs-progs-tests btrfs scrub status /mnt/btrfs-progs-tests btrfs scrub start -B /mnt/btrfs-progs-tests btrfs scrub start -B -d /mnt/btrfs-progs-tests btrfs scrub start -B -r /mnt/btrfs-progs-tests btrfs scrub status /mnt/btrfs-progs-tests btrfs scrub start /mnt/btrfs-progs-tests btrfs scrub status /mnt/btrfs-progs-tests btrfs scrub status /mnt/btrfs-progs-tests btrfs scrub status -d /mnt/btrfs-progs-tests btrfs scrub status -R /mnt/btrfs-progs-tests btrfs scrub status /mnt/btrfs-progs-tests btrfs scrub start /dev/sda6 btrfs scrub status /dev/sda6 btrfs scrub status /dev/sda6 btrfs scrub status -d /dev/sda6 btrfs scrub status -R /dev/sda6 btrfs scrub status /dev/sda6 btrfs subvolume snapshot -r /mnt/btrfs-progs-tests /mnt/btrfs-progs-tests/snap1 btrfs send -f /tmp/btrfs_snapshot_test /mnt/btrfs-progs-tests/snap1 btrfs send -e -f /tmp/btrfs_snapshot_test /mnt/btrfs-progs-tests/snap1 btrfs send --no-data -f /tmp/btrfs_snapshot_test /mnt/btrfs-progs-tests/snap1 btrfs quota enable /mnt/btrfs-progs-tests btrfs quota rescan /mnt/btrfs-progs-tests btrfs quota rescan -s /mnt/btrfs-progs-tests btrfs quota rescan -w /mnt/btrfs-progs-tests btrfs quota disable /mnt/btrfs-progs-tests btrfs quota enable /mnt/btrfs-progs-tests btrfs qgroup create 1/5 /mnt/btrfs-progs-tests btrfs qgroup create 2/5 /mnt/btrfs-progs-tests btrfs qgroup assign 1/5 2/5 /mnt/btrfs-progs-tests btrfs qgroup limit 1G 1/5 /mnt/btrfs-progs-tests btrfs qgroup show /mnt/btrfs-progs-tests btrfs qgroup show -p -c -r -e -F -f /mnt/btrfs-progs-tests btrfs qgroup remove 1/5 2/5 /mnt/btrfs-progs-tests btrfs qgroup destroy 2/5 /mnt/btrfs-progs-tests btrfs qgroup destroy 1/5 /mnt/btrfs-progs-tests btrfs quota disable /mnt/btrfs-progs-tests btrfs replace start -f -B /dev/sda6 /dev/sda10 /mnt/btrfs-progs-tests btrfs replace status /mnt/btrfs-progs-tests btrfs replace start -f -B /dev/sda10 /dev/sda6 /mnt/btrfs-progs-tests btrfs-convert /dev/sda6 btrfs-convert -r /dev/sda6 btrfs-convert -d /dev/sda6 btrfs-convert -i /dev/sda6 btrfs-convert -n /dev/sda6 btrfs-convert -N 4096 /dev/sda6 btrfs-convert -l test /dev/sda6 btrfs-convert -L /dev/sda6 btrfs-convert --no-progress /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -c 0 /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -c 9 /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -t 0 /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -t 1 /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -t 32 /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -w /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 mkfs.btrfs -f /dev/sda6 btrfs-image -w /dev/sda6 /tmp/btrfs_image.img btrfs-image -r /tmp/btrfs_image.img /dev/sda6 btrfs-image -r -t 0 /tmp/btrfs_image.img /dev/sda6 btrfs-image -r -t 1 /tmp/btrfs_image.img /dev/sda6 btrfs-image -r -t 32 /tmp/btrfs_image.img /dev/sda6 btrfs-image -r -o /tmp/btrfs_image.img /dev/sda6 3: Manual check relation source by: grep DUP *.c Confirmed that all source are modified. 4: Use this raid type manually, do some operations in fs, no error found in command and dmesg. 5: Combination of dup conversion with fsck Confirmed OK with relative kernel patch titled: [PATCH] btrfs: Support convert to -d dup for btrfs-convert export TEST_DEV='/dev/vdc' export TEST_DIR='/var/ltf/tester/mnt' do_dup_test() { local m_from="$1" local d_from="$2" local m_to="$3" local d_to="$4" echo "Convert from -m $m_from -d $d_from to -m $m_to -d $d_to" umount "$TEST_DIR" &>/dev/null ./mkfs.btrfs -f -m "$m_from" -d "$d_from" "$TEST_DEV" >/dev/null || return 1 mount "$TEST_DEV" "$TEST_DIR" || return 1 cp -a /sbin/* "$TEST_DIR" [[ "$m_from" != "$m_to" ]] && { ./btrfs balance start -f -mconvert="$m_to" "$TEST_DIR" || return 1 } [[ "$d_from" != "$d_to" ]] && { local opt=() [[ "$d_to" == single ]] && opt+=("-f") ./btrfs balance start "${opt[@]}" -dconvert="$d_to" "$TEST_DIR" || return 1 } umount "$TEST_DIR" || return 1 ./btrfsck "$TEST_DEV" || return 1 echo return 0 } test_all() { for m_from in single dup; do for d_from in single dup; do for m_to in single dup; do for d_to in single dup; do do_dup_test "$m_from" "$d_from" "$m_to" "$d_to" || return 1 done done done done } test_all Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Tested-by: Austin S. Hemmelgarn <ahferroin7@gmail.com> [ minor updates in the changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26btrfs-progs: convert: add context and operations struct to allow different ↵Jeff Mahoney1-58/+202
file systems Push out common convert operations into function pointers that we can ultimately allow other file systems to use to provide their own conversions. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.cz>
2015-11-26btrfs-progs: tests: add 019-non-skinny-false-alertDavid Sterba2-0/+23
Catch a buggy condition fixed by "btrfs-progs: fsck: Fix a false alert where extent record has wrong metadata flag" Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-26btrfs-progs: fsck: Fix a false alert where extent record has wrong metadata flagQu Wenruo1-0/+4
In process_extent_item(), it gives 'metadata' initial value 0, but for non-skinny-metadata case, metadata extent can't be judged just from key type and it forgot that case. This causes a lot of false alert in non-skinny-metadata filesystem. Fix it by set correct metadata value before calling add_extent_rec(). Reported-by: Christoph Anton Mitterer <calestyo@scientia.net> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-24btrfs-progs: docs: update raid table in mkfs manpageDavid Sterba1-8/+14
* split copies to copies and parity and add a common header for all the raid options * add missing RAID1 * n/a were dropped Based on feedback from Duncan <1i5t5.duncan@cox.net>. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-19btrfs-progs: chunk-recovery: Fix a float point errorQu Wenruo2-3/+23
Fix a zero division causing chunk-recovery fail. Also fix a typo "strpie_length" -> "stripe_length". Reported-by: Scotty Edmonds <scotty@scottyedmonds.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-19btrfs-progs: tests: add 007-mix-nodesize-sectorsizeDavid Sterba1-0/+35
Test combinations of sectorsize and nodesize on a single device. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-19btrfs-progs: mkfs: use correct size for superblock csum and writeoutDavid Sterba1-4/+4
If sectorsize is not BTRFS_SUPER_INFO_SIZE (4k), the superblock checksum is wrong and mkfs fails. This has been reported on ppc64 where we pick sectorisize from page size (64k). This has been broken since ages (2008) and discovered by the recently added superblock checks. Reported-by: Dinar Valeev <dvaleev@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-18btrfs-progs: docs: fix typo in balance man pageJeffrey Schiller1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16Btrfs progs v4.3.1v4.3.1David Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: fix fd leak in resolve_loop_device_with_loopdevDavid Sterba1-5/+10
Resolves-coverity-id: 1339300 Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: tests: add 006-partitioned-loopdevDavid Sterba2-0/+26
Create filesystem on a partitioned loop device, test for "btrfs-progs: Fix partitioned loop devices resolving". Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: utils: do not expect lo_file_name to be null terminatedDavid Sterba1-1/+2
The loop_info64::lo_file_name might not be null terminated. Avoid strlen and trim the length to whatever size of the loop_info buffer. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: Fix partitioned loop devices resolvingFlorian Margaine1-1/+30
When using partitions on a loop device, the device's name can be e.g. /dev/loop0p1 or similar, and no relevant entry exists in the /sys filesystem, so the current resolve_loop_device function fails. Instead of using string functions to extract the device name and reading this file, this patch uses the loop device API through ioctl to get the correct backing file. Signed-off-by: Florian Margaine <florian@platform.sh> [ changed checks of error values from open and ioctl ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: find-root: Add support to search chunk rootQu Wenruo3-11/+29
Add support to search chunk root, as we only need to search tree roots in system chunk, which should be very easy to add, just iterate in system chunks. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ renamed to btrfs_next_bg_* ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: cleanup cmd_device_usage, simplify loop checksZhao Lei1-6/+4
1: Remove more_than_one variable, use iterators value instead 2: Remove "out" label, we use break instead. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [ changelog update ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: device: use warning/error for error messageZhao Lei1-29/+18
Switch to common warning()/error() for cmds-device.c. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> [ minor tweaks ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: Check periodic.timer_fd's value before useZhao Lei1-0/+3
periodic.timer_fd's value is 0 on inititlize-failed case, if no value-checking before read(), the code will run as read(STDIN). This patch fixed above case. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: tests: add 005-long-device-name-for-ssdDavid Sterba1-0/+39
A test for "btrfs-progs: mkfs: increase buffer size in is_ssd". Create a device with a long name through loop device wrapped to a device mapper linear device, switch it to the "ssd" mode status. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: mkfs: increase buffer size in is_ssdMichael Lass1-1/+1
In current versions of util-linux the buffer passed to blkid_devno_to_wholedisk has to be sufficiently large to not only hold the device name but the complete target of the /sys/dev/block/<maj:min> symlink. This was changed only recently in 4419ffb9eff5801fdbd385a4a6199b3877f802ad. The small buffer size currently can lead to failure of is_ssd due to truncated device names: readlink("/sys/dev/block/254:7", "../../devices/virtual/block/dm-", 31) = 31 open("/sys/block/dm-/queue/rotational", O_RDONLY) = -1 ENOENT (No such file or directory) Signed-off-by: Michael Lass <bevan@bi-co.net> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: tests: add 011-delete-missing-deviceDavid Sterba1-0/+82
Test for "btrfs-progs: allow device deletion using 'missing' keyword again". Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: allow device deletion using 'missing' keyword againAlexander Fougner1-1/+1
Device deletion procedures ensures the device is a block device. This patch introduces 'missing' as keyword again, correctly passing it on to the kernel instead of complaining about 'missing' not being a block device. Signed-off-by: Alexander Fougner <fougner89@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: mkfs: handler memory allocation error in make_btrfsDavid Sterba1-3/+5
Do the allocation early, no need to cleanup. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-16btrfs-progs: image: reorder initialization in metadump_initDavid Sterba1-19/+13
Put the allocations first, move pthread cond and mutex last so we don't have to do cleanup. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: corrupt-block: use on-stack path buffer in corrupt_dir_itemDavid Sterba1-7/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: calc-size: kill fs_roots structure and its userDavid Sterba1-9/+3
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: calc-size: use on-stack buffer for a helper structureDavid Sterba1-12/+4
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: drop unused argument from zero_output_fileDavid Sterba1-2/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use fixed size buffer in zero_output_fileDavid Sterba1-10/+7
Rewrite the loop so we don't need to allocate sectorsize and write in 4k steps instead. We know that sectorsize is divisible by 4096. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: handle memory allocation failures in traverse_directoryDavid Sterba1-0/+6
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: handle memory allocation failure in add_file_itemsDavid Sterba1-0/+6
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack buffer in __csum_tree_block_sizeDavid Sterba1-7/+1
We know the maximum size of a checksum, calling malloc for 4 bytes is weird. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack buffer in __ino_to_path_fdDavid Sterba1-7/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack buffer in recover_prepareDavid Sterba1-13/+6
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack variable in __rebuild_device_itemsDavid Sterba1-6/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack buffer for btrfs_scan_one_deviceDavid Sterba1-13/+3
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13btrfs-progs: use on-stack buffer for dev_to_fsidDavid Sterba1-7/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06btrfs-progs: remove unused parameter from print_one_fsDavid Sterba1-3/+2
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06btrfs-progs: don't print version info from embedded subcommandsDavid Sterba2-4/+0
The version is provided by 'btrfs --version'. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06btrfs-progs: simplify empty stirngs checkDavid Sterba6-14/+14
We can do a strlen(str) == 0 in a simpler way. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06btrfs-progs: utils: rename helpinfo unit vairablesDavid Sterba5-7/+7
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06Btrfs progs v4.3v4.3David Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-05btrfs-progs: mkfs: do not truncate the image when --rootdir is setDavid Sterba2-1/+31
With the rootdir option we try to guess the final size of the image and fill it with zeros, preceded by truncation. After patch "Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified" the misc test 002 will fail, because of the non-mixed mode. I think we should not touch the image size (no change for block devices) and try to fit into whatever is provided by user. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-05btrfs-progs: Allow btrfs_leaf_free_space to accept NULL rootQu Wenruo1-4/+5
Btrfs_leaf_free_space() function is used to determine the leaf/node size. It's OK to use root->nodesize to determine nodesize, but in fact, extent_buffer->len can also be used to determine the nodesize if caller can ensure it's a tree block. So this patch will add support for NULL root for btrfs_leaf_free_space() function, to allow btrfs_print_leaf() functions to be called in gdb or to debug temporary btrfs in make_btrfs() without a valid root. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: mkfs: Round device size down to sectorsizeZhao Lei1-0/+2
When do following command in a vm, whose disks are created by qemu-img create -f raw 11 2.6G: # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf # btrfs-show-super /dev/vdd /dev/vde /dev/vdf | grep dev_item.total_bytes dev_item.total_bytes 2791727104 dev_item.total_bytes 2791729152 dev_item.total_bytes 2791729152 We can see that the first device's size is little smaller. And it fails xfstests btrfs/011. Reason: First device's size is rounded down to sectorsize in make_btrfs(), but other devices are not. Fix: Round down remain devices' size in btrfs_add_to_fsid(). Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: Rename variables in btrfs_add_to_fsidZhao Lei1-5/+5
There are two total_bytes in btrfs_add_to_fsid(), local variable of total_bytes means fs_total_bytes, and device->total_bytes means device's total_bytes. And device's total_bytes in argument is named block_count in current code. This patch rename: total_bytes -> fs_total_bytes block_count -> device_total_bytes To make code more readable. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: print-tree: Output stripe dev uuidQu Wenruo1-0/+8
Add output for dev uuid for print_chunk(). Quite useful to debug temporary btrfs in btrfs-convert. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: mkfs: remove unused code of format uuid stringZhao Lei1-3/+0
Variant named dev_uuid and uuid_unparse() for set its value are not used, remove it. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: mkfs: output device list in sorted orderZhao Lei1-1/+11
list_for_each_entry_reverse() in current code can not output devices in sorted order, because the sequence are broken in btrfs_alloc_chunk(). We can use list_sort() instead. Before patch: # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf ... Number of devices: 3 Devices: ID SIZE PATH 3 2.60GiB /dev/vdf 1 2.60GiB /dev/vdd 2 2.60GiB /dev/vde After patch: # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf ... Number of devices: 3 Devices: ID SIZE PATH 1 2.60GiB /dev/vdd 2 2.60GiB /dev/vde 3 2.60GiB /dev/vdf Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: fi usage: print header and footer separation lineDavid Sterba1-2/+10
Print the full row width and change to '-' as we're not using '=' anywhere. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: string table: add specifier for fillup charDavid Sterba2-5/+5
Currently it's one by a single "=", but we might want to use a different filler, let's make it explicit by "*". Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: string table: cleanup, rename single letter variablesDavid Sterba1-16/+16
Exception for indexing variables. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: string table: fix whitespace damageDavid Sterba2-31/+23
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: fi usage: print device id column in the tabular output<F2>David Sterba1-7/+10
Example output: Data Metadata System Id Path single RAID1 RAID1 Unallocated 1 /dev/sdc2 44.94GiB 7.93GiB 32.00MiB 1.00GiB 2 /dev/sde1 44.94GiB 7.93GiB 32.00MiB 1.00GiB ======== ======== ======== =========== Total 89.88GiB 7.93GiB 32.00MiB 2.00GiB Used 74.28GiB 4.44GiB 20.00KiB Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: fi usage: cleanup, replace space info starting column constantDavid Sterba1-5/+7
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: fi usage: cleanup, replace header constantDavid Sterba1-12/+16
The size of the header is not obvious, let's make it more visible by replacing it with a varaible. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03btrfs-progs: fi usage: properly count real space infosDavid Sterba1-2/+9
We did not account the column for path but abused the skipped global block reserve colum instead. Properly count the real infos and manually added headers. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fi usage: print path header in the tabular modeDavid Sterba1-0/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fi usage: cleanup, print header in one goDavid Sterba1-16/+5
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fi usage: do not print global block reserveDavid Sterba1-16/+46
Global block reserve is inherently part of metadata and should not be listed separately in the output of 'fi usage' in the tabular output. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02Btrfs progs v4.3-rc1v4.3-rc1David Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: show-super: Add option to print superblock at given bytenrQu Wenruo2-1/+10
Add '-s <sb_bytenr>' option to show superblock at given bytenr. This is very useful to debug non-standard btrfs, like debuging the 1st stage btrfs of btrfs-convert. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ minor updates in docs ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: docs: enhance manual page for inspect-internalDavid Sterba1-21/+29
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: docs: enhance the manual page for convertDavid Sterba1-23/+62
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: docs: enhance manual page for balanceDavid Sterba1-45/+98
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: docs: enhance manual page for btrfstuneDavid Sterba1-8/+11
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: docs: enhance manual page for mkfsDavid Sterba1-95/+229
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: mkfs: print version info firstDavid Sterba1-7/+5
The version info should not be preceded by any messages. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: image: fix bogus check after cpu on-line detectionDavid Sterba1-3/+5
Comparing unsigned type for <= 0 does not make much sense, we should really check the signed value returned by sysconf. Resolves-coverity-id: 1324536 Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: Avoid use pointer in handle_optionsZhao Lei1-14/+18
We use pointer of argc and argv in handle_options() because they are necessary in very old code which are not exist now. This patch move to use argc and argv directly in handle_options(), alone with following update: 1: rename handle_options() to check_options() to fit its function. 2: cleanup for condition in handle_options() to make line short. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: Fix uninitialized key.type for btrfs_find_free_objectidZhao Lei1-0/+1
To avoid using uninitialized value in btrfs_search_slot(). Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-sizeZhao Lei1-1/+8
btrfs-calc-size show following warning: # btrfs-calc-size /dev/sda6 Calculating size of root tree ... extent_io.c:582: free_extent_buffer: Assertion `eb->refs < 0` failed. ./btrfs-calc-size[0x41d642] ./btrfs-calc-size(free_extent_buffer+0x70)[0x41e1c1] ./btrfs-calc-size(btrfs_free_fs_root+0x11)[0x40e1e8] ./btrfs-calc-size[0x40e215] ./btrfs-calc-size(rb_free_nodes+0x1d)[0x4326fe] ./btrfs-calc-size(close_ctree+0x3f3)[0x40f9ea] ./btrfs-calc-size(main+0x200)[0x431b4e] /lib64/libc.so.6(__libc_start_main+0xf5)[0x3858621d65] ./btrfs-calc-size[0x407009] Reason: path in calc_root_size() is only used to save node data, it don't hold ref_cnt for each eb in. Using btrfs_free_path() to free path will reduce these eb again, and cause many problems, as negative ref_cnt or invalid memory access. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fix floating point exception for btrfs-calc-sizeZhao Lei1-2/+2
Current code exit with floating point exception on a blank fs: # btrfs-calc-size -b /dev/sda6 Calculating size of root tree Total size: 16384 Inline data: 0 Total seeks: 0 Forward seeks: 0 Backward seeks: 0 Floating point exception This patch add a condition check for above case. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: add initial tests/READMEDavid Sterba1-0/+136
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: add an initial READMEDavid Sterba1-0/+41
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: mkfs: remove stray message about forced mixed-bgDavid Sterba1-5/+0
We no longer force mixed-bg mode since "Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified", the message is not relevant anymore. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add 003-mixed-with-wrong-nodesizeDavid Sterba1-0/+12
Mixed mode needs equal sectorsize and nodesize. This was fixed by "Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and having differing sectorsize and nodesize" Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: do not log output of run_mayfail to terminalDavid Sterba1-2/+6
No need to log expected failures to the terminal, the results file is fine; pass the return value of the command. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and having ↵Chandan Rajendra1-12/+13
differing sectorsize and nodesize. mkfs.btrfs allows creation of Btrfs filesystem instances with mixed block group feature enabled and having a sectorsize different from nodesize. For e.g: [root@localhost btrfs-progs]# mkfs.btrfs -f -M -s 4096 -n 16384 /dev/loop0 Forcing mixed metadata/data groups btrfs-progs v3.19-rc2-404-gbbbd18e-dirty See http://btrfs.wiki.kernel.org for more information. Performing full device TRIM (4.00GiB) ... Label: (null) UUID: c82b5720-6d88-4fa1-ac05-d0d4cb797fd5 Node size: 16384 Sector size: 4096 Filesystem size: 4.00GiB Block group profiles: Data+Metadata: single 8.00MiB System: single 4.00MiB SSD detected: no Incompat features: mixed-bg, extref, skinny-metadata Number of devices: 1 Devices: ID SIZE PATH 1 4.00GiB /dev/loop6 This commit fixes the issue by setting BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS feature bit before checking the validity of nodesize that was specified on the command line. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: use system's default path for math.hZhao Lei1-1/+1
Line of #include "math.h" in extent-tree.c using quotas is historical reason, (we had custom math.h before). Use "<>" instead of quotes in this header file. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: Add missing close_ctree to btrfs-select-super.cZhao Lei1-0/+1
Add missing close_ctree() to btrfs-select-super.c to avoid memory leak. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: Add all missing btrfs_close_all_devices to standalone toolsZhao Lei6-1/+10
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>
2015-11-02btrfs-progs: Remove all btrfs_close_all_devices in sub-commandZhao Lei3-6/+0
Since we have btrfs_close_all_devices() in btrfs's main entrance, it is not necessary to call btrfs_close_all_devices() separately in each sub-command. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: btrfs: Add missing btrfs_close_all_devices for btrfs commandZhao Lei1-1/+8
Adding a btrfs_close_all_devices() after command callback in btrfs.c can force-close all opened device before program exit, to avoid memory leak in all btrfs sub-command. Suggested-by: David Sterba <dsterba@suse.cz> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add support for command instrumentationDavid Sterba1-3/+15
Add a way to wrap commands executed by the tests. This means the common wrappers: run_check, run_check_stdout and run_mayfail , with the exception of the use root_helper. The contents of the shell variable INSTRUMENT are prepended to the command, without quotes. Use with care. Example: this has been tested with valgrind, the output goes to the RESULTS file. $ INSTRUMENT=valgrind make test-misc Any use of root_helper/SUDO_HELPER will skip the instrumentation. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: 001-simple-unmounted: iterate over fuzzed images and run ↵David Sterba1-0/+20
check Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add test driver for fuzzed imagesDavid Sterba2-1/+46
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fix missing initialization of list head for dev_listAnand Jain1-0/+1
Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: fix uninitialized copy of btrfs_fs_devices listAnand Jain1-1/+1
Noticed that at print_one_uuid() some of the members of btrfs_fs_devices contained some junk values. It took a while to dig this further, and found that we make a local copy of the btrfs_fs_devices list at search_umounted_fs_uuids() and wasn't initialized properly. Fixed using using calloc instead of malloc. Signed-off-by: Anand Jain <anand.jain@oracle.com> [ switched to calloc ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: do not run sudo helper tests if not necessaryDavid Sterba1-1/+1
We use setup_root_helper in some helpers to make sure that the sudo helper is set up, and adding that to each test. Make the real test run only once. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: set default test image size to 2GDavid Sterba1-1/+1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add 010-convert-delete-ext2-subvolDavid Sterba1-0/+24
Testcase for "Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREF", make sure we don't try a rollback if the ext2_subvol is half-deleted. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02Btrfs-progs: fix btrfs-convert rollback to check ROOT_BACKREFLiu Bo1-0/+17
Btrfs has changed to delete subvolume/snapshot asynchronously, which means that after umount itself, if we've already deleted 'ext2_saved', rollback can still be completed. So this adds a check for ROOT_BACKREF before checking ROOT_ITEM since ROOT_BACKREF is immediately not in the btree after ioctl(BTRFS_IOC_SNAP_DESTROY) returns. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ updated error messages ] Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: mute coverity warnings about deadcodeEryu Guan1-4/+4
Coverity reports execution cannot reach this statements. So put WARN_ON in if-else conditions. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add 002-no-force-mixed-on-small-volumeDavid Sterba1-0/+13
Verify that we do not force mixed block groups on small volumes anymore. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add 001-basic-profiles mkfs testsDavid Sterba1-0/+89
Basic test to cover block group profile combinations. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: tests: add mkfs testsDavid Sterba2-1/+49
Mkfs deserves it's own. Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02Btrfs-progs: Do not force mixed block group creation unless '-M' option is ↵Chandan Rajendra6-23/+45
specified When creating small Btrfs filesystem instances (i.e. filesystem size <= 1GiB), mkfs.btrfs fails if both sectorsize and nodesize are specified on the command line and sectorsize != nodesize, since mixed block groups involves both data and metadata blocks sharing the same block group. This is an incorrect behavior when '-M' option isn't specified on the command line. This commit makes optional the creation of mixed block groups i.e. Mixed block groups are created only when -M option is specified on the command line. Since we now allow small filesystem instances with sectorsize != nodesize to be created, we can end up in the following situation, [root@localhost ~]# mkfs.btrfs -f -n 65536 /dev/loop0 btrfs-progs v3.19-rc2-405-g976307c See http://btrfs.wiki.kernel.org for more information. Performing full device TRIM (512.00MiB) ... Label: (null) UUID: 49fab72e-0c8b-466b-a3ca-d1bfe56475f0 Node size: 65536 Sector size: 4096 Filesystem size: 512.00MiB Block group profiles: Data: single 8.00MiB Metadata: DUP 40.00MiB System: DUP 12.00MiB SSD detected: no Incompat features: extref, skinny-metadata Number of devices: 1 Devices: ID SIZE PATH 1 512.00MiB /dev/loop0 [root@localhost ~]# mount /dev/loop0 /mnt/ mount: mount /dev/loop0 on /mnt failed: No space left on device The ENOSPC occurs during the creation of the UUID tree. This is because of things like large metadata block size, DUP mode used for metadata and global reservation consuming space. Also, large nodesize does not make sense on small filesystems, hence this should not be an issue. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: add helpers to print rangesDavid Sterba1-0/+20
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: add helpers for parsing 32bit rangesDavid Sterba1-0/+32
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02btrfs-progs: extend parse_range API to accept a relaxed rangeDavid Sterba1-5/+25
In some cases we want to accept a range of type [a..a]. Add a new function to do the 'a < b' check for the caller and use it. Signed-off-by: David Sterba <dsterba@suse.com>