Commit Graph

2126 Commits (8653831b9fbdfa2746e66bb0ba839f3f461fddfc)
 

Author SHA1 Message Date
David Sterba 8653831b9f btrfs-progs: add compat header for android
Provide stubs and compat macros for android build.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:49 +02:00
kenneth.kang 455ab41f91 btrfs-progs: Add Android build mk file
Add Android.mk to use btrfs on android device.

There are still outstanding problems and build support is incomplete:

1) phread_cancel was changed to pthread_kill due to android didn't
   support that.
2) This module needs lzo library on android/external folder.
3) blkid library doesn't support fully. So have to use -f option to
   work.

Signed-off-by: kenneth.kang <kenneth.kang@lge.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:49 +02:00
Zhao Lei 07cc891d1d btrfs-progs: Simplify all-subvolumn-clean condition for wait_for_subvolume_cleaning
Instead of using a dirty-subvolumn-counter in old code, this patch
turn to use a simple and direct way:
  If (not dirty-subvolumn found in current loop) {
      return all_clean;
  }

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:49 +02:00
Zhao Lei 601c5e1b23 btrfs-progs: Simplify memory allocation for enumerate_dead_subvols
No need prepare memory for enumerate_dead_subvols() in caller, and pass
additional argument for allocated length.

Just do every thing inside enumerate_dead_subvols(), it will not
increase malloc count, but make code simple.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:49 +02:00
Zhao Lei 298746b958 btrfs-progs: Fix wrong return value of wait_for_subvolume_cleaning()
Reproduce:
 # btrfs subvolume sync /mnt/btrfs
 Subvolume id 323 is gone
 # echo $?
 1
 #

Reason:
 wait_for_subvolume_cleaning() return !0 in right case, because
 value of ret is set to "is subvolume clean" state before return.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:49 +02:00
Zhao Lei 6425752ab2 btrfs-progs: Fix infinite loop of btrfs subvolumn sync
We can trigger the bug by following operation:
  (no wait between commands 3~5)
  btrfs subvolume create /mnt/btrfs/mysubvol
  btrfs subvolume snapshot /mnt/btrfs/mysubvol /mnt/btrfs/mysubvol_snap
  btrfs subvolume delete /mnt/btrfs/mysubvol_snap
  btrfs subvolume delete /mnt/btrfs/mysubvol
  btrfs subvolume sync /mnt/btrfs
The last command will not exit.

Reason:
  List of "deleted subvolumes" are not currectly set.

  It caused by a typo of value assign, in detail:
  *ids[idx] = sh->offset;
  should be:
  (*ids)[idx] = sh->offset;
  So only first element is set to right memory address.

  If there are multiple "deleted subvolumes", program will
  keep wait.

Above typo also caused some segment fault in my test.

This patch fixed above bug.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
Byongho Lee 9a99d2b683 btrfs-progs: fix memory leak in btrfs-convert main()
In btrfs-convert main(), strdup() allocates memory to fslabel but that
memory is not freed. We could fix it by adding free() calls to every
return point, but that would make the code messy because there are
several return paths.
So I fix it by changing the code using strdup() with local array and
strncpy().

And btrfs-convert main() guarantees that string length of fslabel is not
to exceed 'BTRFS_LABEL_SIZE', so it's enough to use strcpy() instead of
strncpy() to copy fslabel in do_convert().

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
Zhao Lei 107adbd05d btrfs-progs: tests: umount TEST_MNT in clean-tests.sh
If a testcase failed, we can't run it(or other tests needs mount) again,
  # ./misc-tests.sh 007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync
  # ./misc-tests.sh 007
   [TEST]   007-subvolume-sync
   failed: mount /root/btrfs-progs/tests/test.img /root/btrfs-progs/tests/mnt
   test failed for case 007-subvolume-sync

This patch add "umount $TEST_MNT" to clean-tests.sh, to let user
clean mountpoint easily.

After patch:
  # ./misc-tests.sh  007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync
  #
  # clean-tests.sh
  #
  # ./misc-tests.sh  007
   [TEST]   007-subvolume-sync
   failed: fail
   test failed for case 007-subvolume-sync

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[added sudo helper to umount]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
Zhao Lei d4d500d341 btrfs-progs: tests: Introduce init_env to initialize common env variant
For example, $TEST_DIR is common used in severial tests, and have
duplicated code for initialize.

These duplicated code not only benifits harddisk vendor, but have
inconsistent details, as:
  convert-tests.sh: lack of mkdir
  fsck-tests/012-leaf-corruption/test.sh: unnecessary mkdir
  fsck-tests/013-extent-tree-rebuild/test.sh: unnecessary init
  misc-tests/XXX ...
And severial error message:
  _fail "unable to create mount point on $TEST_MNT"
  _fail "failed to create mount point"
  ...

This patch move initizlizaton of $TEST_DIR to common init_env(),
to avoid above problem, and init_env() can be used to add more
things in future.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
Zhao Lei 665dc49ef6 btrfs-progs: Use common unit parser for btrfs filesystem command
Move to use get_unit_mode_from_arg() for cmds-filesystem.c,
to make "btrfs filesystem df/show/usage"'s unit argument same.

Also have cleanup effect: 19 insertions(+), 181 deletions(-)

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:48 +02:00
Zhao Lei 71d856ba3c btrfs-progs: Use common unit parser for btrfs qgroup command
Move to use get_unit_mode_from_arg() for btrfs qgroup command,
to make "btrfs qgroup show"'s unit argument same with other
tools.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:01:59 +02:00
Zhao Lei 4483673ba6 btrfs-progs: Use common unit parser for btrfs device command
Move to use get_unit_mode_from_arg() for cmds-device.c,
to make "btrfs device usage"'s unit argument same with other
tools.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:01:59 +02:00
Zhao Lei 656731013a btrfs-progs: Introduce get_unit_mode_from_arg for common use
We are using separate code for parsing unit mode in current code,
better to use common function.

This patch introduces a common function to specify units as arguments
and a common help message, to make every tool in btrfs having same unit
argument.

The benefits are:
1: Unify current tool's arguments for unit
2: Make tools in future easy to implement such argument
3: Changes (enhancement) in common function have effect on all
   relative tools

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Zhao Lei f7ad593ca0 btrfs-progs: tests: Introduce subvolume sync test
Current code have following bug for subvolume sync:
1: If there are more than 1 subvolume to sync, the program will
   infinitely loop.
2: return !0 in exit

This patch add misc-tests/007-subvolume-sync for above case.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Byongho Lee 657e520a11 btrfs-progs: add memory allocation fail check in btrfs_add_to_fsid()
In btrfs_add_to_fsid(), strdup() allocates memory to device->name, but
the return value is not checked.
So add the return value check and error handling code.
And clean-up error handling code for ENOMEM case.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Byongho Lee 6e38141890 btrfs-progs: fix memory leak in btrfs-map-logical main()
In btrfs-map-logical main(), strdup() allocates memory to output_file,
but that memory is not freed.
So add missing free() calls before return.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Zhao Lei abe48ca860 btrfs-progs: use btrfs_open_dir for btrfs device command
We can use btrfs_open_dir() to check whether the target dir is
under btrfs mount point before openning, instead of checking it in kernel
through ioctl, and returning a  fuzzy error message.

Before patch:
  # (/mnt/tmp is not btrfs mountpoint)
  #
  # btrfs device add -f /dev/sda13 /mnt/tmp
  ERROR: error adding the device '/dev/sda13' - Inappropriate ioctl for device
  #

After patch:
  # btrfs device add -f /dev/sda13 /mnt/tmp
  ERROR: not btrfs filesystem: /mnt/tmp
  #

Similar fix for device remove and device usage.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[renamed to btrfs_open_dir]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Zhao Lei 87c25626c4 btrfs-progs: Introduce btrfs_open_dir wrapper
This patch introduce open_btrfs_dir() to open a dir in btrfs
filesystem.

It can be used for several tools in btrfs-progs.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[renamed from open_btrfs_dir, adjusted error messages]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
Zhao Lei 64650e13bb btrfs-progs: remove code for setup mntid in cmd_subvol_show
We don't need to use value of mntid in cmd_subvol_show(), no need
to get its value.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:14 +02:00
David Sterba bf3639dc62 btrfs-progs: fix use after free in replace start
Commit "btrfs-progs: Add further checks to btrfs replace start command"
accesses device size just after its memory is freed.

Resolves-coverity-id: 1320425
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Tsutomu Itoh f32b82ba98 btrfs-progs: add newline to some error messages
Added a missing newline to some error messages.
Also printf() was changed to fprintf(stderr) for error messages.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Reviewed-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Zhao Lei ec1fc69d39 btrfs-progs: close all fs_devices before exit in some commands
mkfs creates more than one fs_devices in fs_uuids.
1: one is for file system being created
2: others are created in test_dev_for_mkfs in order to check mount point
   test_dev_for_mkfs()-> ... -> btrfs_scan_one_device()

Current code only closes 1, and this patch also closes in case 2.

Similar problem exist in other tools, eg.::

 cmd-check.c: the function is:
 cmd_check()->check_mounted()-> ... -> btrfs_scan_one_device()
 ...

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Zhao Lei b0f760c91a btrfs-progs: Introduce btrfs_close_all_devices helper
If there is more than one fs_devices in fs_uuids list (like mkfs.btrfs
does), we need close them all before exit. Add a helper for that.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Qu Wenruo 004eabb1ad btrfs-progs: find-root: fix a bug that will cause wrong result
[BUG]
btrfs-find-root may not output desire result, as due to
search_extent_cache() may return a result that doesn't cover the desired
range, generation cache can be screwed up if higher generation tree root
is found before lower generation tree root.

For example:
=======
./btrfs-find-root  /dev/sda6  -a
Superblock thinks the generation is 8
Superblock thinks the level is 0
adding bytenr: 4194304, gen: 8	<<< Debug output
adding bytenr: 24715264, gen: 7 <<< gen is 7 at read_tree_block time
Well block 4194304(gen: 8 level: 0) seems good, and it matches
superblock
Well block 24715264(gen: 8 level: 0) seems good, and it matches
superblock  <<< But its gen is wrong at result output time
=======

[Fix]
Add a new check to make sure the search_extent_cache() is returning the
desired result.

Reported-by: Marc Merlin <marc@merlins.org>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Qu Wenruo 3eb8836424 btrfs-progs: find-root: Output matched root when searching all roots
[Bug]
When given '-a' option, btrfs-find-root will output all possible tree
roots but the exact matched one.

[Reason]
Result printing skipes the exact match one, as it will normally be shown
before the alternative ones.
But when '-a' is given, that's not the case.

[Fix]
Just show the exact match one for search all case.

Reported-by: Marc Merlin <marc@merlins.org>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Zhao Lei 96fbc6a146 btrfs-progs: unified error handling in print_replace_status
Current code of print_replace_status() mixed stdout and stderr in error
case, output a error string to stderr without "\n", then output "\n" to
stdout to end the line.

This patch fixed above problem by using unified error handle way for 3
type of errors in print_replace_status().

Also include some small logic cleanup.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
Qu Wenruo 2d46558b30 btrfs-progs: Use existing facility to replace read_data_extent function
Function read_data_extent() in btrfs-image.c is using manual-and-read
codes.
Replace it with existing read_extent_data() to reduce duplication.

Also, now we can use other mirror to try our best to do the dump, just
like read_tree_block().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
David Sterba 59df5b6e9a btrfs-progs: tests, verify that btrfs-image works on a missing device
Create a 2 device raid1 filesystem, fill with some data, delete one
device (the device node must not exist) and try to dump a filesystem
image.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:13 +02:00
David Sterba e547fdb166 btrfs-progs: tests, add more common helpers
Add support for failures of commands, log the output.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Qu Wenruo c0f32c54a3 btrfs-progs: Avoid reading bad fd in case of missing device.
Offline btrfs tools, like btrfs-image, will infinitely loop when there
is missing device.

The reason is, for missing device, it's fd will be set to -1, but before
we reading, we only check the fd validation by checking if it's 0.
So in that case, -1 will pass the validation check, and cause pread to
return 0, and loop to read.

Just change the validation check from "== 0" to "<= 0" to avoid such
problem.

Reported-by: Timothy Normand Miller <theosib@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Zhao Lei 919d2becc8 btrfs-progs: add missing free operation of raid_map for raid56
We forgot free raid_map for raid56's map_bio.
This patch add it.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Zhao Lei 7fc612e6ca btrfs-progs: Add initialztion of rec->crossing_stripes
rec->crossing_stripes is not initialized in allocate place,
and have possibility causing wrong report for normal tree block.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Byongho Lee ae60507e59 btrfs-progs: fix memory leaks in error path
This patch includes below fixes in error path:
1. fix memory leaks if realloc() fails
2. add missing call free_history() before return error in scrub_read_file()

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Reviewed-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Goffredo Baroncelli d7748770a7 btrfs-progs: Add further checks to btrfs replace start command
Add further checks to btrfs replace start command.

The following tests where added in user space before calling
the ioctl():
1) check if the new disk is greather or equal to the old one
2) check if the source device is or a block device or a
numerical dev-id

These checks are already performed in kernel space; however
when "btrfs replace start" is ran in background is not possible
to show any error returned by the ioctl(), so in case of fail
the user had to check dmesg to understand the what happened.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Tsutomu Itoh b651b8ca7e btrfs-progs: cleanup: remove unnecessary check before btrfs_free_path is called
We need not check path before btrfs_free_path() is called because
path is checked in btrfs_free_path().

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
David Sterba 25ff5e53e0 btrfs-progs: update help for device stats
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Qu Wenruo cc31e6cf50 btrfs-progs: fsck-tests: add case for inode losing all its extents
Add test case for inode with no file extents, but still non-zero size.
To test whether fsck will infinite loop.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Qu Wenruo 773ede50c0 btrfs-progs: fsck: fix a infinite loop on discount file extent repair
For a special case, discount file extent repair function will cause
infinite loop.

The case is, if the file loses all its extents, we won't have a hole
to fill, causing repair function doing nothing. Since the
I_ERR_DISCOUNT doesn't disappear, fsck will do an infinite loop.

For such case, just puch hole to fill the whole range to fix it.

Reported-by: Robert Munteanu <robert.munteanu@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:12 +02:00
Qu Wenruo 1ffa833a91 btrfs-progs: fsck: print correct file hole
If a file lost all its extents, fsck will unable to print out the hole.

Add an extra check to print out the hole range.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
David Sterba 7c41d25ec6 btrfs-progs: do not install static binaries over non-static
The builds should be able to coexist, so we don't want to forcibly
overwite the standard version.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Brendan Heading 38c5382e3f btrfs-progs: compilation errors when using musl libc
- limits.h must be included to pick up PATH_MAX.
- remove double declaration of BTRFS_DISABLE_BACKTRACE

kerncompat.h assumed that if __GLIBC__ was not defined,
it could safely define BTRFS_DISABLE_BACKTRACE, however this can be
defined by the configure script. Added a check to ensure it is not
defined first.

Signed-off-by: Brendan Heading <brendanheading@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Qu Wenruo 6936aa4c43 btrfs-progs: Add missing exit for parse_profile function
In parse_profile() function, in error handling route, it output error
message but forgot to exit(1), causing even profile is not valid, it
will just fallback to single.

Reported-by: James Harvey <jamespharvey20@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
David Sterba c78f3eea94 btrfs-progs: doc: update qgroup docs
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
David Sterba e5a6610c94 btrfs-progs: qgroup assign: add option to schedule rescan
Previous patch detecs inconsistency and unconditionally triggers quota
rescan. This may not be always desired as it's a heavy metadata
operation. In case of batch assignments it's better to trigger the
rescan at the end.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
David Sterba 79a851f143 btrfs-progs: qgroup assign: set path after checking argument count
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Qu Wenruo 62ae6b2bf2 btrfs-progs: Schedule quota rescan if qgroup assign caused inconsistence.
NOTE: This patch needs to cooperate with kernel patches, which will fix
a kernel bug that never clear INCONSISTENT bit and return 1 if quota
assign makes qgroup data inconsistent.

Some qgroup assign will cause qgroup data inconsistent, like remove a
qgroup with shared extents from a parent qgroup. But some won't, like
assign a empty(OK, nodesize rfer and exel) to a qgroup.

Newer kernel will return 1 if qgroup data inconsistent and in that case
we should schedule a quota rescan.

This patch will do this in btrfs-progs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Zhao Lei 02abd61aa0 btrfs-progs: Introduce a misc test for thread conflict in btrfs-convert
Current code of btrfs-convert have a bug of thread conflict, which caused
invalid memory accessing between threads, and make program panic.

This patch add a test item for above bug, as:
 # ./misc-tests.sh
    [TEST]   001-btrfstune-features
    [TEST]   002-uuid-rewrite
    [TEST]   003-zero-log
    [TEST]   004-convert-thread-conflict
 failed: btrfs-convert /root/btrfsprogs/tests/test.img
 test failed for case 004-convert-thread-conflict
 #
 # cat misc-tests-results.txt
 ...
 ############### btrfs-convert /root/btrfsprogs/tests/test.img
 trans 7 running 5
 ctree.c:363: btrfs_cow_block: Assertion `1` failed.
 btrfs-convert(btrfs_cow_block+0x92)[0x40acaf]
 btrfs-convert(btrfs_search_slot+0x1cb)[0x40c50f]
 btrfs-convert(btrfs_csum_file_block+0x20f)[0x41d83a]
 btrfs-convert[0x43422d]
 btrfs-convert[0x4342cd]
 btrfs-convert[0x4345ca]
 btrfs-convert[0x434767]
 btrfs-convert[0x435770]
 btrfs-convert[0x439748]
 btrfs-convert(main+0x13f8)[0x43b09d]
 /lib64/libc.so.6(__libc_start_main+0xfd)[0x335e01ecdd]
 btrfs-convert[0x407649]
 create btrfs filesystem:
         blocksize: 4096
         nodesize:  16384
         features:  extref, skinny-metadata (default)
 creating btrfs metadata.

 creating ext2fs image file.
 failed: btrfs-convert /root/btrfsprogs/tests/test.img
 test failed for case 004-convert-thread-conflict
 #

Note that this bug is not happened every time, especilly in slow
device as loop(slow cpu with fast block device is likely to trigger).
I set loop count to 20 to make bug happened in 90% tests.

Suggested-by: David Sterba <dsterba@suse.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Zhao Lei bafc3a33f5 btrfs-progs: tests: Move code to create loop device to common
This code block is used several tests, move it to ./common and add a
helper.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
Zhao Lei cb3424cd23 btrfs-progs: Set info->periodic.timer_fd to 0 in init-fail
In current code, (info->periodic.timer_fd == 0) means it is not
valid, as:
  if (info->periodic.timer_fd) {
      close(info->periodic.timer_fd);
      ...

We need set its value from -1 to 0 in create-fail case, to make
code like above works.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:10 +02:00
Zhao Lei f156337dc8 btrfs-progs: resst info->periodic.timer_fd's value after free
task_period_stop() is used to close a timer explicitly, to avoid
the timer handle closed again by task_stop(), we should reset its
value after close.

Also add value-reset for info->id for safe.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:10 +02:00