David Sterba [Fri, 19 Aug 2016 14:20:36 +0000 (16:20 +0200)]
btrfs-progs: pass OPEN_CTREE flags as unsigned
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>
David Sterba [Fri, 19 Aug 2016 14:06:41 +0000 (16:06 +0200)]
btrfs-progs: build: add more debugging features
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>
David Sterba [Fri, 19 Aug 2016 13:45:04 +0000 (15:45 +0200)]
btrfs-progs: switch ternary op to an if in cmd_subvol_show
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 19 Aug 2016 08:13:08 +0000 (16:13 +0800)]
btrfs-progs: print-tree: Print hex and human readable root flags
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 19 Aug 2016 08:13:07 +0000 (16:13 +0800)]
btrfs-progs: print-tree: Print human readable inode flags
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 19 Aug 2016 08:13:06 +0000 (16:13 +0800)]
btrfs-progs: convert-test: Check if the ext2_save/image is read only
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>
Qu Wenruo [Fri, 19 Aug 2016 08:13:05 +0000 (16:13 +0800)]
btrfs-progs: convert: Fix a regression that ext2_save/image is not readonly
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>
David Sterba [Thu, 18 Aug 2016 17:50:06 +0000 (19:50 +0200)]
btrfs-progs: docs: refer to btrfs(5) from btrfs(8)
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 18 Aug 2016 17:25:10 +0000 (19:25 +0200)]
btrfs-progs: docs: update btrfs-quota manual page, more sections
Add more overall sections.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 18 Aug 2016 17:25:10 +0000 (19:25 +0200)]
btrfs-progs: docs: update btrfs-quota manual page
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>
David Sterba [Thu, 18 Aug 2016 16:38:34 +0000 (18:38 +0200)]
btrfs-progs: mkfs: switch to new error message helpers
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>
David Sterba [Thu, 18 Aug 2016 15:44:18 +0000 (17:44 +0200)]
btrfs-progs: no BUG_ON in close_ctree
There's no reason for it.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 17 Aug 2016 17:33:24 +0000 (19:33 +0200)]
btrfs-progs: check: adjust command line options for the low-memory mode
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>
Lu Fengqi [Sun, 24 Apr 2016 07:47:12 +0000 (15:47 +0800)]
btrfs-progs: check: introduce low memory mode
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>
Lu Fengqi [Sun, 24 Apr 2016 07:35:41 +0000 (15:35 +0800)]
btrfs-progs: check: introduce traversal function for fsck
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>
Lu Fengqi [Sun, 24 Apr 2016 07:24:56 +0000 (15:24 +0800)]
btrfs-progs: check: introduce function to speed up fs tree check
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>
Lu Fengqi [Sun, 24 Apr 2016 07:07:59 +0000 (15:07 +0800)]
btrfs-progs: check: introduce main entry function for checking leaf items
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>
Lu Fengqi [Sun, 24 Apr 2016 07:00:24 +0000 (15:00 +0800)]
btrfs-progs: check: introduce function to check chunk item
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>
Lu Fengqi [Sun, 24 Apr 2016 06:41:41 +0000 (14:41 +0800)]
btrfs-progs: check: introduce function to check block group item
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>
Lu Fengqi [Sun, 24 Apr 2016 06:17:10 +0000 (14:17 +0800)]
btrfs-progs: check: introduce function to check dev used space
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>
Lu Fengqi [Sun, 24 Apr 2016 05:54:28 +0000 (13:54 +0800)]
btrfs-progs: check: introduce function to check dev extent item
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>
Lu Fengqi [Sun, 24 Apr 2016 05:45:28 +0000 (13:45 +0800)]
btrfs-progs: check: introduce function to check an extent
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>
Lu Fengqi [Sun, 24 Apr 2016 05:33:47 +0000 (13:33 +0800)]
btrfs-progs: check: introduce function to check shared data backref
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>
Lu Fengqi [Sat, 23 Apr 2016 08:58:24 +0000 (16:58 +0800)]
btrfs-progs: check: introduce function to check referencer for data backref
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>
Lu Fengqi [Sat, 23 Apr 2016 08:35:04 +0000 (16:35 +0800)]
btrfs-progs: check: introduce function to check shared block ref
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>
Lu Fengqi [Sat, 23 Apr 2016 08:08:40 +0000 (16:08 +0800)]
btrfs-progs: check: introduce function to check referencer of a backref
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>
Lu Fengqi [Sat, 23 Apr 2016 07:56:50 +0000 (15:56 +0800)]
btrfs-progs: check: introduce function to query tree block level
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>
Lu Fengqi [Sat, 23 Apr 2016 07:26:25 +0000 (15:26 +0800)]
btrfs-progs: check: introduce function to check data backref in extent tree
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>
Lu Fengqi [Sat, 23 Apr 2016 06:40:37 +0000 (14:40 +0800)]
btrfs-progs: check: introduce function to check tree block backref in extent 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>
Wang Xiaoguang [Tue, 16 Aug 2016 06:17:57 +0000 (14:17 +0800)]
btrfs-progs: eliminate some unnecessary btrfs_lookup_extent_info() calls in 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>
David Sterba [Fri, 29 Jul 2016 13:06:42 +0000 (15:06 +0200)]
Btrfs progs v4.7
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 28 Jul 2016 12:18:59 +0000 (14:18 +0200)]
btrfs-progs: update CHANGES for 4.7
Signed-off-by: David Sterba <dsterba@suse.com>
Justin Maggard [Thu, 28 Jul 2016 17:44:11 +0000 (10:44 -0700)]
btrfs-progs: fix memory leak with missing device
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>
David Sterba [Thu, 28 Jul 2016 17:56:20 +0000 (19:56 +0200)]
btrfs-progs: fix unaligned access in raid6 calculations
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>
David Sterba [Thu, 28 Jul 2016 17:36:50 +0000 (19:36 +0200)]
btrfs-progs: use proper unaligned helper in btrfs_csum_final
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>
David Sterba [Thu, 28 Jul 2016 11:14:08 +0000 (13:14 +0200)]
btrfs-progs: fi defrag: change default extent target size to 32 MiB
The kernel default is too low, 32 MiB is recommended and should give
better results.
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 28 Jul 2016 08:28:25 +0000 (16:28 +0800)]
btrfs-progs: Doc: Fix format error in btrfs-send
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 28 Jul 2016 00:16:43 +0000 (02:16 +0200)]
btrfs-progs: handler memory allocation error in write_data_to_disk
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 28 Jul 2016 00:04:30 +0000 (02:04 +0200)]
btrfs-progs: handle memory allocation error in __alloc_extent_buffer
Drop the BUG() as all callers handle errors.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 23:56:06 +0000 (01:56 +0200)]
btrfs-progs: update values of EXTENT_* bits
Make the values unsigned as we do various bit operations.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 23:47:40 +0000 (01:47 +0200)]
btrfs-progs: refactor and extend btrfs_prepare_device arguments
The message about discard is printed unconditionally and does not
conform to the --quite option eg. in mkfs. Consolidate the operation
flags into one argument and add support for verbosity.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 21:27:05 +0000 (23:27 +0200)]
btrfs-progs: use values directly for BLOCK_GROUP_ macros
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 21:19:20 +0000 (23:19 +0200)]
btrfs-progs: use unsigned type for extent_buffer flags
We're doing bit operations.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 20:30:52 +0000 (22:30 +0200)]
btrfs-progs: fix unaligned access calculating raid56 data
The extent_buffer::data might be unaligned wrt unsigned long, depends on
acutal layout of the structure and width of the int types. Use explicit
unaligned access helpers.
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 27 Jul 2016 21:13:09 +0000 (23:13 +0200)]
btrfs-progs: kerncompat: introduce put_unaligned_x helpers
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 26 Jul 2016 17:33:12 +0000 (19:33 +0200)]
btrfs-progs: docs: update btrfs-balance manual page
Update the new options.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 26 Jul 2016 17:30:39 +0000 (19:30 +0200)]
btrfs-progs: balance: add another (shorter) option for background
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 26 Jul 2016 17:11:42 +0000 (19:11 +0200)]
btrfs-progs: balance: silence compiler warning
cmds-balance.c: In function 'cmd_balance_start':
cmds-balance.c:654:6: warning: ignoring return value of 'chdir', declared with
attribute warn_unused_result [-Wunused-result]
chdir("/");
Reported-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Austin S. Hemmelgarn [Tue, 21 Jun 2016 15:16:59 +0000 (11:16 -0400)]
btrfs-progs: add option to run balance as daemon
Currently, balance operations are run synchronously in the foreground.
This is nice for interactive management, but is kind of crappy when you
start looking at automation and similar things.
This patch adds an option to `btrfs balance start` to tell it to
daemonize prior to running the balance operation, thus allowing us to
preform balances asynchronously. The two biggest use cases I have for
this are starting a balance on a remote server without establishing a
full shell session, and being able to background the balance in a
recovery shell (which usually has no job control) so I can still get
progress information.
Because it simply daemonizes prior to calling the balance ioctl, this
doesn't actually need any kernel support.
Signed-off-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Omar Sandoval [Fri, 15 Jul 2016 19:12:48 +0000 (12:12 -0700)]
btrfs-progs: fix btrfsck of space_cache=v2 bitmaps on big-endian
Copy le_test_bit() from the kernel and use that for the free space tree
bitmaps.
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 15 Jul 2016 15:00:56 +0000 (17:00 +0200)]
btrfs-progs: corrupt block: handle eb read and write errors
Resolves-coverity-id: 1261558
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 15 Jul 2016 14:46:08 +0000 (16:46 +0200)]
btrfs-progs: corrupt block: handle block mapping errors in debug_corrupt_block
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 15 Jul 2016 14:38:07 +0000 (16:38 +0200)]
btrfs-progs: corrupt block: pass eb as argument to debug_corrupt_block
Allocate the eb externally so we can handle the easy errors in advance.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 15 Jul 2016 14:27:06 +0000 (16:27 +0200)]
btrfs-progs: image: fix minor resource leak
It's on error exit path.
Resolves-coverity-id: 1354246
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 15 Jul 2016 14:12:00 +0000 (16:12 +0200)]
btrfs-progs: handle ulist_add errors in qgroup-verify
Resolves-coverity-id: 1364084
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Fri, 15 Jul 2016 01:40:27 +0000 (18:40 -0700)]
Btrfs-progs: fix btrfs-map-logical to only print extent mapping info
I have a valid btrfs image which contains,
...
item 10 key (
1103101952 BLOCK_GROUP_ITEM
1288372224) itemoff 15947 itemsize 24
block group used 655360 chunk_objectid 256 flags DATA|RAID5
item 11 key (
1103364096 EXTENT_ITEM 131072) itemoff 15894 itemsize 53
extent refs 1 gen 11 flags DATA
extent data backref root 5 objectid 258 offset 0 count 1
item 12 key (
1103888384 EXTENT_ITEM 262144) itemoff 15841 itemsize 53
extent refs 1 gen 15 flags DATA
extent data backref root 1 objectid 256 offset 0 count 1
item 13 key (
1104281600 EXTENT_ITEM 262144) itemoff 15788 itemsize 53
extent refs 1 gen 15 flags DATA
extent data backref root 1 objectid 257 offset 0 count 1
...
The extent [
1103364096, 131072) has length 131072, but if we run
"btrfs-map-logical -l
1103364096 -b $((65536 * 3)) /dev/sda"
it will return mapping info 's of non-existing extents.
It's because it assumes that extents's are contiguous on logical address,
when it's not true, after one loop (cur_logical += cur_len) and mapping
the next extent, we can get an extent that is out of our search range and
we end up with a negative @real_len and printing all mapping infos till
the disk end.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 14 Jul 2016 23:25:12 +0000 (01:25 +0200)]
btrfs-progs: tests: add 007-unsupported-block-sizes
Check if block sizes smaller than 4k expectedly fail to convert.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 14 Jul 2016 21:43:38 +0000 (23:43 +0200)]
btrfs-progs: docs: update btrfs manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 14 Jul 2016 21:43:38 +0000 (23:43 +0200)]
btrfs-progs: docs: update btrfs-convert manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 14 Jul 2016 21:43:38 +0000 (23:43 +0200)]
btrfs-progs: docs: update btrfs-filesystem manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 14 Jul 2016 21:35:26 +0000 (23:35 +0200)]
btrfs-progs: docs: update btrfs-scrub manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 13 Jul 2016 17:41:55 +0000 (19:41 +0200)]
btrfs-progs: do not set optind if not necessary
In the subcommand callbacks that are called just once, we don't need to
explicitly reset optind.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 13 Jul 2016 17:05:23 +0000 (19:05 +0200)]
btrfs-progs: balance: use errno directly
No need to store the errno in a local variable.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 13 Jul 2016 17:00:01 +0000 (19:00 +0200)]
btrfs-progs: balance: cleanup, switch to common exit block
Call close_file_or_dir at the end of the function and replace returns by
gotos to the exit block.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 12 Jul 2016 15:47:23 +0000 (17:47 +0200)]
btrfs-progs: docs: update btrfs-subvolume manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 12 Jul 2016 15:13:16 +0000 (17:13 +0200)]
btrfs-progs: docs: update btrfs-balance manual page
Signed-off-by: David Sterba <dsterba@suse.com>
Wang Shilong [Thu, 7 Jul 2016 09:43:38 +0000 (18:43 +0900)]
btrfs-progs: du: fix to skip not btrfs dir/file
'btrfs file du' is a very useful tool to watch my system
file usage information with snapshot aware.
when trying to run following commands:
[root@localhost btrfs-progs]# btrfs file du /
Total Exclusive Set shared Filename
ERROR: Failed to lookup root id - Inappropriate ioctl for device
ERROR: cannot check space of '/': Unknown error -1
and My Filesystem looks like this:
[root@localhost btrfs-progs]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 16G 368K 16G 1% /dev/shm
tmpfs tmpfs 16G 1.4M 16G 1% /run
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda3 btrfs 60G 19G 40G 33% /
tmpfs tmpfs 16G 332K 16G 1% /tmp
/dev/sdc btrfs 2.8T 166G 1.7T 9% /data
/dev/sda2 xfs 2.0G 452M 1.6G 23% /boot
/dev/sda1 vfat 1.9G 11M 1.9G 1% /boot/efi
tmpfs tmpfs 3.2G 24K 3.2G 1% /run/user/1000
So I installed Btrfs as my root partition, but boot partition
can be other fs.
We can Let btrfs tool aware of this is not a btrfs file or
directory and skip those files, so that someone like me
could just run 'btrfs file du /' to scan all btrfs filesystems.
After patch, it will look like:
Total Exclusive Set shared Filename
0.00B 0.00B - //root/.bash_logout
0.00B 0.00B - //root/.bash_profile
0.00B 0.00B - //root/.bashrc
0.00B 0.00B - //root/.cshrc
0.00B 0.00B - //root/.tcshrc
This works for me to analysis system usage and analysis
performaces.
Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Tsutomu Itoh [Thu, 9 Jun 2016 01:23:15 +0000 (10:23 +0900)]
btrfs-progs: add the error message when open fails
When open in btrfs_open_devices failed, only the following message is
displayed. Therefore the user doesn't understand the reason why open
failed.
# btrfs check /dev/sdb8
Couldn't open file system
This patch adds the error message when open fails.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 8 Jul 2016 15:04:25 +0000 (17:04 +0200)]
btrfs-progs: docs: man5, document control device
Signed-off-by: David Sterba <dsterba@suse.com>
Luis Henriques [Mon, 4 Jul 2016 22:48:47 +0000 (23:48 +0100)]
btrfs-progs: tests: 006-image-on-missing-device: fix btrfs tool path
If btrfs isn't in the path, this test will fail with:
[TEST/misc] 006-image-on-missing-device
failed: btrfs fi show /dev/loop0
test failed for case 006-image-on-missing-device
Makefile:226: recipe for target 'test-misc' failed
make: *** [test-misc] Error 1
Fix the test script by adding $TOP to the path.
Signed-off-by: Luis Henriques <henrix@camandro.org>
[ updated to full command names ]
Signed-off-by: David Sterba <dsterba@suse.com>
Mark Fasheh [Mon, 4 Jul 2016 12:57:38 +0000 (14:57 +0200)]
btrfs-progs: check: write corrected qgroup info to disk
Now that we can verify all qgroups, we can write the corrected qgroups out
to disk when '--repair' is specified. The qgroup status item is also updated
to clear any out-of-date state. The repair_ functions were modeled after the
inode repair code in cmds-check.c.
I also renamed the 'scan' member of qgroup_status_item to 'rescan' in order
to keep consistency with the kernel.
Testing this was easy, I just reproduced qgroup inconsistencies via the
usual routes and had btrfsck fix them.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
Mark Fasheh [Fri, 17 Jun 2016 20:37:48 +0000 (13:37 -0700)]
btrfs-progs: check: verify qgroups above level 0
At the moment we only check subvolume quota groups (level 0). With this
patch we can check groups above 0, thus verifying the entire qgroup
hierarchy on a file system. The accounting portion of this patch is modeled
after the kernel - we are essentially reimplementing the 'quota rescan' case
here. Most other sections of this code went unchanged, in particular the
root counting works independently of the accounting.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 4 Jul 2016 13:22:53 +0000 (15:22 +0200)]
btrfs-progs: factor out repair mode
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Thu, 23 Jun 2016 19:26:06 +0000 (15:26 -0400)]
btrfs-progs: check: switch to iterating over the backref_tree
We now have two data structures that can be used to iterate the same data
set, and there may be quite a few of them in memory. Eliminating the
list_head member will reduce memory consumption while iterating over
the extent backrefs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Thu, 23 Jun 2016 19:26:05 +0000 (15:26 -0400)]
btrfs-progs: check: supplement extent backref list with rbtree
For the pathlogical case, like xfstests generic/297 that creates a
large file consisting of one, repeating reflinked extent, fsck can
take hours. The root cause is that calling find_data_backref while
iterating the extent records is an O(n^2) algorithm. For my
example test run, n was 2*2^20 and fsck was at 8 hours and counting.
This patch supplements the list with an rbtree and drops the runtime
of that testcase to about 20 seconds.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Thu, 23 Jun 2016 19:26:04 +0000 (15:26 -0400)]
btrfs-progs: check: add helpers for converting between structures
We either open code list_entry calls or outright cast between types. The
compiler will do the right thing if we use static inlines to do
typesafe conversions.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Hans van Kranenburg [Sun, 3 Jul 2016 21:22:26 +0000 (23:22 +0200)]
btrfs-progs: use the correct struct for BTRFS_IOC_LOGICAL_INO
BTRFS_IOC_LOGICAL_INO takes a btrfs_ioctl_logical_ino_args as argument,
not a btrfs_ioctl_ino_path_args. The lines were probably copy/pasted
when the code was written.
Since btrfs_ioctl_logical_ino_args and btrfs_ioctl_ino_path_args have
the same size, the actual IOCTL definition here does not change.
But, it makes the code less confusing for the reader.
Signed-off-by: Hans van Kranenburg <hans.van.kranenburg@mendix.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Wang Xiaoguang [Fri, 1 Jul 2016 05:26:25 +0000 (13:26 +0800)]
btrfs-progs: mkfs: fix allocation information output of block group types
When cleanup_temp_chunks() removes block groups, it forgot to update
mkfs_allocation accordingly, fix this.
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 4 Jul 2016 11:45:15 +0000 (13:45 +0200)]
btrfs-progs: tests: use /bin/bash for scripts
Since we use 'source' in scripts, let's use bash everywhere.
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Mon, 27 Jun 2016 07:50:11 +0000 (15:50 +0800)]
btrfs-progs: convert-test: Add test case for discontinuous hole extent
For ext* fs containing a large hole(larger than 128M), btrfs-convert
will only insert one 128M hole extent and skip the remaining.
This leads to discontinuous file extents.
Add test case for it, and since it's a pinpoint regression test case, no
combination of convert options nor checksum verification.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Mon, 27 Jun 2016 07:50:10 +0000 (15:50 +0800)]
btrfs-progs: convert: Fix a bug leads to discontinuous extents
Btrfs_record_file_extent() will split extents using max extent size(128M).
It works well for real file extents, but not that well for large
hole extent, as hole doesn't have extent size limit.
In that case, it will only insert one 128M hole, and skip the rest,
leading to discontinuous extent error for converted btrfs.
Fix it by not splitting hole extents.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Luis Henriques [Fri, 24 Jun 2016 23:47:29 +0000 (00:47 +0100)]
btrfs-progs: tests: 001-simple-unmounted: fix test failure due to bashism
The usage of 'source' is a bashism, and '.' should be used instead. This
is causing fuzz-tests/001-simple-unmounted to fail in systems where
/bin/sh isn't bash:
[TEST/fuzz] 001-simple-unmounted
./test.sh: 5: ./test.sh: source: not found
./test.sh: 7: ./test.sh: setup_root_helper: not found
./test.sh: 8: ./test.sh: check_prereq: not found
./test.sh: 18: ./test.sh: check_all_images: not found
Since most (all?) tests actually use /bin/bash, change this test to use
bash too.
Signed-off-by: Luis Henriques <henrix@camandro.org>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 24 Jun 2016 12:10:31 +0000 (14:10 +0200)]
Btrfs progs v4.6.1
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 8 Jun 2016 09:40:02 +0000 (11:40 +0200)]
btrfs-progs: update CHANGES for 4.6.1
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 24 Jun 2016 12:04:04 +0000 (14:04 +0200)]
btrfs-progs: build: check if FIEMAP_EXTENT_SHARED is defined
Detect the macro at configure time rather than during compilation.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 24 Jun 2016 12:03:36 +0000 (14:03 +0200)]
btrfs-progs: build: add m4 macros for AC_CHECK_DEFINE
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 24 Jun 2016 11:54:45 +0000 (13:54 +0200)]
btrfs-progs: build: let autotools include m4
We'll need some non-standard macro definitions.
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Fri, 24 Jun 2016 08:24:47 +0000 (17:24 +0900)]
btrfs-progs: fi show: print error message if no valid Btrfs is specified
* Before this patch
===============================
# ./btrfs fi show foo # "foo" doesn't mean any valid Btrfs
# # no error message
# echo $?
1
===============================
* After this patch
===============================
# ./btrfs fi show foo
ERROR: foo is not a valid Btrfs
#
# echo $?
1
===============================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 13:52:17 +0000 (15:52 +0200)]
btrfs-progs: tests: fix filesytem type creation for convert tests
The extN filesystem type was lost when the separate tests were created
and we've been testing only ext2. The tests pass for ext3 and ext4
though.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 13:50:17 +0000 (15:50 +0200)]
btrfs-progs: tests: add 005-delete-all-rollback
Test if a rollback works after deleing all files from btrfs.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 12:28:23 +0000 (14:28 +0200)]
btrfs-progs: tests: update README
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 12:07:46 +0000 (14:07 +0200)]
btrfs-progs: tests: add test console
Add a wrapper that sets up environment the same way a test would use it.
Use it for quick prototyping or testing, the commands and output is
logged.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 09:30:24 +0000 (11:30 +0200)]
btrfs-progs: tests: print shorter test name in the output
The full path is printed, we're interested in the last path component
only.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 22 Jun 2016 09:25:33 +0000 (11:25 +0200)]
btrfs-progs: tests: split convert_test
Split the big function to several helpers so we can use them separately.
Add comments and do minor tweaks.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 21 Jun 2016 00:48:39 +0000 (02:48 +0200)]
btrfs-progs: docs: update 'btrfs-device' manual page
Signed-off-by: David Sterba <dsterba@suse.com>
Mark Fasheh [Wed, 15 Jun 2016 22:50:01 +0000 (15:50 -0700)]
btrfs-progs: free qgroup counts in btrfsck
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
Chandan Rajendra [Fri, 17 Jun 2016 05:37:54 +0000 (11:07 +0530)]
Btrfs-progs: Initialize stripesize to the value of sectorsize
stripesize should ideally be set to the value of sectorsize. However
previous versions of btrfs-progs/mkfs.btrfs had set stripesize to a
value of 4096. On machines with PAGE_SIZE other than 4096, This could
lead to the following scenario,
- /dev/loop0, /dev/loop1 and /dev/loop2 are mounted as a single
filesystem. The filesystem was created by an older version of mkfs.btrfs
which set stripesize to 4k.
- losetup -a
/dev/loop0: [0030]:19477 (/root/disk-imgs/file-0.img)
/dev/loop1: [0030]:16577 (/root/disk-imgs/file-1.img)
/dev/loop2: [64770]:3423229 (/root/disk-imgs/file-2.img)
- /etc/mtab lists only /dev/loop0
- losetup /dev/loop4 /root/disk-imgs/file-1.img
The new mkfs.btrfs invoked as 'mkfs.btrfs -f /dev/loop4' succeeds even
though /dev/loop1 has already been mounted and has
/root/disk-imgs/file-1.img as its backing file.
The above behaviour occurs because check_super() function returns an
error code (due to stripesize not being set to 4096) and hence
check_mounted_where() function treats /dev/loop1 as a disk containing a
filesystem other than Btrfs.
Hence as a workaround this commit allows 4096 as a valid stripesize.
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 16 Jun 2016 01:15:51 +0000 (09:15 +0800)]
btrfs-progs: qgroup: Fix a bug that fails to skip rescan running case
Commit
6bdf962fe35a8648d(btrfs-progs: Read qgroup status for qgroup
verify) will read qgroup status, and then use it to skip qgroup
reporting.
However since the rescan_running/inconsistent flags are only 1 bit long,
while qgroup flags & BTRFS_QGROUP_FLAGS returns value longer than 1bit,
it doesn't work.
Fix it by doing double negation on (flags & BTRFS_QGROUP_FLAGS) to
convert it to either 1 or 0.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 16 Jun 2016 16:48:44 +0000 (18:48 +0200)]
btrfs-progs: docs: update btrfs-restore manual page
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 16 Jun 2016 11:50:18 +0000 (13:50 +0200)]
btrfs-progs: tests: add 003-fi-resize-args
Check various resize option combinations.
Signed-off-by: David Sterba <dsterba@suse.com>