summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: corrupt-block: Correctly handle -r when passing -INikolay Borisov2018-06-07
| | | | | | | | | | | | | | | The documentation for the -I option (corrupt an item) states: An item to corrupt (must also specify the field to corrupt and a root+key for the item) The code on the other hand doesn't check whether -r is in fact passed, and even if it is it's not handled at all. This means presently -I is possible to corrupt items only in the root tree. Fix this by correctly checking -r is passed and fail otherwise and passing the correct root to corrupt_btrfs_item. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: corrupt-block: Factor out specific-root codeNikolay Borisov2018-06-07
| | | | | | | | Some options operate on a specific root so let's extract the code which deals with this. No functional change. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add DEBUG_CFLAGS_INTERNAL for libbtrfsutilGu JinXiang2018-06-07
| | | | | | | | Add DEBUG_CFLAGS_INTERNAL to LIBBTRFSUTIL_CFLAGS for libbtrfsutil's build. Signed-off-by: Gu JinXiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: ins: dump-tree: Print tree name for extent data/tree block backrefMisono Tomohiro2018-06-07
| | | | | | | | | | | | | | | | | | | Print tree name instead of number to make output more readable. Example: [before] extent data backref root 5 objectid 257 offset 16384 count 1 tree block backref root 18446744073709551607 [after] extent data backref root FS_TREE objectid 257 offset 16384 count 1 tree block backref root DATA_RELOC_TREE Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: ins: dump-tree: Use %lld for extent data backref offsetMisono Tomohiro2018-06-07
| | | | | | | | Offset of extent data backref in extent item can be negative. So, let's use %lld insteand of %llu to output readable value. Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: restore: fix mistake on overwrite_ok() if relative path is givenTing-Chang Hou2018-06-07
| | | | | | | | | | fstatat will return -1 with errno EBADF if path_name is relative path. This caused an error of the return value of overwrite_ok(). When restoring the subvolume to destination with relative path, it will overwrite the existing file rather than skip it. Signed-off-by: tchou <tchou@synology.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: Enhance btrfs_print_tree() check to avoid ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | out-of-boundary memory access For btrfs_print_tree(), if nr_items is corrupted, it can easily go beyond extent buffer boundary. Add extra nr_item check, and only print as many valid slots as possible. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use symbolic names for read ahead behaviorNikolay Borisov2018-06-07
| | | | | | | | | | Presently btrfs-progs haven't pulled the enum defining the symbolic names of read ahead constants. This commit adds the enum and simultaneously converts all usages to respective symbolic name. No functional change, just making the code human readable. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck-tests: add test case to check symlinks with bad flagsSu Yue2018-06-07
| | | | | | | | There are two bad symlinks in the test case. One is with immutable attribute. Another one is with append attribute. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: check symlinks with append/immutable flagsSu Yue2018-06-07
| | | | | | | | | | | | | | | | Define new error bit INODE_FLAGS_ERROR to represents invalid inode flags error. Symlinks should never have append/immutable flags set. While checking inodes, if found a symlink with append/immutable flags, report and record the inode flags error. This is for lowmem mode. Issue: #133 Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: check symlinks with append/immutable flagsSu Yue2018-06-07
| | | | | | | | | | | | | | | Define new macro I_ERR_ODD_INODE_FLAGS to represents odd inode flags. Symlinks should never have append/immutable flags. While processing inodes, if found a symlink with append/immutable flags, mark the inode record with I_ERR_ODD_INODE_FLAGS. This is for original mode. Issue: #133 Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove fs_info argument from write_ctree_superNikolay Borisov2018-06-07
| | | | | | | | | This function already takes a transaction handle which has a reference to the fs_info, so use that to obtain it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove root argument from write_one_cache_groupNikolay Borisov2018-06-07
| | | | | | | | | It's not needed since we can acquire a reference to the fs_info from the transaction handle already passed. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove root argument from btrfs_set_block_flagsNikolay Borisov2018-06-07
| | | | | | | | | It's used only to get a reference to fs_info, which can be obtained from the transaction handle. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Change btrfs_root to btrfs_fs_info argument in ↵Nikolay Borisov2018-06-07
| | | | | | | | | | | btrfs_lookup_extent_info That function really wants an fs_info and not a root. Accidentally, this also makes the kernel/user space signatures to be coherent. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove unused root argument from btrfs_extent_post_opNikolay Borisov2018-06-07
| | | | | | | | This is no longer used by the callees of that function so remove it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove unused argument from clean_tree_blockNikolay Borisov2018-06-07
| | | | | | | | | | This function actually uses only the extent_buffer arg but takes 3 arguments. Furthermore, it's current interface doesn't even mirror the kernel counterpart. Just remove the extra arguments. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Make update_pinned_extents take btrfs_fs_infoNikolay Borisov2018-06-07
| | | | | | | | | This function needs btrfs_fs_info and not a root. So make it directly take btrfs_fs_info, Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove root argument from finish_current_insertNikolay Borisov2018-06-07
| | | | | | | | Just reference it directly from trans->fs_info. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove root parameter from del_pending_extentsNikolay Borisov2018-06-07
| | | | | | | | | | This function always operates on the extent root which can be referenced from trans->fs_info. Do that to simplify function's signature. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove root parameter from btrfs_fix_block_accountingNikolay Borisov2018-06-07
| | | | | | | | | | It's always set to extent_root and the function already takes a transaction handle where fs_info could be referenced and in turn the extent_tree. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove root argument from delete_extent_recordsNikolay Borisov2018-06-07
| | | | | | | | | | | | | This function is always passed the extent_root as "root" parameter. In turn it uses the root parameter to mostly access fs_info and performs only a single call to btrfs_update_block_group where it passses the passed root. This is all redundant since fs_info can be referenced from the transaction handle and in turn extent_root can be referenced from the fs_info. So do that to simplify the function's signature. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: test mkfs.btrfs fails on small backing size thin ↵Su Yue2018-06-07
| | | | | | | | | | | | | | | provision device This tests is most similar to xfstests generic/405. It calls device mapper to create a thin provision device with small backing size and big virtual size. mkfs.btrfs should fail on such devices. This test should pass after commit e805b143a4fe ("btrfs-progs: mkfs: return nozero value on thin provisioned device"). Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: do not merge tree block refs have different root_idSu Yue2018-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For an extent item which contains many tree block backrefs, like In 020-extent-ref-cases/keyed_block_ref.img item 10 key (29470720 METADATA_ITEM 0) itemoff 3450 itemsize 222 refs 23 gen 10 flags TREE_BLOCK tree block skinny level 0 tree block backref root 278 tree block backref root 277 tree block backref root 276 tree block backref root 275 tree block backref root 274 tree block backref root 273 tree block backref root 272 tree block backref root 271 tree block backref root 270 tree block backref root 269 tree block backref root 268 tree block backref root 267 tree block backref root 266 tree block backref root 265 tree block backref root 264 tree block backref root 263 tree block backref root 262 tree block backref root 261 tree block backref root 260 tree block backref root 259 tree block backref root 258 tree block backref root 257 In find_parent_nodes(), these refs's parents are 0, then __merge_refs will merge refs to one ref. It causes only one root to be returned. So, if both parents are 0, do not merge refs. Lowmem check calls find_parent_nodes frequently to decide whether check an extent buffer or not. The bug affects bytes accounting. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove useless branch in __merge_refsSu Yue2018-06-07
| | | | | | | | | | | After call of ref_for_same_block, ref1->parent must equals to ref2->parent, the block of exchange is never reached. So remove the block of exchange. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove comments about delayed ref in backref.cSu Yue2018-06-07
| | | | | | | | There is no delayed ref in btrfs-progs, so remove related comments. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Allow tree to be printed without an fs_infoQu Wenruo2018-06-07
| | | | | | | | | | | | | | | | | | | | | | | | For btrfs_print_tree() and btrfs_print_leaf(), the usage of fs_info is mainly for nodesize and sectorsize. However for nodesize, we can get it from @eb->len without the need for fs_info at all. For nodesize, introduce new helper BTRFS_NODEPTR_PER_EXTENT_BUFFER() to get nodesize from @eb directly. And with the help of previous modified btrfs_leaf_free_space(), btrfs_print_tree() can live without fs_info at all. For btrfs_print_leaf(), we modify print_extent_csum() to accept NULL fs_info by skipping csum length calculation. With all these modification, btrfs_print_tree/leaf() can be called without accessing @fs_info at all, and make it more flexible to handle binary tree block dump, or inside gdb. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove fs_info parameter from btrfs_leaf_free_space()Qu Wenruo2018-06-07
| | | | | | | | | | | | | | | | | For btrfs_leaf_free_space(), to get leaf data size, we have two way to get it: 1) leaf->fs_info->nodesize 2) leaf->len Anyway, we could get rid of @fs_info parameter for btrfs_leaf_free_space(). And here we choose method 2), as it provides extra benefit to get leaf free space without initializing a real fs_info. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: detect whether -std=gnu90 is supportedJeff Mahoney2018-06-07
| | | | | | | | | | | | | | GCC releases prior to 4.5.0 don't support -std=gnu90 so btrfs-progs won't build at all on older distros. We can detect whether the compiler supports -std=gnu90 and fall back to -std=gnu89 if it doesn't. AX_CHECK_COMPILE_FLAG is the right way to do this, but it depends on autoconf 2.64. AX_GCC_VERSION has been deprecated, so we'll use that only for earlier autoconf versions so we can drop it when we drop support for older autoconf releases. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: autoconf 2.63 compatibilityJeff Mahoney2018-06-07
| | | | | | | | | | Commit 2e1932e6a38 (btrfs-progs: build: simplify version tracking) started m4_chomp to strip the newlines from the version file. m4_chomp was introduced in autoconf 2.64 but SLE11 ships with autoconf 2.63. For purposes of just stripping the newline, m4_flatten is sufficient. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: fix support for e2fsprogs < 1.42Jeff Mahoney2018-06-07
| | | | | | | | | | | | | | | | | | Commit 324d4c1857a (btrfs-progs: convert: Add larger device support) introduced new dependencies on the 64-bit API provided by e2fsprogs. That API was introduced in v1.42 (along with bigalloc). This patch maps the following to their equivalents in e2fsprogs < 1.42. - ext2fs_get_block_bitmap_range2 - ext2fs_inode_data_blocks2 - ext2fs_read_ext_attr2 Since we need to detect and define EXT2_FLAG_64BITS for compatibilty anyway, it makes sense to use that to detect the older e2fsprogs instead of defining a new flag ourselves. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: change to output more info without root privilegeMisono Tomohiro2018-06-07
| | | | | | | | | | | | | | | | Although per device usage cannot be shown without root privilege, per profile usage can be shown. To achieve this, we just basically need to remove the check of nullness of chunkinfo in print_filesystem_usage_by_chunk(), because other functions except print_unused() properly handles chunkinfo by chunkcount, which is 0 if chunkinfo is null. As a result, "fi usage" always includes the information of "fi df". Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: change warning message more appropriatelyMisono Tomohiro2018-06-07
| | | | | | | | | | | | "fi usage" shows the warning "RAID5/6 numbers will be incorrect" when running without root privilege even if raid5/6 is not used. What happens is it cannot get the per device profile usage info, so change the message more appropriately. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> [ adjust message ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Make __btrfs_fs_incompat return boolNikolay Borisov2018-06-07
| | | | | | | | | | First this function does the '!!' trick to turn its value into a bool, yet the return type is int. Second, the kernel counterpart also returns bool. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove ext_ref local variable from check_fs_roots_lowmemNikolay Borisov2018-06-07
| | | | | | | | | All real consumers of that variable have inlined the checks since they are simple enough. So just remove it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref arument from check_fs_rootNikolay Borisov2018-06-07
| | | | | | | | It's no longer used so just remove it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref param from check_fs_first_inodeNikolay Borisov2018-06-07
| | | | | | | | It's no longer used in that function so can be dropped altogether. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove ext_ref param from walk_down_treeNikolay Borisov2018-06-07
| | | | | | | | It's no longer used so just remove it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Remove ext_ref param from check_fs_first_inodeNikolay Borisov2018-06-07
| | | | | | | | It's no longer use and can be dropped. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop unused ext_ref parameter from process_one_leafNikolay Borisov2018-06-07
| | | | | | | | It's no longer used in the function so just remove it Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref argument from check_inode_itemNikolay Borisov2018-06-07
| | | | | | | | | We can derive this argument from root->fs_info and also make it local to the sole switch case it's used. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref param from check_dir_itemNikolay Borisov2018-06-07
| | | | | | | | This parameter is no longer used in this function, so drop it Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref parameter from find_inode_refNikolay Borisov2018-06-07
| | | | | | | | | | This is a boolean parameter which signals whether the fs has the EXTENDED_IREF feature flag toggled or not. Since a reference to fs_info can be obtained there is no need to pollute the interface. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for collision DIR_ITEM handlingNikolay Borisov2018-06-07
| | | | | | | | | | | | | | Verify that if we have an otherwise clean filesystem, containging collided DIR_ITEM, btrfs check lowmem's mode can correctly handle those and not produce any false positives. This if fixed by commit titled: "btrfs-progs: check: fix DIR_ITEM checking in lowmem" Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: fix DIR_ITEM checking in lowmemNikolay Borisov2018-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When checking the validity of a DIR_ITEM item the index variable is explicitly set to -1 so that the index check in find_inode_ref() is ignored. This is necessary due to possible name collisions in DIR_ITEMS (i.e. multiple files with the same crc32c for their names, resulting in the identical key->offset). Currently the code is broken due to index being set to -1 at the beginning of check_dir_item and subsequently reset to the index found in find_inode_ref. On subsequent iterations of the while loop in check_dir_items we are going to erroneously perform index checking, since index is not -1 but whatever the index value of the last handled INODE_REF ITEM. Without this patch check in lowmem mode produces the following false warnings positivess: ERROR: root 5 INODE REF[1991456, 256] name 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK filetype 1 missing But the items for this name are in fact correct: ------------------SNIP------------------------ item 13 key (256 DIR_ITEM 4227063046) itemoff 2945 itemsize 140 location key (220890 INODE_ITEM 0) type FILE transid 2278 data_len 0 name_len 40 name: 5ab4e1bb~~~~~~~~65KNTAWVJ5VD4SV2R3BKFCXL location key (1991456 INODE_ITEM 0) type FILE transid 2285 data_len 0 name_len 40 name: 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK item 21 key (1991456 INODE_REF 256) itemoff 2104 itemsize 50 index 1934146 namelen 40 name: 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK -------------------SNIP------------------------- Fix this by moving the code setting index at the beginning of the while loop. This ensure that for each item in DIR_ITEM we have index set correctly. Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()") Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case to ensure btrfs check returns error for ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | corrupted qgroups Since the test case uses run_mustfail(), which is pretty easy pass due to other unexpected problems, so here an extra run_check() is added to ensure we don't only report qgroup error, but also fix it without problem. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Make btrfs check return error for qgroup mismatchQu Wenruo2018-06-07
| | | | | | | | | | | | | | | Current btrfs-check will check qgroup consistency, but even when it finds something wrong, the return value is still 0. Fix it by allowing report_qgroups() to return int to indicate qgroup mismatch, and also add extra logic to return no error if qgroup repair is successful. Without this patch, fstests can't detect qgroup corruption by its fsck alone. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use exclude_super_stripes instead of account_super_bytesNikolay Borisov2018-06-07
| | | | | | | | | | | | | | | | | | Originally commit 2681e00f00fe ("btrfs-progs: check for matchingi free space in cache") added the account_super_bytes function to prevent false negative when running btrfs check. Turns out this function is really copied exclude_super_stripes, excluding the calls to exclude_super_stripes. Later commit e4797df6a9fa ("btrfs-progs: check the free space tree in btrfsck") introduced proper version of exclude_super_stripes. Instead of duplicating the function, just remove account_super_bytes and use exclude_super_stripes instead of the former. This also has the benefit of bringing the userspace code a bit closer to the kernel counterpart. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: check btrfs qgroup parent-child relation outputLu Fengqi2018-06-07
| | | | | | | | | | | Since commit aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments") cause qgroup show to output the wrong qgroup parent-child relationship, in addition to fixing the problem, a test case is needed to prevent the similar problem in the future. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relationLu Fengqi2018-06-07
| | | | | | | | | | | | | | | The QGROUP_RELATION item is very special, it always exists in pairs (with objectid and offset exchanged). Its objectid and offset are the ids of a pair of parent and child qgroups, respectively. The larger one is parent and the smaller one is child. After the following commit, the order of the parameters is wrong and causes qgroup show to output the wrong qgroup parent-child relationship. Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments") Issue: #129 Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>