summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
...
* btrfs-progs: mkfs: handle and report transaction commit failuresDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: switch BUG_ON to error handling in traverse_directoryDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: document all btrfs_open_ctree_flagsDavid Sterba2016-08-24
| | | | | | Document and add unsigned type to the values. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: improve error handling in recow_rootsDavid Sterba2016-08-24
| | | | | | Return and handle errors in the callchain. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: improve error handling in main()David Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: return errors from block group creation functionsDavid Sterba2016-08-24
| | | | | | | No more BUG_ONs, we don't care about cleanup as the filesystem is supposed to be marked as partial. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: two staged filesystem creationDavid Sterba2016-08-24
| | | | | | | | | | | | | | | | | | | | | | | | The filesystem existence on a device is manifested by the signature, during the mkfs process we write it first and then create other structures. Such filesystem is not valid and should not be registered during device scan nor listed among devices from blkid. This patch will introduce two staged creation. In the first phase, the signature is wrong, but recognized as a partially created filesystem (by open or scan helpers). Once we successfully create and write everything, we fixup the signature. At this point automated scanning should find a valid filesystem on all devices. We can also rely on the partially created filesystem to do better error handling during creation. We can just bail out and do not need to clean up. The partial signature is '!BHRfS_M', can be shown by btrfs inspect-internal dump-super -F image Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: do not scan partially initialized devicesDavid Sterba2016-08-24
| | | | | | | | We call scan ioctl on the devices too early, when most of the filesystem structures are not yet created. Move the registration to the end, after the filesystem gets closed. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce signature for a partially set up filesystemDavid Sterba2016-08-24
| | | | | | | | | | | | Currently the superblock is created first, with a valid signaure, but the rest of the filesystem is missing. When the creation process is interrupted, the filesystem still might be considered as valid. To prevent that, create the filesytem with an invalid signature that would be still recognized during the mkfs process, and finalize at the end. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: make superblock reading/scanning api more genericDavid Sterba2016-08-24
| | | | | | We'll add more modes that affect scanning. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: pass OPEN_CTREE flags as unsignedDavid Sterba2016-08-24
| | | | | | | As we're passing a set of flags, the enum type is not appropriate. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: add more debugging featuresDavid Sterba2016-08-22
| | | | | | | | Add options to show file and line or stack trace for error/warning messages that use the common helpers. Possible to let any error stop execution for ease of analysis and debugging. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: switch ternary op to an if in cmd_subvol_showDavid Sterba2016-08-19
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: Print hex and human readable root flagsQu Wenruo2016-08-19
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: Print human readable inode flagsQu Wenruo2016-08-19
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert-test: Check if the ext2_save/image is read onlyQu Wenruo2016-08-19
| | | | | | | | | | | | | | | Old convert codes uses both 0400 permission and INODE_READONLY flag to make the converted ext2 image readonly. While new convert treat the inode just as normal inode, with no special inode flag and uses 0600 permission. This makes user able to modify converted image unintentionally and make rollback fails. This test case will test the regression. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix a regression that ext2_save/image is not readonlyQu Wenruo2016-08-19
| | | | | | | | | | | | | | | | | | The new convert treats the convert image as a normal file, without any special flags and permissions. This is different from original code: 1) Permission changed from 0400 to 0600 2) Inode lacks READONLY flag This makes we can read-write mount the ext2 image and cause rollback failure. Follow old code behavior, use 0400 permission and add back READONLY flag to fix it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: refer to btrfs(5) from btrfs(8)David Sterba2016-08-18
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: update btrfs-quota manual page, more sectionsDavid Sterba2016-08-18
| | | | | | Add more overall sections. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: docs: update btrfs-quota manual pageDavid Sterba2016-08-18
| | | | | | | | | | Copy the intoductory and usecases from the text written by Arne Jansen, https://git.kernel.org/cgit/linux/kernel/git/arne/qgroups-doc.git/ The graphics missing for now. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: switch to new error message helpersDavid Sterba2016-08-18
| | | | | | | Do not use fprintf, adjust messages, add verbose errno or at least the errorr code if there's no clear mapping to a string. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: no BUG_ON in close_ctreeDavid Sterba2016-08-18
| | | | | | There's no reason for it. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: adjust command line options for the low-memory modeDavid Sterba2016-08-17
| | | | | | | | Change the single-purpose option --low-memory to a generic option that takes the mode. Currently supported are the original mode and the low-memory in the same way. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce low memory modeLu Fengqi2016-08-17
| | | | | | | | | | | | | | | | | | | | | | | Introduce a new fsck mode: low memory mode. Old btrfsck is working efficiently but uses some memory for each extent item. This method will ensure extents are only iterated once at extent/chunk tree check process. But since it uses some memory for each extent item, for a large fs with several TB metadata, this can easily eat up memory and cause OOM. To handle such limitation and improve scalability, the new low-memory mode will not use any heap memory to record which extent is checked. Instead it will use extent backref to avoid most of uneeded checks on shared fs/subvolume tree blocks. And with the use forward and backward reference cross check, we can also ensure every tree block is at least checked once. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce traversal function for fsckLu Fengqi2016-08-17
| | | | | | | | | | Introduce a new function traverse_tree_block() to do pre-order traversal, to co-operate with new fs/subvolume tree skip function. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to speed up fs tree checkLu Fengqi2016-08-17
| | | | | | | | | | | | | | | | | | Introduce function should_check() to reduced duplicated tree block check for fs/subvolume tree. The idea is, we only check the fs/subvolue tree block if we have the lowest referencer rootid, according to extent tree. In that case, we can skip a lot of fs/subvolume tree block checks if there are a lot of snapshots. Although we will do a lot of extent tree searches for it. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce main entry function for checking leaf itemsLu Fengqi2016-08-17
| | | | | | | | | | | Introduce an entry function, check_leaf_items() to check all known/valuable items and update related accounting like total_bytes and csum_bytes. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check chunk itemLu Fengqi2016-08-17
| | | | | | | | | | | Introduce function check_chunk_item() to check a chunk item. It will check all chunk stripes with dev extents and the corresponding block group item. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check block group itemLu Fengqi2016-08-17
| | | | | | | | | | | Introduce function check_block_group_item() to check a block group item. It will check the referencer chunk and the used space accounting with extent tree. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check dev used spaceLu Fengqi2016-08-17
| | | | | | | | | | Introduce function check_dev_item() to check used space with dev extent items. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check dev extent itemLu Fengqi2016-08-17
| | | | | | | | | Introduce function check_dev_extent_item() to find its referencer chunk. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check an extentLu Fengqi2016-08-17
| | | | | | | | | | | | | Introduce function check_extent_item() using previously introduced functions. With previous function to check referencer and backref, this function can be quite easy. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check shared data backrefLu Fengqi2016-08-17
| | | | | | | | | | Introduce the function check_shared_data_backref() to check the referencer of a given shared data backref. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check referencer for data backrefLu Fengqi2016-08-17
| | | | | | | | | | Introduce new function check_extent_data_backref() to search referencer for a given data backref. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check shared block refLu Fengqi2016-08-17
| | | | | | | | | | Introduce function check_shared_block_backref() to check shared block ref. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check referencer of a backrefLu Fengqi2016-08-17
| | | | | | | | | | Introduce a new function check_tree_block_backref() to check if a backref points to correct referencer. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to query tree block levelLu Fengqi2016-08-17
| | | | | | | | | | | | | | | Introduce function query_tree_block_level() to resolve tree block level by the following method: 1) tree block backref level 2) tree block header level And only when header level == backref level, and transid matches, it will return the tree block level. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check data backref in extent treeLu Fengqi2016-08-17
| | | | | | | | | | Introduce a new function check_data_extent_item() to check if the corresponding data backref exists in extent tree. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: introduce function to check tree block backref in extent ↵Lu Fengqi2016-08-17
| | | | | | | | | | | | | | | | | | | tree Introduce function check_tree_block_ref() to check whether a tree block has correct backref in extent tree. Unlike old extent tree check method, we only use search_slot() to search reference, no extra structure will be allocated in heap to record what we have checked. This method may cause a little more IO, but should work for super large fs without triggering OOM. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: eliminate some unnecessary btrfs_lookup_extent_info() calls in ↵Wang Xiaoguang2016-08-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | walk_down_tree() In walk_down_tree(), we may call btrfs_lookup_extent_info() for same tree block many times, obviously unnecessary. Here we define a simple struct to record whether we already have gotten tree block's refs: struct node_refs { u64 bytenr[BTRFS_MAX_LEVEL]; u64 refs[BTRFS_MAX_LEVEL]; }; I fill a disk partition with linux kernel source codes and use below test script to have performance test. #!/bin/bash echo 3 > /proc/sys/vm/drop_caches for ((i = 0; i < 20; i++)); do time ./btrfsck /dev/sdc5 done 2>&1 | grep real | awk -F "[ms]" '{run_time += $2} END{print run_time / 20}' Before this patch, it averagely took 0.8447s for every btrfsck execution, and with this patch, it averagely took 0.7807s. Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.7David Sterba2016-07-29
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: update CHANGES for 4.7David Sterba2016-07-29
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leak with missing deviceJustin Maggard2016-07-29
| | | | | | | | | In read_one_chunk(), we may add an empty entry for a missing device. However, this entry wasn't being added to the dev_list, and so it never got freed. Signed-off-by: Justin Maggard <jmaggard@netgear.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix unaligned access in raid6 calculationsDavid Sterba2016-07-29
| | | | | | | | | | The raid6 code matches kernel implementation that also does the unaligned access. So to keep the code close, add helpers for unaligned native access and use them. The helpers are local as we don't plan to use them elsewhere. Reported-by: Anatoly Pugachev <matorola@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use proper unaligned helper in btrfs_csum_finalDavid Sterba2016-07-29
| | | | | | | | This will not cause unaligned access as the checksum is at the beginning of btrfs_header and thus aligned to a page, but for clarity use the helper. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi defrag: change default extent target size to 32 MiBDavid Sterba2016-07-28
| | | | | | | The kernel default is too low, 32 MiB is recommended and should give better results. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Doc: Fix format error in btrfs-sendQu Wenruo2016-07-28
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: handler memory allocation error in write_data_to_diskDavid Sterba2016-07-28
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: handle memory allocation error in __alloc_extent_bufferDavid Sterba2016-07-28
| | | | | | Drop the BUG() as all callers handle errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: update values of EXTENT_* bitsDavid Sterba2016-07-28
| | | | | | Make the values unsigned as we do various bit operations. Signed-off-by: David Sterba <dsterba@suse.com>