Commit Graph

4746 Commits (c0037091917af0e32e49e90ec4a53748205e2c80)
 

Author SHA1 Message Date
Qu Wenruo c003709191 btrfs-progs: print-tree: Use BFS as default traversal method
When debugging tree nodes with higher level, default DFS is not that
reader friendly:

  file tree key (262 ROOT_ITEM 16)
  node 33800192 level 2 items 4 free 117 generation 16 owner 262
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	key (256 INODE_ITEM 0) block 33771520 gen 15
  	key (330 EXTENT_DATA 0) block 33325056 gen 11
  	key (438 EXTENT_DATA 0) block 33652736 gen 15
  	key (654 EXTENT_DATA 0) block 33644544 gen 15
  node 33771520 level 1 items 59 free 62 generation 15 owner 256
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	key (256 INODE_ITEM 0) block 33787904 gen 15
  	key (256 DIR_ITEM 273597024) block 33124352 gen 9
  	[...]
  leaf 33787904 items 30 free space 1868 generation 15 owner 256
  fs uuid 2d66d111-6850-4ca1-ae73-03f50adde41c
  chunk uuid 11141e63-2534-4d04-a0bd-c0531a8f5b88
  	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
  		generation 6 transid 15 size 12954 nbytes 0
  		block group 0 mode 40755 links 1 uid 0 gid 0 rdev 0
  		sequence 528 flags 0x0(none)
  		atime 1565071339.446118888 (2019-08-06 14:02:19)
  		ctime 1565071339.449452222 (2019-08-06 14:02:19)
  		mtime 1565071339.449452222 (2019-08-06 14:02:19)
  		otime 1565071338.89452221 (2019-08-06 14:02:18)
  	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
  		index 0 namelen 2 name: ..
  	item 2 key (256 DIR_ITEM 2487323) itemoff 3781 itemsize 42
  		location key (487 INODE_ITEM 0) type FILE
  		transid 7 data_len 0 name_len 12
  		name: file_reg_115
  	[...]
  leaf 33124352 items 31 free space 1873 generation 9 owner 256
  	[...]

However such DFS will show the leaves before nodes. If tracing things
like drop_progress, we want to see nodes first then leaves.

So change default behavior to BFS to life of developers easier.

This affects 'btrfs inspect-internal dump-tree' output, the traversal
order can be selected by --dfs or --bfs options.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:27:28 +02:00
Anand Jain b250f30492 libbtrfsutil: remove stale BTRFS_DEV_REPLACE_ITEM_STATE_x defines
The BTRFS_DEV_REPLACE_ITEM_STATE_x series defines as shown in [1] are
unused in both kernel and btrfs-progs.

[1]
btrfs.h:#define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED        2
btrfs.h:#define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED        3
btrfs.h:#define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED       4

Further the BTRFS_DEV_REPLACE_ITEM_STATE_x values are different form its
counterpart BTRFS_IOCTL_DEV_REPLACE_STATE_x series as shown in [2].

[2]
btrfs_tree.h:#define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED   2
btrfs_tree.h:#define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED    3
btrfs_tree.h:#define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED    4

So this patch deletes the BTRFS_DEV_REPLACE_ITEM_STATE_x altogether,
they're not used by anything.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:27:26 +02:00
Johannes Thumshirn 7aace2519a btrfs-progs: pass in a btrfs_mkfs_config to write_temp_extent_buffer
Pass in a btrfs_mkfs_config to write_temp_extent_buffer(), this is
needed so we can grab the checksum type for checksum buffer verification
in later patches.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:27:23 +02:00
Johannes Thumshirn 5eb0c11333 btrfs-progs: use btrfs_csum_data() in __csum_tree_block_size()
Use the btrfs_csum_data() wrapper in __csum_tree_block_size() instead of
directly calling crc32c().

This helps us when plumbing new checksum algorithms into the FS.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:27:20 +02:00
David Sterba 55a8c9626f
Btrfs progs v5.2.2
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-05 15:34:37 +02:00
David Sterba c21dcd04de btrfs-progs: update CHANGES for v5.2.2
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:16:36 +02:00
Qu Wenruo 7cb441ba56 btrfs-progs: fsck-tests: Add test image for valid half-dropped orphan inode
Btrfs check used to report false alerts on half dropped orphan inodes.
Add test cases to prevent such problem from happening again.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:58 +02:00
Qu Wenruo c31bd8db54 btrfs-progs: check/lowmem: Skip nbytes check for orphan inodes
For orphan inodes, kernel won't update its nbytes and size since it's a
waste of time.

So lowmem check can report false alert on some orphan inodes.

Fix it by checking if the inode is an orphan before
complaining/repairing its nbytes.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:56 +02:00
Anand Jain 9b1a1dacbc btrfs-progs: print-tree add missing DEV_STATS
Add missing BTRFS_DEV_STATS_OBJECTID into the print-tree.

before:
 	item 0 key (0 PERSISTENT_ITEM 1) itemoff 16243 itemsize 40
 		persistent item objectid 0 offset 1
after:
 	item 0 key (DEV_STATS PERSISTENT_ITEM 1) itemoff 16243 itemsize 40
 		persistent item objectid DEV_STATS offset 1

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:53 +02:00
David Sterba d523a28a15 btrfs-progs: tests: cli/003: add resize checks with 'max'
The 'max' keyword checks were missing. We care about correct parsing,
not necessarily the exact result of the filesystem resize.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:46 +02:00
David Sterba 88fc7becac btrfs-progs: pretty print device size in overflow error message
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:31 +02:00
Jeff Mahoney 893934258d btrfs-progs: tests: mkfs and extra large devices
Test case for mkfs to handle if total device size overflows 16EiB. The
device images are created inside temporary btrfs so this works on any
underlying filesystem (unlike NFS or tmpfs).

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ split test from original patch and update to work on any filesystem ]
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:25 +02:00
Jeff Mahoney d29f475108 btrfs-progs: check if adding device would overflow while scanning
It's theoretically possible to add multiple devices with sizes that add up
to or exceed 16EiB.  A file system will be created successfully but will
have a superblock with incorrect values for total_bytes and other fields.

Kernels up to v5.0 will crash when they encounter this scenario.

We need to check for overflow and reject the device if it would overflow.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1099147
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:23 +02:00
Jeff Mahoney 391b891278 btrfs-progs: kernel-lib: add overflow check helpers
Copy of include/linux/overflow.h from the kernel.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ split from the original patch ]
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:22 +02:00
Jeff Mahoney 1643179c6a btrfs-progs: mkfs: treat btrfs_add_to_fsid as fatal error
When btrfs_add_to_fsid fails in mkfs we try to close the ctree.  That
complains that we already have a transaction open.  We should be taking
the error path and exit cleanly without writing.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:17 +02:00
Josef Bacik 73ff25c65d btrfs-progs: check: don't check nbytes on unlinked files
We don't update the inode when evicting it, so the nbytes will be wrong
in between transaction commits.  This isn't a problem, stop complaining
about it to make generic/269 stop randomly failing. The orphan outdated
inodes can be still present but check will not skip them.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:08:11 +02:00
Qu Wenruo 50d2702e49 btrfs-progs: fsck-tests: Add test case for invalid root generation
The image contains a fs tree whose generation is over 100 larger than
super block generation.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:55 +02:00
Qu Wenruo 1baf729743 btrfs-progs: check/original: Check and repair root item geneartion
Add such ability to original mode to fix root generation mismatch, which
can be rejected by kernel.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:52 +02:00
Qu Wenruo ebf29e39c3 btrfs-progs: check/lowmem: Check and repair root generation
Since kernel is going to reject any root item which is newer than super
block generation, we need to provide a way to fix such problem in
btrfs-check.

This patch addes the ability to report and repair root generation in
lowmem mode.

This is done by cowing the root node, so we will update the root
generation along with the root node generation at commit transaction
time.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:50 +02:00
Vladimir Panteleev f972ef650b btrfs-progs: balance: check for full-balance before background fork
Move the full-balance warning to before the fork, so that the user can
see and react to it.

Notes on test:

- Don't use grep -q, as it causes a SIGPIPE during the countdown, and
  the balance thus doesn't start.

- The "balance cancel" is superfluous as the last command, but it
  provides some idempotence and allows adding more tests below it.

Issue: #168
Signed-off-by: Vladimir Panteleev <git@vladimir.panteleev.md>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:42 +02:00
Vladimir Panteleev bbb18c990c btrfs-progs: tests: fix cli-tests/003-fi-resize-args
grep's exit code was never checked (and -o errexit is not in effect),
thus the test was ineffectual and regressed.

Add the missing exit code check, and update the error messages to
make the test pass again.

Signed-off-by: Vladimir Panteleev <git@vladimir.panteleev.md>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:40 +02:00
Hans van Kranenburg e46e17ab5a btrfs-progs: docs: fix label property description
Recently, commit c9da5695b2 improved the description for the label
property, to clarify it's a filesystem property, and not a device
property. Follow this change in the man page for btrfs-property.

Also add a little hint about what to specify as object.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Hans van Kranenburg <hans.van.kranenburg@mendix.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:36 +02:00
David Sterba b4cadc2ac9 btrfs-progs: docs: fix formatting of btrfs(5)
Two paragraphs for 'discard' mount option were not aligned in the
section and the swapfile bullet list was squashed to one line. All in
the manual page output.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:33 +02:00
Nikolay Borisov fcebb87f52 btrfs-progs: tests: Check for metadata_uuid feature in misc-tests/034-metadata-uuid
Instead of checking the kernel version, explicitly check for the
presence of metadata_uuid file in sysfs. This allows the test to be run
on older kernels that might have this feature backported.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:30 +02:00
Adam Borowski 90a87e817d btrfs-progs: check: fix option parsing for -E
The option -E has a mandatory argument that was missing from the short
option spec, thus it always crashed.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-09-04 16:06:24 +02:00
David Sterba 9a85732d8b
Btrfs progs v5.2.1
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:54:59 +02:00
David Sterba 20f8386488 btrfs-progs: update CHANGES for v5.2.1
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:54:07 +02:00
David Sterba 4b09ba4b78 btrfs-progs: restore: fix chown of a symlink
User reports:

"When I execute btrfs restore -S to restore a symlink, it prints:

SYMLINK: 'dest/path/of/symlink' => 'symlink/target'
Failed to change owner: Bad file descriptor

And at cmds-restore.c#L937:

ret = fchownat(-1, file, btrfs_inode_uid(path.nodes[0], inode_item),
                           btrfs_inode_gid(path.nodes[0], inode_item),
                           AT_SYMLINK_NOFOLLOW);
"

The -1 is indeed a bad descriptor, and should be probably AT_FDCWD as
this is documented. The path passed as 'file' is always absolute, so the
semantics are unaffected.

Issue: #183
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:43 +02:00
Grzegorz Kowal 0d7159807f btrfs-progs: scrub: fix status lines alignment
Pull-request: #190
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:43 +02:00
Grzegorz Kowal 96ed8e801f btrfs-progs: scrub: fix ETA calculation
ETA is calculated in a wrong way. It should be just current time in
seconds + sec_left, independently if the job was resumed or not.

Pull-request: #190
Signed-off-by: Grzegorz Kowal <grzegorz@amuncode.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:43 +02:00
Filipe Manana df090f6eb7 Btrfs-progs: mkfs, fix metadata corruption when using mixed mode
When creating a filesystem with mixed block groups, we are creating two
space info objects to track used/reserved/pinned space, one only for data
and another one only for metadata.

This is making fstests test case generic/416 fail, with btrfs' check
reporting over an hundred errors about bad extents:

  (...)
  bad extent [17186816, 17190912), type mismatch with chunk
  bad extent [17195008, 17199104), type mismatch with chunk
  bad extent [17203200, 17207296), type mismatch with chunk
  (...)

Because, surprisingly, this results in block groups that do not have the
BTRFS_BLOCK_GROUP_DATA flag set but have data extents allocated in them.
This is a regression introduced in btrfs-progs v5.2.

So fix this by making sure we only create one space info object, for both
metadata and data, when mixed block groups are enabled.

Fixes: c31edf610c ("btrfs-progs: Fix false ENOSPC alert by tracking used space correctly")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:43 +02:00
David Sterba 4e48f14f8b btrfs-progs: tests: switch messages to _log
The _log helper should be used for test log messages instead of raw echo
to the results file.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Qu Wenruo 6f24e7276b btrfs-progs: tests: Avoid debug log populating stdout
When running misc-test/034, we got unexpected log output:
      [TEST/misc]   033-filename-length-limit
      [TEST/misc]   034-metadata-uuid
  Checking btrfstune logic
  Checking dump-super output
  Checking output after fsid change
  Checking for incompat textual representation
  Checking setting fsid back to original
  Testing btrfs-image restore

This is caused by commit 2570cff076 ("btrfs-progs: test: cleanup misc-tests/034")
which uses _log facility which also populates stdout.

Just change _log() to echo "$*" >> "$RESULTS" to fix it.
Unlike the initial commit, there is no other user of _log, so it
shouldn't affect other tests.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Omar Sandoval 4a714918f0 btrfs-progs: receive: get rid of unnecessary strdup()
In process_clone(), we're not checking the return value of strdup().
But, there's no reason to strdup() in the first place: we just pass the
path into path_cat_out(). Get rid of the strdup().

Fixes: f1c24cd80d ("Btrfs-progs: add btrfs send/receive commands")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Naohiro Aota 8ca6c0c3c7 btrfs-progs: check: initialize qgroup_item_count in earlier stage
"btrfsck -Q" segfaults because it does not call qgroup_set_item_count_ptr()
properly:

  # btrfsck -Q /dev/sdk
  Opening filesystem to check...
  Checking filesystem on /dev/sdk
  UUID: 34a35bbc-43f8-40f0-8043-65ed33f2e6c3
  Print quota groups for /dev/sdk
  UUID: 34a35bbc-43f8-40f0-8043-65ed33f2e6c3
  Segmentation fault (core dumped)

Since "struct task_ctx ctx" is global, we can just move
qgroup_set_item_count_ptr() much earlier stage in the check process to
avoid to forget initializing it.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Qu Wenruo 27049a1e77 btrfs-progs: extent-tree: Unify the parameters of btrfs_inc_extent_ref()
The old parameters, @ref_generation and @owner_objectid, are pretty
confusing when using auto-completion.

Unify the parameters as a quick fix.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba 40347be06d btrfs-progs: props: update help texts
- add first line of the long description
- list the type values in all commands (set, get, list)
- enhance
- split option description

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba c6d00c3f00 btrfs-progs: props: convert to C99 initializers
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
David Sterba c9da5695b2 btrfs-progs: props: update descriptions
Drop 'set/get' and update descriptions.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Josef Bacik 42a1aaeec4 btrfs-progs: deal with drop_progress properly in fsck
While testing snapshot deletion with dm-log-writes I saw that I was
failing the fsck sometimes when the fs was actually in the correct
state.  This is because we only skip blocks on the same level of
root_item->drop_level.  If the drop_level < the root level then we could
very well walk into nodes that we wouldn't actually walk into on fs
mount, because the drop_progress is further ahead in the slot of the
root.  Instead only process the slots of the nodes that are above the
drop_progress key.  With this patch in place we no longer improperly
fail to check fs'es that have a drop_progress set with a drop_level <
root level.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:42 +02:00
Qu Wenruo 2a8cec4b12 btrfs-progs: Exhaust delayed refs and dirty block groups to prevent delayed refs lost
[BUG]
Btrfs-progs sometimes fails to find certain extent backref when
committing transaction.
The most reliable way to reproduce it is fsck-test/013 on 64K page sized
system:

  [...]
  adding new data backref on 315859712 root 287 owner 292 offset 0 found 1
  btrfs unable to find ref byte nr 31850496 parent 0 root 2  owner 0 offset 0
  Failed to find [30867456, 168, 65536]

Also there are some github bug reports related to this problem.

[CAUSE]
Commit 909357e867 ("btrfs-progs: Wire up delayed refs") introduced
delayed refs in btrfs-progs.

However in that commit, delayed refs are not run at correct timing.
That commit calls btrfs_run_delayed_refs() before
btrfs_write_dirty_block_groups(), which needs to update
BLOCK_GROUP_ITEMs in extent tree, thus could cause new delayed refs.

This means each time we commit a transaction, we may screw up the extent
tree by dropping some pending delayed refs, like:

Transaction 711:
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
|  Now all delayed refs are written to extent tree
|
|- btrfs_write_dirty_block_groups()
|  Needs to update extent tree root
|  ADD_DELAYED_REF to 315859712.
|  Delayed refs are attached to current trans handle.
|
|- __commit_transaction()
|- write_ctree_super()
|- btrfs_finish_extent_commit()
|- kfree(trans)
   Now delayed ref for 315859712 are lost

Transaction 712:
Tree block 315859712 get dropped
btrfs_commit_transaction()
|- btrfs_run_delayed_refs()
   |- run_one_delayed_ref()
      |- __free_extent()
         As previous ADD_DELAYED_REF to 315859712 is lost, extent tree
         doesn't have any backref for 315859712, causing the bug

In fact, commit c31edf610c ("btrfs-progs: Fix false ENOSPC alert by
tracking used space correctly") detects the tree block leakage, but in
the reproducer we have too much noise, thus nobody notices the leakage
warning.

[FIX]
We can't just move btrfs_run_delayed_refs() after
btrfs_write_dirty_block_groups(), as during btrfs_run_delayed_refs(), we
can re-dirty block groups.
Thus we need to exhaust both delayed refs and dirty blocks.

This patch will call btrfs_write_dirty_block_groups() and
btrfs_run_delayed_refs() in a loop until both delayed refs and dirty
blocks are exhausted. Much like what we do in commit_cowonly_roots() in
kernel.

Also, to prevent such problem from happening again (and not to debug
such problem again), add extra check on delayed refs before freeing the
transaction handle.

Reported-by: Klemens Schölhorn <klemens@schoelhorn.eu>
Issue: #187
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:41 +02:00
Adam Borowski 1e6246eaec btrfs-progs: fix a printf format string fatal warning
At least in Debian, default build flags include -Werror=format-security,
for good reasons in most cases.  Here, the string comes from strftime --
and though I don't suspect any locale would be crazy enough to have %X
include a '%' char, the compiler has no way to know that.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-26 17:46:41 +02:00
David Sterba 608fd900ca
Btrfs progs v5.2
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-05 18:21:55 +02:00
David Sterba 9ebb5057ad btrfs-progs: update CHANGES for v5.2
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-05 18:20:22 +02:00
David Sterba 4d29e37947 libbtrfsutil: subvolume: use helpers to access search header
The test cli-tests/008-subvolume-get-set-default fails when compiled
with 'D=ubsan', the access to search header items does not follow the
type alignment, so use the accessors.

The error:

  subvolume get-default: default id is not 256, but
	  libbtrfsutil/subvolume.c:361:13: runtime error: member access within
	  misaligned address 0x7ffc147e4b6f for type 'const struct
	  btrfs_ioctl_search_header', which requires 8 byte alignment

Note that using the accessors does not fix the ubsan warning, as it
warns on taking the address of a member whose _base_ type is unaligned,
ie. it's the 'sh'.

Fixing that would need to play tricks with pointers to do &sh->type
manually, but to avoid triggering ubsan.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:02 +02:00
David Sterba db1246039d libbtrfsutil: add accessors for search header items
Add helpers that do proper unaligned access of search heade items. This
is done in the non-libbtrfsutil code already, use the same helpers here
too. We can't use the get_unaligned_* helpers that are defined in
kerncompat, so use plain memcpy that will work everywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:02 +02:00
David Sterba dc6da57e0a btrfs-progs: tests: make test-clean work without built binaries
'make clean' followed by 'make test-clean' will fail due to the sanity
check for 'btrfs' binary. We don't need that for cleaning the test, so
turn the error into a warning.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:02 +02:00
David Sterba 7797f03924 btrfs-progs: sb-mod: add remaining superblock integer items
Add support for changing all integer items in the superblock. Sort them
in the order of defintion in the structure.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 5ab79b808a btrfs-progs: sb-mod: add remaining integer value types
The field type bit width is now only used to describe the members, but
let's add all of the integer ones.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 9b3a9daacd btrfs-progs: build: add stub makefile to image and mkfs
Add makefiles that work inside the image and mkfs directories, this
already exists for convert.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00