Commit Graph

1680 Commits (cff33e7ebc2a863482bd6c07fb50b897d25ccf55)
 

Author SHA1 Message Date
Qu Wenruo cf8599c338 btrfs-progs: corrupt-block: fix a delete and use bug corrupting extent tree
When corrupting extent tree, corrupt-block will iterate each child
node/leaf of a node.
However, when a node's child is leaf, btrfs_corrupt_extent_leaf() may
delete some item in the leaf, which may cause the children number of the
parent node decrease.

Before this patch, corrupt-block will read out the nritems only *ONCE*
and iterate the 'nritems' times.
When btrfs_corrupt_extent_leaf() deletes enough item, causing the
nritems of btrfs_header decreased, the last few iteration will access
non-existed node, which will cause the delete and use bug like
the following:

deleting extent record: key 40714240 168 16384
Couldn't map the block 3459802452797161472
btrfs-corrupt-block: volumes.c:1137: btrfs_num_copies: Assertion
`!(!ce)' failed.
Aborted

This patch will update the nritmes in each iteration to avoid the bug.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-14 13:12:27 +02:00
Gui Hecheng 2527730d5d btrfs-progs: init uninitialized output buf for btrfs-restore
A memory problem reported by valgrind as follows:
	=== Syscall param pwrite64(buf) points to uninitialised byte(s)
When running:
	# valgrind --leak-check=yes btrfs restore /dev/sda9 /mnt/backup

Because the output buf size is alloced with malloc, but the length of
output data is shorter than the sizeof(buf), so valgrind report
uninitialised byte(s).
We could use calloc to repalce malloc and clear this WARNING away.

Reported-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-14 13:10:44 +02:00
Hugo Mills 90a379a876 btrfs-progs: Add -R to list UUIDs of original received subvolume
When using send/receive, it it useful to be able to match up source
subvols on the send side (as, say, for -p or -c clone sources) with their
corresponding copies on the receive side. This patch adds a -R option to
btrfs sub list to show the received subvolume UUID on the receive side,
allowing the user to perform that matching correctly.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-14 13:09:52 +02:00
Holger Hoffstätte 80d8122896 Btrfs-progs: fix typos
Fix (at least one user-visible) typos: it's its, not it's.

Signed-off-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:32 +02:00
Thomas Petazzoni 1cb7bd2f3c btrfs-progs: Improve static building and installation
This commit improves the static-only building of btrfs-progs, and adds
support for installing the static only tools:

 - It now ensures that all programs are built statically, not only a
   small subset of them, by defining 'progs_static' from the existing
   'progs' variable.

 - It changes the order of libraries in the btrfs-%.static rule so
   that -lpthread (part of STATIC_LIBS) appears *after* the '$($(subst
   -,_,$(subst .static,,$@)-libs))' logic, which brings in
   -lcom_err. This is needed because libcom_err.a uses the semaphore
   functions, which are available in the pthread library.

 - Adds the necessary rules to generate the btrfsck.static link and
   btrfstune.static binary.

 - Adds an 'install-static' target to install the static
   binaries. Note that they are renamed to not carry a '.static'
   suffix.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:23 +02:00
Gustavo Zacarias ef208e98ce btrfs-progs: Add support for DISABLE_DOCUMENTATION
This commit adds the support for a make variable named
"DISABLE_DOCUMENTATION", which allows to disable the build of the
documentation. This is useful in contexts where the tools needed to
build the documentation are not necessarily available.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:15 +02:00
Gui Hecheng 101a8e1326 btrfs-progs: move debug info to verbose mode for restore
The restore tool should only print info of the restoring process
in verbose mode with -v option specified.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:07 +02:00
Arvin Schnell 68b50d43c0 btrfs-progs: library version defines
commit 46de1a6ec3 changed the
parameters of btrfs_read_and_process_send_stream().  This breaks
snapper compilation. We can include version defines usable for the C
preprocessor.

Version 0.1.0: API up to and including 46de1a6ec3 (3.14.x)

Version 0.1.1: 909131939f (changed in 3.16)

Signed-off-by: Arvin Schnell <aschnell@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:04:15 +02:00
David Sterba da5db5596c btrfs-progs: read global reserve size from space infos
Kernels >= 3.15 export the global block reserve as a space info presented
by 'btrfs fi df' but would display 'unknown' instead of some meaningful
string.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-28 02:03:33 +02:00
Gui Hecheng 5f1313a45d btrfs-progs: remove unused flags for btrfs_path
The three flags of @btrfs_path:
	btrfs_path {
		unsigned int keep_locks:1;
		unsigned int skip_locking:1;
		unsigned int leave_spinning:1;
	}
have little meaning, because the userspace @btrfs_search_slot()
is free of locking and no other routines will decide their behavior
on these. So just remove them.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-28 02:03:18 +02:00
Naohiro Aota 15cda713b2 btrfs-progs: Do not free dirty extent buffer
free_some_buffer() should not free dirty extent buffers. They are left
to be committed.

Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-28 02:03:09 +02:00
Chris Mason ea7c181c68 Btrfs Progs v3.16
Signed-off-by: Chris Mason <clm@fb.com>
2014-08-26 06:50:36 -07:00
David Sterba d34cbe76c7 btrfs-progs: check: do not require argument for --subvol-extents
$ btrfs check --subvol-extents /dev/sdx
ERROR: /dev/sdx is not a valid numeric value.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:56 +02:00
David Sterba 9f2ff27df8 btrfs-progs: mkfs make --uuid require an argument
$ mkfs.btrfs --uuid 1234... /dev/sdx
Error: error checking 1234...  status: No such file or directory

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:56 +02:00
Hugo Mills 2be623dbae btrfs-progs: Fix spelling in btrfs sub list help
"below", not "bellow"

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:55 +02:00
Zach Brown dace60fc82 btrfs-progs: fix unaligned loads in receive
A user reported corruption after receiving subvolumes.  Turning up the
logging during the receive showed that the commands and string
attributes were being received correctly but the u64 attrbutes were
sometimes corrupted by having variable number of low order bytes
introduced.

It turned out they were on a platform that corrupts unaligned userspace
loads.  Loading the u64s from the unaligned pointers into the received
command stream with get_unaligned() fixed the problem.

Reported-By: Klaus Holler <kho@gmx.at>
Tested-By: Klaus Holler <kho@gmx.at>
Signed-off-by: Zach Brown <zab@zabbo.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:55 +02:00
Gui Hecheng 3db4c0a3d3 btrfs-progs: add ask_user confirmation for btrfstune clear seeding flag
If we do the following:
	# mkfs.btrfs -f <dev>
	# mount <dev> <mnt>
	# dd if=/dev/urandom of=<mnt>/data bs=1M count=100
	# umount <dev>
	# btrfstune -S 1 <dev> 		<--- make seeding device
	# mount <dev> <mnt>
	# btrfs dev add -f <dev2> <mnt>
	# umount <dev>
	# btrfstune -S 0 <dev>		<--- clear seeding flag
	# mount <dev2> <mnt>		<=== new device not mountable

When mounting the new device, btrfs will check whether
the seeding flag is set when try to open seeding device.
If the user clears the seeding flag of the seeding device,
the new device will not be mountable. Even set the seeding
flag back will not recovery this problem, because the generation
has been changed. So clear the seeding flag has the chance to
damage the derived new fs.

So I add user confirmation check when clearing seeding flag.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:55 +02:00
Satoru Takeuchi cfee4bc139 btrfs-progs: avoid to use numeric literal for the size of uuid buffer
Replace a numeric literal to more descriptive macro for
the size of uuid buffer.

Signed-of-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:55 +02:00
Satoru Takeuchi 092a9bdd64 btrfs-progs: random fixes for usage string of btrfs scrub
- Add missing description about "-R" option in the command
  usage of "btrfs scrub resume".

- Add missing comma to avoid the following misformatted command
  usage of "btrfs scrub start". See the line of "-R" option.

===
usage: btrfs scrub start [-BdqrRf] [-c ioprio_class -n ioprio_classdata] <path>|<device>

    Start a new scrub

    -B     do not background
    -d     stats per device (-B only)
    -q     be quiet
    -r     read only mode
    -R     raw print mode, print full data instead of summary-c     set ioprio class (see ionice(1) manpage)
    -n     set ioprio classdata (see ionice(1) manpage)
    -f     force to skip checking whether scrub has started/resumed in userspace
           this is useful when scrub stats record file is damaged
===

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 16:09:48 +02:00
Satoru Takeuchi 8f921e4859 btrfs-progs: add missing descriptions of '--max-errors' in btrfs-receive documentation
Fix the lack of description of "--max-erros" option in
both man and command usage of btrfs receive.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:04 +02:00
Gui Hecheng 633f1e43d7 btrfs-progs: remove unused parameter in rollback for btrfs-convert
The @force parameter for function @do_rollback is never checked
or used, remove it.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:04 +02:00
Gui Hecheng 2b2337830c btrfs-progs: check option conflict for btrfs-convert
The -d, -i, -n options make no sense to rollback.
Check the improper usages such as:
	# btrfs-convert -r -d <dev>

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:04 +02:00
Satoru Takeuchi c2d83207bf btrfs-progs: move test_isdir() to utils.c
Since test_isdir() is a utility function, it's better to
move it to utils.c. In addition, "const char *" is
more appropriate type as its "path" argument because
this argument is not changed in this function.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: David Sterba <dsterba@suse.cz>
Cc: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:04 +02:00
Satoru Takeuchi 91b3334057 btrfs-progs: introduce test_issubvolname() for simplicity
There are many duplicated codes to check if the given string is
correct subvolume name. Introduce test_issubvolname() for this
purpose for simplicity.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: David Sterba <dsterba@suse.cz>
Cc: Mike Fleetwood <mike.fleetwood@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:04 +02:00
Gui Hecheng f0884b5dc3 btrfs-progs: add mount status check for btrfs-image
When btrfs-image run on a mounted filesystem,
the undergoing fs operations may change what you have imaged a while ago.
In this case, give a warning to remind the user that he may not
get a consistent image he wants.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[tweaked the message]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Satoru Takeuchi acf2652649 btrfs-progs: remove unnecessary NULL check after get_df()
If get_df() returns 0, "sargs" surely points to malloc'ed region.
So NULL check of sargs is not necessary.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Gui Hecheng eb39e765f1 btrfs-progs: fix improper return value check for is_existing_blk_or_reg_file
The function @is_existing_blk_or_reg_file has a return value of -errno,
which indicate the @stat call fails with non-ENOENT errors.
In this condition, we should not continue the following work.

But -errno evaluates to true and will let the following work go.
So we should judge more accurately whether the return value of
@is_existing_blk_or_reg_file is > 0 or not to decide our behavior.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Gui Hecheng 508e9ac827 btrfs-progs: remove unnecessary return value check in btrfs-property
The function @parse_prop() returns either -1 or 0, no need to check
for other values. Just return the unnecessary check.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Gui Hecheng d3aa724646 btrfs-progs: init variables which are checked later in btrfs-property
The local variable @object etc. in btrfs-property get/set functions
are to be checked whether to be NULL or not, but the @parse_args()
don't guarantee to assign a value to it, so it is better to init
it to NULL.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
David Sterba 515f8fa14a btrfs-progs: mkfs: remove experimental tag
Make it consistent with kernel status and documentation.

Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Justin Maggard 2ac5cdf79f btrfs-progs: add always option to restore's looping prompt
If you are using btrfs restore to try to recover a very large or
fragmented file, you may encounter _lots_ of prompts requiring
you to press 'y' to continue because we are looping a lot.

Add the option to press 'a', to supress these prompts for the rest
of the file.

Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Wang Shilong 84ebfa6d88 Btrfs-progs: fix some build warnings on 32bit platform
Fix following build warnings on 32bit platform:

...
utils.c:1708:3: warning: left shift count >= width of
type [enabled by default]
   if (x << i & (1UL << 63))
   ^
qgroup-verify.c:393:9: warning: cast to pointer from integer
of different size [-Wint-to-pointer-cast]
  return (struct tree_block *)unode->aux;
         ^
qgroup-verify.c:407:38: warning: cast from pointer to integer
of different size [-Wpointer-to-int-cast]
   if (ulist_add(tree_blocks, bytenr, (unsigned long long)block, 0) >= 0)
                                      ^
cmds-restore.c:120:4: warning: format %lu expects argument of type
long unsigned int, but argument 3 has type size_t [-Wformat=]
    fprintf(stderr, "bad compress length %lu\n", in_len);
...

BTW, this patch also switches other castings with new helpers.

Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Satoru Takeuchi 6452351060 btrfs-progs: Unify the messy error message formats
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:03 +02:00
Wang Shilong 5374ebe042 Btrfs-progs: remove author and copyright info from man page
>From:
http://man7.org/linux/man-pages/man7/man-pages.7.html
...
AUTHORS lists authors of the documentation or program.Use of
an AUTHORS section is strongly discouraged. Generally,
it is better not to clutter every page with a list of
(over time potentially numerous) authors; if you write
or significantly amend a page, add a copyright notice
as a comment in the source file.  If you are the author
of a device driver and want to include an address for
reporting bugs, place this under the BUGS section.
...

Suggested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Qu Wenruo de22c28ef3 btrfs-progs: Check fstype in find_mount_root()
When calling find_mount_root(), caller in fact wants to find the mount
point of *BTRFS*.

So also check ent->fstype in find_mount_root() and do special error
string output in caller.

This will suppress a lot of "Inapproiate ioctl for device" error
message.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Qu Wenruo 10c8f34f51 btrfs-progs: Remove fprintf() in find_mount_root().
find_mount_root() function in utils.c should not print error string.
Caller should be responsible to print error string.

This patch will remove the only fprintf in find_mount_root() and modify
the caller a little to use strerror() to prompt users.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Liu Bo b2d0e10d49 Btrfs-progs: fix wrong manpage of defrag command
'btrfs filesystem defrag' has an option '-t', whose manpage says

"Any extent bigger than threshold given by -t option, will be
considered already defragged. Use 0 to take the kernel default, and
use 1 to say every single extent must be rewritten."

Here 'use 0' still works, it refers to the default value(256K), however,
'use 1' is an obvious typo, it should be -1, which means the largest value
it can be.

Right now, we use parse_size() which no more allow value '-1', so in
order to keep the manpage correct, this updates it to only keep value '0'.

If you want to make sure every single extent is rewritten, please use a fairly
large size, say 1G.

Reported-by: Sebastian Ochmann <ochmann@informatik.uni-bonn.de>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Gui Hecheng f1672e50c7 btrfs-progs: use check_argc_* to check arg number for all tools
Since this patch:
	btrfs-progs: move the check_argc_* functions into utils.c

All tools including the independent tools(e.g. btrfs-image, btrfs-convert)
can share the convenience of the check_argc_* functions, so this patch
adopt the argc check functions globally.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Nils Steinger 2e1accf4fd btrfs-progs: Add uninstall targets to Makefiles.
Signed-off-by: Nils Steinger <git@n-st.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Gui Hecheng 4a67a68569 btrfs-progs: replace a confusing raw number with a macro
The raw number 36 for the uuid string length is somewhat confusing,
use a macro to define replace it.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[Use BTRFS_UUID_UNPARSED_SIZE]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Anand Jain c5898d811e btrfs-progs: fix wrong message about forcing the mixed group profile
When the added disk is small, the function btrfs_prepare_device() would
print message indicating that mixed group is forced, apparently thats
not true

reproducer:

mkfs.btrfs -f -draid1 -mraid1 /dev/sdd /dev/sdc
::
SMALL VOLUME: forcing mixed metadata/data groups <---- WRONG

mount /dev/sdd /btrfs

btrfs fi df /btrfs
Data, RAID1: total=126.25MiB, used=128.00KiB
Data, single: total=8.00MiB, used=0.00B
System, RAID1: total=8.00MiB, used=16.00KiB
System, single: total=4.00MiB, used=0.00B
Metadata, RAID1: total=126.25MiB, used=112.00KiB
Metadata, single: total=8.00MiB, used=0.00B
GlobalReserve, single: total=16.00MiB, used=0.00B

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
David Sterba ac9dccad72 btrfs-progs: fix build of static target
A user repoted that static buid fails with

utils-lib.static.o: In function `arg_strtou64':
/home/dsterba/labs/btrfs-progs/utils-lib.c:17: multiple definition of `arg_strtou64'
utils-lib.static.o:/home/dsterba/labs/btrfs-progs/utils-lib.c:17: first defined here

utils-lib.o was mistakenly added to linker twice.

Signed-off-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
2014-08-22 15:07:01 +02:00
Gui Hecheng a2e2c295d9 btrfs-progs: correct manpage option description for scrub
The -f option of scrub means to
    "force starting new scrub even if a scrub is already running"
*not*
    "force to check whether scrub has started or resumed in userspace"
as described originally.

So replace the orignal description in the manpage and code.

Also, add description of the potential failure as follows
    "If a scrub is already running, it fails."

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Gui Hecheng dfe83649cf btrfs-progs: remove unnecessary judgment for fd in scrub
The scrub_read_file function is always on a branch,
which has (fd >= 0), so there is not need to judgment
the pasted in arg.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Gui Hecheng 965cd86449 btrfs-progs: adjust the return values for scrub
o Return 0 to indicate success,
  when detected errors were corrected during scrubbing.
  P.s. This is also to facilitate scripting when return value
       is to be checked.
o Warn the users if there are uncorrectable errors detected.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Zach Brown f3936db37a btrfs-progs: mkfs: don't zero extend small files
mkfs can try to write outside of small devices.  The zeroing code
doesn't test the device size and runs before mkfs tests for small
devices and exits.

Testers experienced this as small regular files being extended as mkfs
failed:

 $ truncate -s 1m /tmp/some-file
 $ strace -epwrite ./mkfs.btrfs /tmp/some-file
 SMALL VOLUME: forcing mixed metadata/data groups

 WARNING! - Btrfs v3.14.2 IS EXPERIMENTAL
 WARNING! - see http://btrfs.wiki.kernel.org before using

 pwrite(3, ..., 2097152, 0) = 2097152
 pwrite(3, ..., 4096, 65536) = 4096
 pwrite(3 ..., 2097152, 18446744073708503040) = -1 EINVAL (Invalid argument)
 ERROR: failed to zero device '/tmp/some-file' - Input/output error

 $ ls -lh /tmp/some-file
 -rw-rw-r--. 1 zab zab 2.0M Jul 16 13:49 /tmp/some-file

This simple fix adds a helper that clamps a region to be zeroed to the
size of the device.  It doesn't address the larger questions of whether
to modify the device before the size test or whether or zero regions
that have been trimmed.

Finally, the error handling mess after the zeroing calls is cleaned up.
zero_blocks() and its callers only return -errno.

Signed-off-by: Zach Brown <zab@zabbo.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Anand Jain fcdd44470d btrfs-progs: define BTRFS_MKFS_SMALL_VOLUME_SIZE for small volume
mkfs cut of size '1024 * 1024 * 1024' to mark dev as small volume so to
force mixed group. Use a define for that.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:01 +02:00
Anand Jain 27d61fbcab btrfs-progs: dont break the string
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:00 +02:00
Tsutomu Itoh 79559e96d8 btrfs-progs: doc: fix incorrect subvol name
Subvolume name is wrong. Fix it.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:04:50 +02:00
Mark Fasheh faf540ec7e btrfs-progs: ignore orphaned qgroups by default
qgroup items are not deleted by btrfs when the underlying subvolume goes
away. As a result, btrfsck will print those as inconsistent. This can
clutter up the printout so we ignore them by default. They are still printed
if a full report (via --qgroup-report) is requested.

This patch and the ones it depends on (to do qgroup verification) can be
found at:

https://github.com/markfasheh/btrfs-progs-patches/tree/qgroup-verify

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:04:50 +02:00