Misono, Tomohiro [Mon, 23 Oct 2017 04:45:48 +0000 (13:45 +0900)]
btrfs-progs: fi: enable fi usage for filesystem on top of seed device
Currently "fi usage" (and "dev usage") cannot run for the filesystem
using the seed device.
This is because FS_INFO ioctl returns the number of devices excluding
seeds, but load_device_info() tries to access valid device from devid 0
to max_id, and results in accessing seeds too (thus causing mismatching
number of devices).
Since only the size of non-seed devices matters, fix this by just
skipping seed device by checking device's fsid and comparing it to the
fsid obtained by FS_INFO ioctl.
Anand Jain:
%fi_args.num_devices provides number of devices excluding the seed device.
So when looping through the device list for a given fsid, determine if the
given device is a seed device by reading its superblock and then skip it
if its a seed device. Reading of the superblock is done by the function
dev_to_fsid() which can fail if the user is not root OR if the device has
media errors as well. So skip the seed check altogether if we fail to know
the device superblock and thus the fsid.
With this now we are able to view the btrfs fi usage when the device is
bad.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Mon, 23 Oct 2017 04:44:01 +0000 (13:44 +0900)]
btrfs-progs: fi: move dev_to_fsid to cmds-fi-usage for later use
Move dev_to_fsid() from cmds-filesystem.c to cmds-fi-usage.c in order to
call it from both "fi show" and "fi usage".
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Tue, 17 Oct 2017 09:13:12 +0000 (17:13 +0800)]
btrfs-progs: rescue: Fix zero-log mounted branch
Seems to be a typo that, in (ret > 0) branch of check_mounted(),
zero-log set the return value but doesn't return.
Fix it by adding back the missing return.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Lu Fengqi [Thu, 26 Oct 2017 08:32:51 +0000 (16:32 +0800)]
btrfs-progs: qgroup: fix qgroup show sort by multi items
We should not free the string until we don't call strtok any longer.
If the string is freed in advance, in fact, the second and subsequent
sort items will be ignored.
Fixes:
9fcdf8f8945b ("btrfs-progs: don't write to optarg in btrfs_qgroup_parse_sort_string")
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Mon, 16 Oct 2017 08:22:56 +0000 (16:22 +0800)]
btrfs-progs: mkfs: refactor test_minimum_size to use the calculated minimal size
test_minimum_size() function is only called to check if provided device
is large enough.
However the minimal device size only needs to be calculated once, and
can be reused everywhere.
Refactor that function to make later modification easier.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 26 Oct 2017 07:28:37 +0000 (15:28 +0800)]
btrfs-progs: convert: Open the fs readonly for rollback
For rollback, we only needs to open the fs to check if it meets the
condition to rollback. And this RW read makes us failed to rollback
btrfs with v2 space cache.
In fact, we don't even start a transaction during rollback.
So open the fs RO for rollback, to avoid v2 space cache problem.
Reported-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Reviewed-by: Gu JinXiang <gujx@cn.fujitsu.com>
Tested-by: Gu JinXiang <gujx@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 Oct 2017 05:41:36 +0000 (13:41 +0800)]
btrfs-progs: mkfs: error out gracefully for --rootdir
--rootdir option will start a transaction to fill the fs, however if
something goes wrong, from ENOSPC to lack of permission, we won't commit
the transaction and cause BUG_ON triggered by uncommitted transaction:
------
extent buffer leak: start
29392896 len 16384
extent_io.c:579: free_extent_buffer: BUG_ON `eb->flags & EXTENT_DIRTY` triggered, value 1
------
The root fix is to introduce btrfs_abort_transaction() in btrfs-progs,
however in this particular case, we can workaround it by force
committing the transaction.
Since during mkfs, the magic of btrfs is set to an invalid one, without
setting fs_info->finalize_on_close() the fs is never able to be mounted.
So even we force to commit wrong transaction we won't screw up things
worse.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 Oct 2017 05:41:35 +0000 (13:41 +0800)]
btrfs-progs: mkfs: fix overwritten return value for mkfs
For mkfs failure, especially --rootdir errors like EPERM/ENOSPC, the out
branch will overwrite the return value, causing wrong status code.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 Oct 2017 05:41:34 +0000 (13:41 +0800)]
btrfs-progs: mkfs: avoid positive return value from cleanup_temp_chunks
Since we're calling btrfs_search_slot() the return value can be
positive. However we just pass that return value out, causing undefined
return value.
This can cause mkfs to return 1, which indicates something wrong.
Fix it.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 Oct 2017 05:41:33 +0000 (13:41 +0800)]
btrfs-progs: mkfs: avoid BUG_ON for chunk allocation when ENOSPC happens
When passing directory larger than block device using --rootdir
parameter, we get the following backtrace:
------
extent-tree.c:2693: btrfs_reserve_extent: BUG_ON `ret` triggered, value -28
./mkfs.btrfs(+0x1a05d)[0x557939e6b05d]
./mkfs.btrfs(btrfs_reserve_extent+0xb5a)[0x557939e710c8]
./mkfs.btrfs(+0xb0b6)[0x557939e5c0b6]
./mkfs.btrfs(main+0x15d5)[0x557939e5de04]
/usr/lib/libc.so.6(__libc_start_main+0xea)[0x7f83b101af6a]
./mkfs.btrfs(_start+0x2a)[0x557939e5af5a]
------
Nothing special, just BUG_ON() abusing from ancient code.
Fix them by using correct return.
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Pavel Kretov [Tue, 24 Oct 2017 22:47:45 +0000 (01:47 +0300)]
btrfs-progs: defrag: add a brief warning about ref-link breakage
There is a warning in btrfs-filesystem(8) saying that running 'defrag'
in Linux will almost certainly break ref-links, with much data potentially
being physically duplicated.
However, many users tend to read man pages *after* trying to run things
on their own risk and may miss this important information. This commit
adds a brief copy of this warning into the command built-in help message
where it has good chances to be spotted before user is stuck with
a crowded filesystem.
Pull-request: #73
Signed-off-by: Pavel Kretov <firegurafiku@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:23:13 +0000 (01:23 +0200)]
btrfs-progs: image: move sanitization to new file
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:11:11 +0000 (01:11 +0200)]
btrfs-progs: image: pass sanitize mode and name tree separately to sanitize_name
Now sanitize_name and all callees do not depend on metadump_struct.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:11:11 +0000 (01:11 +0200)]
btrfs-progs: image: pass sanitize mode and name tree separately to sanitize_dir_item
We don't need the full mdrestore structure.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:11:11 +0000 (01:11 +0200)]
btrfs-progs: image: pass sanitize mode and name tree separately to sanitize_inode_ref
We don't need the full mdrestore structure.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:06:53 +0000 (01:06 +0200)]
btrfs-progs: image: drop unused parameter from sanitize_xattr
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:04:55 +0000 (01:04 +0200)]
btrfs-progs: image: pass rb_root to find_collisions
We don't need the full metadump structure, pass only the name tree.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 23:01:43 +0000 (01:01 +0200)]
btrfs-progs: image: introduce symbolic names for the sanitization modes
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 22:48:30 +0000 (00:48 +0200)]
btrfs-progs: image: start a new header for sanitization functions
Will be used by following cleanups, so far only the name structure could
be moved here.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 22:31:44 +0000 (00:31 +0200)]
btrfs-progs: build: use variables for btrfs-image images
More separate sources will be created for btrfs-image.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 Oct 2017 22:24:13 +0000 (00:24 +0200)]
btrfs-progs: image: move metadump definitions to own header
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 18 Oct 2017 02:00:43 +0000 (11:00 +0900)]
btrfs-progs: test: add new cli-test for subvol get/set-default
Add new test to check functionality of subvol get/set-default.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
[ fix style issues, add missing SUDO_HELPER ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 17 Oct 2017 18:27:12 +0000 (20:27 +0200)]
btrfs-progs: docs: update btrfs-properties
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Sat, 14 Oct 2017 12:54:54 +0000 (21:54 +0900)]
btrfs-progs: prop: also allow "none" to disable compression
Some people were asking why disabling compression via properties is not
set by "none" instead. As this is purely userspace conversion to "" that
kernel accepts, let's add "none" as well for convenience.
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Sat, 14 Oct 2017 12:54:54 +0000 (21:54 +0900)]
btrfs-progs: allow "no" to disable compression for convenience
It's messy to use "" to disable compression. Introduce the new value "no"
which can also be used for this purpose.
Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
[ coding style fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Fri, 6 Oct 2017 01:05:08 +0000 (10:05 +0900)]
btrfs-progs: subvol: change set-default to also accept path
This patch changes "subvol set-default" to also accept the subvolume path
for convenience.
If there are two args, they are assumed as subvol id and path to the fs
(the same as current behavior), and if there is only one arg, it is assumed
as the path to the subvolume.
subvol id is resolved by test_issubvolume() + lookup_path_rootid().
The empty subvol (ino == 2) will get error on test_issubvolume() which
checks whether inode num is 256 or not.
Issue: #35
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
[ update documentation, use the new multi-line command scheme ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 17 Oct 2017 17:39:47 +0000 (19:39 +0200)]
btrfs-progs: help: print multiple syntax schemas on separate lines
The help string for some commands could be split to more lines for
clarity, eg. as is now in the receive command. The 'btrfs help' listing
should indent all the lines properly, similar the command specific
help with "usage:'.
The syntax of the first help string line is to separate all command
usage schemas by "\n".
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Wed, 11 Oct 2017 17:57:16 +0000 (11:57 -0600)]
btrfs-progs: do not add stale device into fs_devices
If one of btrfs' devices was pulled out and we've replaced it with a
new one, then they have the same uuid.
If that device gets reconnected, 'btrfs filesystem show' will show the
stale one instead of the new one, but on the kernel side btrfs has a fix
not to include the stale one, this could confuse users as people may
monitor btrfs by running that command.
This does the similar thing to what kernel side has done.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
[ format string adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 27 Sep 2017 06:34:40 +0000 (14:34 +0800)]
btrfs-progs: fsck-tests: 027/bad_extent_inline_ref_type
This case is for avoiding crash in lowmem check mode.
Field type of extent_inline_ref in an extent is corrupted.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 27 Sep 2017 06:34:39 +0000 (14:34 +0800)]
btrfs-progs: check: check extent_inline_ref in lowmem
Lowmem check does not skip invalid type in extent_inline_ref and then
calls btrfs_extent_inline_ref_size(type) which causes a crash.
Error:
$ btrfs check --mode=lowmem /tmp/data_small
Checking filesystem on /tmp/data_small
UUID:
ee205d69-8724-4aa2-a4f5-
bc8558a62169
checking extents
ERROR: extent[
20971520 16384] backref type mismatch, missing bit: 2
ERROR: extent[
20971520 16384] backref generation mismatch,
wanted: 7, have: 0
ERROR: extent[
20971520 16384] is referred by other roots than 3
ctree.h:1754: btrfs_extent_inline_ref_size: BUG_ON `1` triggered,
value 1
btrfs(+0x543db)[0x55fabc2ab3db]
btrfs(+0x587f7)[0x55fabc2af7f7]
btrfs(+0x5fa44)[0x55fabc2b6a44]
btrfs(cmd_check+0x194a)[0x55fabc2bd717]
btrfs(main+0x88)[0x55fabc2682e0]
/usr/lib/libc.so.6(__libc_start_main+0xea)[0x7f021c3824ca]
btrfs(_start+0x2a)[0x55fabc267e7a]
[1] 5188 abort (core dumped) btrfs check --mode=lowmem /tmp/data_small
Fix it by introducing check_extent_inline_ref() to check the type.
If the checker returns a non-zero value, we should not try to check the
corrupted extent item anymore.
Suggested-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 27 Sep 2017 06:34:38 +0000 (14:34 +0800)]
btrfs-progs: check: error or return value of repair_root_items()
Return value of repair_root_items():
<0 on error
=0 does nothing
>0 if repair is enabled, N roots are repaired;
else N roots are corrupted.
In the repair mode, there should be no error if the return value is
bigger than 0. This fixes the test fsck/006 again.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 27 Sep 2017 08:28:39 +0000 (16:28 +0800)]
btrfs-progs: check: call repair_root_items before any repairs
The annotation of repair_root_items says:
"This must be run before any other repair code - not doing it so,
makes other repair code delete or modify backrefs in the extent tree
for example, which will result in an inconsistent fs after repairing
the root items."
However, the rule was broken by commit
1f728b1a514f ("Btrfs-progs,
fsck: move root items repair after root rebuilding").
The commit intends to fix failure of test-fsck/013 so it moves
repair_root_items() after check_extents_and_chunks().
The correct way is to skip calling repair_root_item() when
init_extent_tree is non-zero.
Now put repair_root_items() before do_check_chunks_and_extents() and
do not call repair_root_items() if init_extent_tree is set.
Then test-fsck/013 works well.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 27 Sep 2017 06:34:36 +0000 (14:34 +0800)]
btrfs-progs: check: return value of check_extent_refs
In original check mode (without option --repair), check_extent_refs()
always returns 0.
Add a variable @err to record status while checking extents. At the end
of check_extent_refs(), let it return -EIO if @err is non-zero.
The test fsck/006-bad-root-items will fail after this patch and fixed by
the following patches.
Example:
$ btrfs check bad-extent-inline-ref-type.raw
Checking filesystem on bad-extent-inline-ref-type.raw
UUID:
1942d6fe-617b-4499-9982-
cc8ffae5447f
checking extents
corrupt extent record: key
29360128 169 16384
ref mismatch on [
29360128 16384] extent item 0, found 1
Backref
29360128 parent 5 root 5 not found in extent tree
backpointer mismatch on [
29360128 16384]
bad extent [
29360128,
29376512), type mismatch with chunk
checking free space cache
checking fs roots
checking csums
checking root refs
found 114688 bytes used, no error found
total csum bytes: 0
total tree bytes: 114688
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 109471
file data blocks allocated: 0
referenced 0
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ add note about the failing test, rename variable to err ]
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Tue, 12 Sep 2017 03:56:30 +0000 (11:56 +0800)]
btrfs-progs: check: repair block group accounting in lowmem mode
Add a macro named BG_ACCOUNT_ERROR meaning that block group used size
does not equal the total.
After extent-tree repair, BG_ACCOUNT_ERROR should be fixed up.
Clean bits at end of check_chunks_and_extents_v2().
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 06:30:02 +0000 (14:30 +0800)]
btrfs-progs: check: introduce repair_extent_data_item()
The only thing repair_extent_data_item() does is that it adds backref of the
tree_block. Just like what original mode does:
It first searches the corresponding extent item.
1. If the extent item exists but backref is missing, add one backref to the
extent.
2. Found nothing, just add an extent item and add one backref.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 06:26:12 +0000 (14:26 +0800)]
btrfs-progs: check: introduce repair_tree_block_ref()
The only thing repair_tree_block_ref() does is that it adds backref of the
tree_block. Just like what original repair do:
It first searches the corresponding extent item then
1. If the extent item exists but backref is missing, add one backref to the
extent.
2. if found nothing, just add an extent item and add one backref.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 06:22:37 +0000 (14:22 +0800)]
btrfs-progs: check: introduce repair_chunk_item()
Because this patchset concentrates on repair of extent tree,
repair_chunk_item() now only inserts missed chunk group item into
extent tree.
There are some things left TODO, for example dev_item fix.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 06:20:06 +0000 (14:20 +0800)]
btrfs-progs: check: delete wrong items in lowmem repair
Introduce delete_extent_tree_item() and repair_extent_item() to do
only deletion.
While checking the extent tree, just delete the wrong item. For extent
item, free wrong backref. Otherwise, delete. So the remaining items in
extent tree should be correct.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 06:12:37 +0000 (14:12 +0800)]
btrfs-progs: check: change the way lowmem mode traverses metadata
This patch is a preparation for extent-tree repair in lowmem mode.
In the lowmem mode, checking tree blocks of various trees is recursive.
But during repair, adding or deleting item(s) may modify upper nodes
which will cause the repair to be complicated and dangerous.
Before this patch:
One problem of lowmem check is that it only checks the lowest node's
backref in check_tree_block_ref.
This way ensures checked tree blocks are valid and avoids to traverse
all trees for performance reasons.
However, there is one shortcoming that it can not detect backref mistake
if one extent whose owner == offset but lacks the other backref(s).
In check, correctness is more important than speed.
If errors can not be detected, repair is impossible.
Changes in the patch:
check_chunks_and_extents now has to check *ALL* trees so lowmem check
will behave like original mode.
Changing the way of traversal to be same as fs tree which calls
walk_down_tree_v2() and walk_up_tree_v2() is easy for further
repair.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ heavy coding style fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Wed, 1 Mar 2017 01:21:51 +0000 (09:21 +0800)]
btrfs-progs: tests: Allow check test to repair in lowmem mode for certain errors
Since lowmem mode can repair certain corruptions (mostly in fs tree),
insert a beacon into each fsck test cases to allow some of them be
tested in lowmem mode.
With this patch, fsck option override will check the beacon file
".lowmem_repairable" in the same directory of the test image, and if the
beacon exists, then it will also run lowmem mode repair to repair the
image.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Fri, 1 Sep 2017 02:56:16 +0000 (10:56 +0800)]
btrfs-progs: check: special case for last item
Since repair functions will search path again, if the last item
was checked, the location where the path points is invalid.
Fix it by saving the last valid key if err contains LAST_ITEM,
and call btrfs_next_item() before return of check_inode_item().
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Tue, 29 Aug 2017 03:33:23 +0000 (11:33 +0800)]
btrfs-progs: check: punch_extent_hole in lowmem
While checking file extents, there are two errors that may occur:
1) There is one hole between the last extent end and beginning of the
current extent but no-holes is disabled.
2) No-holes is disabled, one file's nbytes equals 0 but isize is not 0.
Those both mean the file may have lost some extents.
To avoid btrfsck's error message, fix it by introducing function
'punch_extent_hole' to punch holes.
For case 1, punch a hole extent whose length is
(current extent begin - last extent end)
while checking one extent.
For case 2, punch a hole extent whose length is
(file isize - actual file size)
after traversing one entire file.
Then repair_inode_nbytes will set the nbytes to isize.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Tue, 29 Aug 2017 03:23:46 +0000 (11:23 +0800)]
btrfs-progs: check: repair inode nlink in lowmem
New function repair_inode_nlinks_lowmem() sets nlink of the inode to refs.
If refs equals 0, move the inode to lost+found and set refs to 1
initially.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Tue, 29 Aug 2017 06:11:26 +0000 (14:11 +0800)]
btrfs-progs: check: count dir inode isize again
repair_ternary_lowmem() may delete dir_item(s), later traversal can cause
wrong isize of the dirctory inode.
Introduce count_dir_iszie() to count directory isize if any
dir_item(s) in the directory has been repaired.
check_dir_item() now returns DIR_COUNT_AGAIN means the inode should be
counted isize again.
It is unnessary to do recount after check_inode_ref(), since
inode_ref is irrelevant to isize.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Tue, 29 Aug 2017 02:47:20 +0000 (10:47 +0800)]
btrfs-progs: check: repair dir_item and inode_ref in lowmem mode
Introduce repair_ternary_lowmem() to repair dir_item, dir_index
and inode_ref.
If two of the three are missing or mismatched, call btrfs_unlink() to
delete the existing one.
If one of three is missing or mismatched, call btrfs_add_link() to
add the missing one.
repair_dir_item() inserts an inode item corresponding to location in the
dir item if error contains INODE_ITEM_MISSING.
Also, it calls repair_ternary_lowmem() to repair relationship of
dir_item, dir_index and inode_ref.
check_inode_ref() calls repair_ternary_item() to fix up errors.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 08:08:55 +0000 (16:08 +0800)]
btrfs-progs: check: introduce repair_fs_first_inode()
Introduce 'repair_fs_first_inode' to repair first inode errors
(ref missing and inode item missing).
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 07:48:16 +0000 (15:48 +0800)]
btrfs-progs: check: introduce repair_inode_item_missing()
Introduce __create_inode_item() to create a new inode item.
It is called by create_inode_item() and create_inode_item_lowmem().
Function repair_inode_item_missing() just adds a new inode item.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 07:08:09 +0000 (15:08 +0800)]
btrfs-progs: check: adjustments for further repair
For code reuse, btrfs_insert_dir_item() now calls
inserts_with_overflow() even if the dir_item existed.
Add a parameter @ignore_existed to btrfs_add_link().
If @ignore_existed is not zero, btrfs_add_link() continues to do link.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 06:44:56 +0000 (14:44 +0800)]
btrfs-progs: check: introduce print_dir_item_err()
check_dir_item() now checks relative dir_item/dir_index.
Introduce print_dir_item_err() to print error msg while
checking dir_item/dir_index.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 06:31:47 +0000 (14:31 +0800)]
btrfs-progs: check: introduce print_inode_ref()
Introduce print_inode_ref() to print error msg while checking inode ref.
Add args @name_ret and @namelen_ret to check_inode_ref().
Name is essential if the inode item is to be put into lost+found
while doing nlinks repair.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 06:18:27 +0000 (14:18 +0800)]
btrfs-progs: check: change find_dir_index/item
The changes in the patch is for further repair:
1.Introduce find_dir_index() to get the index by traversing items.
2.We should distinguish dir_index error and dir_item error.
However, there are only DIR_ITEM_MISSING and DIR_ITEM_MISMATCH.
Introduce marcos DIR_INDEX_MISSING and DIR_INDEX_MISMATCH
to represent index missing/mismatch.
3.Because find_dir_item() prints message right now if it detects any
error.
Remove message output now and next patches will introduce functions
to print error message.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 05:54:21 +0000 (13:54 +0800)]
btrfs-progs: check: modify check_fs_first_inode()
Modify check_fs_first_inode to check the inode ref in first inode.
Which root dir inode differs from other inode is inode_ref points
"..".
So we just handle this special case and treat it as normal
inode in continued check.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 05:42:49 +0000 (13:42 +0800)]
btrfs-progs: check: change find_inode_ref()'s arg
For further lowmem repair, change @index type u64 to u64* of
function find_inode_ref().
So caller can get the index of ref.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 05:26:33 +0000 (13:26 +0800)]
btrfs-progs: check: repair inode orphan item in lowmem mode
Introduce repair_inode_orphan_item_lowmem() to add an orphan
item if the inode refs and nlink are both zero.
repair_inode_orphan_item_lowmem() is just a wrapper function
that calls btrfs_add_orphan_item().
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 03:20:34 +0000 (11:20 +0800)]
btrfs-progs: check: repair dir inode isize in lowmem mode
After traversal of whole directory, we should get the actual isize.
Like original mode, function repair_dir_isize_lowmem() sets isize of the
directory inode item to actual size.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Mon, 28 Aug 2017 02:41:27 +0000 (10:41 +0800)]
btrfs-progs: check: repair inode nbytes in lowmem mode
After checking one entire inode item, we should get the actual
nbytes of the inode item.
Like original mode, repair_inode_nbytes_lowmem() sets nbytes in
struct btrfs_inode_item to the actual nbytes.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Wed, 23 Aug 2017 01:38:56 +0000 (09:38 +0800)]
btrfs-progs: check: enable repair in lowmem mode
Turn on the option --repair with --mode==lowmem in btrfs check.
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ use warning() and adjust wording ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 16 Oct 2017 16:47:48 +0000 (18:47 +0200)]
Btrfs progs v4.13.3
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 28 Jul 2017 13:29:46 +0000 (15:29 +0200)]
btrfs-progs: update CHANGES for v4.13.3
Signed-off-by: David Sterba <dsterba@suse.com>
Lu Fengqi [Fri, 13 Oct 2017 09:17:22 +0000 (17:17 +0800)]
btrfs-progs: subvol list: don't print deleted subvol as TOPLEVEL
We should use entry->root_id instead of top_id to determine whether it is
the toplevel subvolume. Introduced in 4.13.2.
Issue: #72
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Naohiro Aota [Thu, 12 Oct 2017 02:22:24 +0000 (11:22 +0900)]
btrfs-progs: build: set include path relatively
Currently, gcc is passed the include directory with full path. As a result,
dependency files (*.o.d) also record the full path at the build time. Such
full path dependency is annoying for sharing the source between multiple
machines, containers, or anything the path differ.
And this is the same way what other program using autotools e.g. e2fsprogs
is doing:
$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2 -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>
Signed-off-by: Naohiro Aota <naota@elisp.net>
[ set TOPDIR=. instead of -I as discussed, does not harm linker ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 13 Oct 2017 18:04:37 +0000 (20:04 +0200)]
btrfs-progs: build: add absolute path for topdir
We'll need TOPDIR to be ./ but library-test is intentionally built
outside of the git repository so we need to make them separate.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 12 Oct 2017 12:29:27 +0000 (14:29 +0200)]
btrfs-progs: tests: add more configure option coverage
* test convert spec string
* explicitly ask for zstd, as it is now autodetected
Signed-off-by: David Sterba <dsterba@suse.com>
Sergei Trofimovich [Thu, 12 Oct 2017 12:08:54 +0000 (13:08 +0100)]
btrfs-progs: build: allow '--with-convert=' to accept comma-separated values
Before the change configure refused to accept it's defaults explicitly:
$ ./configure --enable-convert --with-convert=ext2,reiserfs
...
configure: error: unknown tokens for --with-convert: ,
After the change both converters are enabled:
$ ./configure --enable-convert --with-convert=ext2,reiserfs
...
btrfs-convert: yes (ext2,reiserfs)
Cc: linux-btrfs@vger.kernel.org
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 10 Oct 2017 15:08:03 +0000 (17:08 +0200)]
btrfs-progs: build: move travis helper script to own directory
We're going to add move build check integration scripts and
configuration, so put everything under travis/ now.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 10 Oct 2017 12:57:26 +0000 (14:57 +0200)]
btrfs-progs: tests: fsck/007 fix so check --force works
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 10 Oct 2017 12:53:32 +0000 (14:53 +0200)]
btrfs-progs: check: drop exclusive open mode for --force
The check opens the given device in exclusive by default. In the forced
mode we want to access a device in use, so we have to drop the
exclusivity bit.
This works for block devices but not for files, that could be mounted
via a loop device. In that respect test check/007 is broken and will be
fixed.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 Oct 2017 12:37:57 +0000 (14:37 +0200)]
Btrfs progs v4.13.2
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 28 Jul 2017 13:29:46 +0000 (15:29 +0200)]
btrfs-progs: update CHANGES for v4.13.2
Signed-off-by: David Sterba <dsterba@suse.com>
Su Yue [Thu, 28 Sep 2017 07:29:19 +0000 (15:29 +0800)]
btrfs-progs: tests: arg override in command line
Lowmem mode only repairs few cases which has a beacon file
".lowmem_repairable" in the case' directory.
However, defining TEST_ENABLE_OVERRIDE=true in command line does work
in above strategy.
Because _skip_spec() in tests/common.local isn't interpreted by shell
in that case.
Solve it by making _skip_spec() always be defined in common.local.
Reported-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
[ keep the _skip_spec check ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 5 Oct 2017 14:25:21 +0000 (16:25 +0200)]
btrfs-progs: tests: don't list toplevel subvolme in 'subvol list'
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 5 Oct 2017 13:25:53 +0000 (15:25 +0200)]
btrfs-progs: subvol list: don't list FS_TREE as deleted
Adding support for 'btrfs subvol show' for the toplevel subvolume
accidentally started to list the toplevel subvolume among the deleted.
Since version 4.8.3.
Don't panic. The toplevel subvolume (id 5) cannot be deleted.
Fixes:
d4aa2bc07e ("btrfs-progs: subvol show: print more details about toplevel subvolume")
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Tue, 3 Oct 2017 06:47:26 +0000 (15:47 +0900)]
btrfs-progs: misc-test: use raid1 for data to enable mount with -o degraded
kernel 4.14 introduces new function for checking if all chunks is ok for
mount with -o degraded option.
commit
21634a19f646 ("btrfs: Introduce a function to check if all
chunks a OK for degraded rw mount")
As a result, raid0 profile cannot be mounted with -o degraded on 4.14.
This causes failure of the misc-test 011 "delete missing device".
Fix this by using raid1 profile for both data and metadata.
This also should work for kernel before 4.13.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Holger Hoffstätte [Sat, 30 Sep 2017 15:54:27 +0000 (17:54 +0200)]
btrfs-progs: right-align number columns in btrfs-debugfs output
The values for block group offset, length etc. in btrfs-debugfs' output
are left-aligned, which creates unaligned output and makes the usage
percentage hard to read/process further. This patch adds right-aligning
format specifiers for the number values.
Ideally the format values wouldn't be hardcoded but instead derived from
the filesystem size, but this seems to work for now.
Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 Oct 2017 14:00:44 +0000 (16:00 +0200)]
btrfs-progs: set fixed with for printing uuids of subvolumes
The tabular output format looks better if the empty uuids are aligned
with the other. In the list output (now default) it's not that nice but
the whole list format is not nice anyway.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 Oct 2017 13:00:43 +0000 (15:00 +0200)]
btrfs-progs: subvol: group options in help
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 29 Sep 2017 20:29:38 +0000 (22:29 +0200)]
btrfs-progs: docs: update btrfs-balance
Copy unexpected edits from wiki so they do not get lost at next
git->wiki sync.
Author: Bill S.
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:38 +0000 (16:51 -0400)]
btrfs-progs: backref: use separate list for indirect refs
Rather than iterate over all outstanding backrefs to resolve indirect refs,
use a separate list that only contains indirect refs.
When we process missing keys, the ref moves to the indirect ref list.
Once the indirect ref is resolved, move the ref to the pending list.
Eventually these lists will be replaced by rbtrees.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ added assertion fix from Josef ]
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:37 +0000 (16:51 -0400)]
btrfs-progs: backref: use separate list for missing keys
Rather than iterate over all outstanding backrefs to resolve missing keys,
use a separate list that only contains refs that need missing keys resolved.
Once the missing key is resolved, move the ref to the pending list.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:36 +0000 (16:51 -0400)]
btrfs-progs: backref: add list_first_pref helper
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:35 +0000 (16:51 -0400)]
btrfs-progs: backref: push state tracking into a helper structure
Eventually, we'll have several lists and trees, as well as some statistics.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:34 +0000 (16:51 -0400)]
btrfs-progs: extent-cache: actually cache extent buffers
We have the infrastructure to cache extent buffers but we don't actually
do the caching. As soon as the last reference is dropped, the buffer
is dropped. This patch keeps the extent buffers around until the max
cache size is reached (defaults to 25% of memory) and then it drops
the last 10% of the LRU to free up cache space for reallocation. The
cache size is configurable (for use by e.g. lowmem) when the cache is
initialized.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ update codingstyle, switch total_memory to bytes ]
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Tue, 25 Jul 2017 20:51:33 +0000 (16:51 -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 [Tue, 25 Jul 2017 20:51:32 +0000 (16:51 -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.
A previous version of this patch introduced a regression that would
have corrupted file systems during repair. It was traced to the
compare algorithm honoring ->bytes regardless of whether the
reference had been found and a failure to reinsert nodes after
the target reference was found.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 29 Sep 2017 13:24:54 +0000 (15:24 +0200)]
btrfs-progs: mkfs: remove unused function
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 29 Sep 2017 13:23:35 +0000 (15:23 +0200)]
btrfs-progs: mkfs: use existing helper for path concatenation
Mkfs uses make_path that is duplicate of path_cat* functions, so we can
switch to them and add the error handling.
Signed-off-by: David Sterba <dsterba@suse.com>
Yingyi Luo [Fri, 15 Sep 2017 18:17:31 +0000 (11:17 -0700)]
btrfs-progs: add a parameter to btrfs_mksubvol
A convert parameter is added as a flag to indicate if btrfs_mksubvol()
is used for btrfs-convert. The change cascades down to the callchain.
Signed-off-by: Yingyi Luo <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Yingyi Luo [Fri, 15 Sep 2017 17:49:21 +0000 (10:49 -0700)]
btrfs-progs: convert: move link_subvol out of main
link_subvol() is moved to inode.c and renamed as btrfs_mksubvol().
The change cascades down to the callchain.
Signed-off-by: Yingyi Luo <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 27 Sep 2017 02:03:48 +0000 (11:03 +0900)]
btrfs-progs: subvol: fix subvol del --commit-after
Fix 'subvolume delete --commit-after' to work properly:
- SYNC ioctl will be issued even when last delete fails
- SYNC ioctl will be issued on each file system only once in the end
To achieve this, get_fsid() and add_seen_fsid() are called after each
delete to keep only one fd for each fs.
In the end, seen_fsid_hash will be traversed and SYNC is issued on each
fs.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 27 Sep 2017 02:02:47 +0000 (11:02 +0900)]
btrfs-progs: change seen_fsid to hold fd and DIR
Change seen_fsid to hold fd and DIR in order to keep access to each fs.
This will be used for 'subvol delete --commit-after'.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 27 Sep 2017 02:02:19 +0000 (11:02 +0900)]
btrfs-progs: move seen_fsid to utils.c
Move is_seen_fsid()/add_seen_fsid()/free_seen_fsid() to common functions.
This will be used for 'subvol delete --commit-after'.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 27 Sep 2017 02:01:43 +0000 (11:01 +0900)]
btrfs-progs: move get_fsid() to utils.c
Make get_fsid() to a common functions.
This will be used for 'subvol delete --commit-after'.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Misono, Tomohiro [Wed, 27 Sep 2017 02:01:09 +0000 (11:01 +0900)]
btrfs-progs: subvol: exchange subvol del --commit-after and --commit-each
Current code is reversed in --commit-after and --commit-each operation,
i.e. --commit-after means --commit-each actually. This patch fixes this
and also introduces enum type for more readable code.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 25 Sep 2017 16:25:18 +0000 (18:25 +0200)]
Btrfs progs v4.13.1
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 28 Jul 2017 13:29:46 +0000 (15:29 +0200)]
btrfs-progs: update CHANGES for v4.13.1
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 25 Sep 2017 13:09:21 +0000 (15:09 +0200)]
btrfs-progs: tests: check there are no unprintable characters in btrfs-image -ss output
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Sat, 23 Sep 2017 20:15:42 +0000 (22:15 +0200)]
btrfs-progs: build: add more sparse warning checks
- declarations after statements (style issue)
- bitfields without defined signedness
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Sat, 23 Sep 2017 19:53:26 +0000 (21:53 +0200)]
btrfs-progs: build: use -std=gnu89 for sparse
Sparse does not seem to support gnu90 that we'd like to keep for the
regular build. Use gnu89 for C=1 build.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Sat, 23 Sep 2017 19:49:11 +0000 (21:49 +0200)]
btrfs-progs: build: add missing defines for the C=1 build
Sparse complains that BTRFSCONVERT_EXT2 and _RESIERFS are not defined.
The per-target options are missing from the default CFLAGS and only
added in the specific rule.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Sat, 23 Sep 2017 19:08:43 +0000 (21:08 +0200)]
btrfs-progs: updated and add missing function attributes to the definition
Reported by sparse. Make the prototype match the definition and put the
attributes before the function.
Signed-off-by: David Sterba <dsterba@suse.com>