Commit graph

2188 commits

Author SHA1 Message Date
David Sterba 21f26887cd btrfs-progs: split metadata group creation out of make_root_dir
Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 19:12:38 +02:00
David Sterba 00d07721ec btrfs-progs: drop unused parameter from make_btrfs
Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 17:54:43 +02:00
David Sterba df4de2c089 btrfs-progs: move make_btrfs arguments to a struct
No functional change, just introduce the structure and switch current
users.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 17:49:21 +02:00
David Sterba f7a18e4cab btrfs-progs: add 'device remove' alias to completion
Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 15:39:59 +02:00
Tsutomu Itoh cc68c4f9af btrfs-progs: doc: fix short explanation of restore in btrfs
Short explanation of restore is wrong. Fix it.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 15:28:14 +02:00
David Sterba eb26712958 btrfs-progs: check for item end outside of leaf
Enhance leaf check to verify item ends that looks otherwise fine but
would exceed leaf. Same check is done in kernel.

Reported-by: Robert Marklund <robbelibobban@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-07-01 15:20:23 +02:00
David Sterba 1b1fd2c190 btrfs-progs: drop argument from attribute deprecated
The optional argument to attribute 'deprecated' has been introduced in
gcc 4.5, and does not build on 4.4 which is still in use. The
recommended replacements are mentioned in the comment, not absolutely
necessary to repeat it via the attribute.

Reported-by: Amr El-Sharnoby <amr.elsharnoby@horizontechs.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-30 15:05:07 +02:00
Qu Wenruo df0bb2f1d2 btrfs-progs: Add nbytes output for print-tree and reformat inode output
The original implementation doesn't output the nbytes for an inode.
Add the output and since the output is too long, reformat it to multi
lines.

This is very handy to debug related bugs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:47:57 +02:00
David Sterba e7d0a023ae btrfs-progs: no extra newline between aliased commands in help text
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:44:29 +02:00
Omar Sandoval f802f572b1 btrfs-progs: alias btrfs device delete to btrfs device remove
There's an awkward asymmetry between btrfs device add and btrfs device
delete. Resolve this by aliasing delete to remove.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:33:39 +02:00
Omar Sandoval 12aba72aed btrfs-progs: replace struct cmd_group->hidden with flags
We're also going to want to support aliases, so rather than adding
another member, replace "hidden" with a "flags" member.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:33:38 +02:00
Patrik Lundquist d26edf000c btrfs-progs: inspect: Fix out of bounds string termination.
Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:25:39 +02:00
David Sterba b681e2536e btrfs-progs: doc: update defrag page
- update wording for -t
- add optional argument to -c

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-26 16:23:00 +02:00
David Sterba dedb1ebeee btrfs-progs: defrag, check target extent earlier
Print a warning if the target extent size (option -t) is larger than 4G.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-25 19:36:06 +02:00
Patrik Lundquist 96cfbbf0ea btrfs-progs: fix defrag threshold overflow
btrfs fi defrag -t 1T overflows the u32 thresh variable and default,
instead of max, threshold is used.

Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-25 19:32:28 +02:00
Adam Borowski ce63aed165 btrfs-progs: doc: mkfs.btrfs: document -O^
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-25 19:28:49 +02:00
David Sterba 0111bb7b2a
Btrfs progs v4.1
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-22 16:48:41 +02:00
Qu Wenruo 81225f11d9 btrfs-progs: docs: new size options for fi show
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-22 16:45:06 +02:00
Qu Wenruo 15379fa225 btrfs-progs: Allow "filesystem show" command to handle different units
Now "filesystem show" command can handle different units now.

This is handy for higher level programs to get accurate output from "fi
show" command.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-22 16:40:21 +02:00
David Sterba fbb83c2df3 btrfs-progs: INSTALL: fix typos
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-22 01:39:27 +02:00
David Sterba 083c196c2e btrfs-progs: configure: fix typo in summary
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-22 01:13:48 +02:00
David Sterba bdc6c859c4 btrfs-progs: btrfstune: print correct current uuid during rewrite
uuid_unparse is supposed to take the ASCII representation of a UUID, so
we have to pass the raw fsid buffer.

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-18 19:49:44 +02:00
David Sterba 6107844cd5 btrfs-progs: btrfstune: print lowercase uuid during uuid rewrite
We're using lowercase everywhere else.

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-18 19:49:44 +02:00
David Sterba 4b4d742b26 btrfs-progs: tests: verify btrfstune output during uuid-rewrite
The 'Current fsid:' value does not match the real fsid.

Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-18 19:49:33 +02:00
Qu Wenruo eb81f8d263 btrfs-progs: map-logical: Rework map-logical logics
[BUG]
The original map-logical has the following problems:
1) Assert if we pass any tree root bytenr.
The problem is easy to trigger, here the number 29622272 is the bytenr of tree root:

 # btrfs-map-logical -l 29622272 /dev/sda6
 mirror 1 logical 29622272 physical 38010880 device /dev/sda6
 mirror 2 logical 29622272 physical 1111752704 device /dev/sda6
 extent_io.c:582: free_extent_buffer: Assertion `eb->refs < 0` failed.
 btrfs-map-logical[0x41c464]
 btrfs-map-logical(free_extent_buffer+0xc0)[0x41cf10]
 btrfs-map-logical(btrfs_release_all_roots+0x59)[0x40e649]
 btrfs-map-logical(close_ctree+0x1aa)[0x40f51a]
 btrfs-map-logical(main+0x387)[0x4077c7]
 /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f80a5562790]
 btrfs-map-logical(_start+0x29)[0x4078f9]

The problem is that, btrfs-map-logical always use sectorsize as default
block size to call alloc_extent_buffer.
And when it failes to find the block with the same size, it will free
the extent buffer in a incorrect method(Free and create a new one with
refs == 1).

2) Will return map result for non-exist extent.

 # btrfs-map-logical -l 1 -b 123456 /dev/sda6
 mirror 1 logical 1 physical 1 device /dev/sda6
 mirror 1 logical 4097 physical 4097 device /dev/sda6
 mirror 1 logical 8193 physical 8193 device /dev/sda6
 ...

Normally, before bytenr 12582912, there should be no extent as that's
the mkfs time temp metadata/system chunk.

But map-logical will still map them out.

Not to mention the 1 offset among all results.

[FIX]
This patch will rework the whole map logical by the following methods:
1) Always do things inside a extent
Even under the following case, map logical will only return covered
range in existing extents.

	|<------ range given ------->|
|<-Extent A->|	|<-Extent B->|	|<---Extent C->|
Result:
	|<-->|	|<---------->|	|<-->|

So with this patch, we will search extent tree to ensure all operation
are inside a extent before we do some stupid things.

2) No direct call on alloc_extent_buffer function.

That low-level function shouldn't be called at such high level.
It's only designed for low-level tree operation.

So in this patch we will only use safe high level functions avoid such
problem.

[RESULT]
With this patch, no assert will be triggered and better handle on
non-exist extents.

 # btrfs-map-logical -l 29622272 /dev/sda6
 mirror 1 logical 29622272 physical 38010880 device /dev/sda6
 mirror 2 logical 29622272 physical 1111752704 device /dev/sda6

 # btrfs-map-logical -l 1 -b 123456 /dev/sda6
 No extent found at range [1,123457)

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 16:10:18 +02:00
Qu Wenruo 1bbd40a1bb Btrfs-progs: map-logical: introduce write_extent_content function
This function will write extent content info desired file.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 16:10:09 +02:00
Qu Wenruo 1e28ed2f84 Btrfs-progs: map-logical: introduce print_mapping_info function
The new function will print the mapping info of given range
[logical, logical+len).

Note, caller must ensure the ranges are completely inside an extent.
Or btrfs_map_block can return -ENOENT.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 16:09:45 +02:00
Qu Wenruo 02454f307b btrfs-progs: map-logical: introduce map_one_extent function
Introduce the function to get accurate extent length based on extent
tree search.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 16:09:33 +02:00
Qu Wenruo 0074cd315c btrfs-progs: export read_extent_data function
Export it for later btrfs-map-logical cleanup.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 16:08:35 +02:00
David Sterba cf4eb9a90e
Btrfs progs v4.1-rc1
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-17 12:44:16 +02:00
David Sterba 36cc0b67f7 btrfs-progs: Makefile: fix typo, dependencies for cmds-* files
The dependency generation skipped all cmds-*.c files due to a typo
in variable name, since day one.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:03 +02:00
David Sterba 8c44cd110c btrfs-progs: send utils: deprecate path_cat and path_cat3
The functios do no allocation error handling, use _out variants instead.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:03 +02:00
David Sterba e6658cd54a btrfs-progs: receive: use static buffer for cur_subvol path
The embedded 'path' is a pointera and we can't make it a path buffer due
to API constraints. Use a separate buffer and sto using the unsafe
path_cat interface.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:03 +02:00
David Sterba 34e2149488 btrfs-progs: send utils: switch callbacks to patch_cat3_out
Also switch full_subvol_path to a static buffer as the interface
semantics change.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:02 +02:00
David Sterba 8da9ecb083 btrfs-progs: receive: use static buffer for write_path
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:02 +02:00
David Sterba 36ac098aae btrfs-progs: receive: use static buffer for root_subvol_path
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:02 +02:00
David Sterba 55e4b14b3e btrfs-progs: unify naming of key types in print-tree
Drop the BTRFS_ prefix and _KEY suffix where applicable.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:02 +02:00
David Sterba 63d1957db0 btrfs-progs: send utils: switch callbacks to new helpers
Use a local buffer for full path(s) and avoid dynamic allocations that
happend to be unchecked.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:01 +02:00
David Sterba b6a77a272b btrfs-progs: and new path_cat helpers to send utils
Add versions of path_cat and path_cat3 that do not allocate the memory.
The unhandled memory allocations are still there.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-15 14:09:11 +02:00
David Sterba d304cf1a2d btrfs-progs: send: use static buffer for output file name
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-15 14:09:10 +02:00
David Sterba a245463281 btrfs-progs: receive: use static buffer for source file
We should copy the optarg anyway.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-15 14:09:10 +02:00
David Sterba 210bd3a693 btrfs-progs: receive: use static buffer for mount point option argument
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-15 14:09:09 +02:00
David Sterba 6bfa3cae05 btrfs-progs: add helper for copying paths
Check the source path length and do the copy.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 16:44:48 +02:00
David Sterba 230ab9376c btrfs-progs: receive: use static buffer for cur_subvol
Get rid of the allocation. The logic is changed so that a NULL
cur_subvol::path means that no subvolume/snapshot has been found so far.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 16:44:48 +02:00
David Sterba 6a039e5063 btrfs-progs: properly set up ioctl arguments
At some places we do not clear the whole ioctl structure and could
pass garbage to kernel. Zero the ioctl vol_args and use a helper for
copying the path.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 16:44:48 +02:00
David Sterba 2e151027d2 btrfs-progs: use PATH_MAX instead of BTRFS_PATH_NAME_MAX
The path bufferes should be PATH_MAX but BTRFS_PATH_NAME_MAX is shorter
due to embedding in 4k aligned structures.

The only reason to use BTRFS_PATH_NAME_MAX is for the respective
structures btrfs_ioctl_vol_args::name.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 16:44:47 +02:00
David Sterba c55415e4cb btrfs-progs: send: add option to for the no-data mode
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 16:44:47 +02:00
David Sterba 14de97259b btrfs-progs: receive: implement the update_extent callback
The callback for the NO_FILE_DATA send flag is missing and would crash
if such stream is received.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 14:39:57 +02:00
Josef Bacik b47fdc73c3 btrfs-progs: make receive work inside of subvolumes
Kind of a big feature of btrfs is being able to have a default subvol.  However
the receive code generates the paths to the subvols from the root of the fs,
even in the case of a default subvol.  So instead figure out if we're inside of
a subvol, either because we have a different default or we've chroot'ed and are
using -m.  Then strip this extra path off of the subvol we find so we can look
up our parent properly.  Thanks

Reported-by: Neil Horman <nhorman@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-12 14:39:57 +02:00
David Sterba 6d7999d5b7 btrfs-progs: use less memory for pretty_size_mode buffers
Anand reports that the static buffers used for pertty size strings cause
a stack overflow on SPARC. Zach proposed to change the printf format to
wrap the number and the suffix into a macro. This would require to
change all callsites of pretty_size* and is not very convienient to
write.

This patch replaces the per-call-site static buffers with a limited
number for slots that would be used on each invokation of pretty_size
and wrap around. The number of array slots shall be 10 for now, in
current codebase there are no more than 2 calls to pretty_size in a
single argument list.

Reported-by: Anand Jain <Anand.Jain@oracle.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-11 01:10:10 +02:00