Fixed by commit 7c646c538e btrfs-progs: qgroup: Fix regression leads
to corrupted qgroup status.
Add minimal test image for that fix.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor cleanups in test.sh ]
Signed-off-by: David Sterba <dsterba@suse.com>
For tree reloc tree whose level is >= 2, the root node's parent will
point to itself.
In this case it will make btrfsck overflow its stack and cause segfault.
While for tree reloc tree, it doesn't affect qgroup and kernel can
handle it well.
So add tree reloc tree check for qgroup-verify.c and fix the bug.
Test case will follow soon after I make a minimal image for it.
Current xz ziped image is still over 10M for a 512M fs.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
In v4.8-rc1, gcc 5.3.1 gives following warning. Fixed it.
[CC] btrfs-image.o
btrfs-image.c: In function 'flush_pending':
btrfs-image.c:708:17: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
header->bytenr = cpu_to_le64(start);
^
btrfs-image.c:927:6: note: 'start' was declared here
u64 start;
^
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Add a new test case to check if btrfs-convert copies common inode flags
like append(a), immutable(i).
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
Before this patch, btrfs-convert never copy ext* inode flags to
corresponding btrfs inode flags.
This makes common flags like APPEND/SYNC/SYNCDIR/IMMUTABLE not copied to
btrfs inode.
This patch introduces ext2_convert_inode_flags() function to handle the
convert, so btrfs-convert can copy as many inode flags as possible.
Reported-by: Lakshmipathi.G <lakshmipathi.g@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Before this patch, only 3 inode flags have readable string: NODATACOW,
NODATASUM, READONLY.
This patch will output all readable strings for remaining inode flags,
making debug-tree tool more handy.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
Btrfs-progs header lacks quite a lot inode flags.
Copy them from kernel for later use.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Add another target that'll use default compiler options, eg. if we don't
know the bitness of the architecture or gcc does not recognize the
-m32/-m64 options.
Signed-off-by: David Sterba <dsterba@suse.com>
Enhance the test to verify ioctl uniqueness, compare the defined values
against the hardcoded expected values, and take care of the 32bit/64bit
compatibility workarounds.
Signed-off-by: David Sterba <dsterba@suse.com>
The ioctl value of SEND will be different on 32bit userspace and 64bit
kernel due to different pointer type width, that unfortunatelly made it
into the structure definition.
To maintain backward compatibility, we must do it in the 64bit->32bit
way, because we don't have the kernel side workardound like
SET_RECEIVED_SUBVOL has. Changing value of SEND would then break
existing users of the raw ioctl.
The compatibility structure and ioctl should not be used, exists for
documentation, and testing.
Signed-off-by: David Sterba <dsterba@suse.com>
The ioctl value of SET_RECEIVED_SUBVOL will be different on 32bit
userspace and 64bit kernel. This is transparently handled on the kernel
side. We now define the same structure so we can verify the ioctl value.
The defined structure and ioctl should not be used. It is exists only
for testing purposes, documenting the mess and as a warning for the
future.
Signed-off-by: David Sterba <dsterba@suse.com>
Temporarily make the build checks optional. The structure sizes could
change on arches due to alignment requirements or padding inserted into
the structures. We need more extensive tests to make sure we'd not break
ioctls.
Signed-off-by: David Sterba <dsterba@suse.com>
If we disable backtrace, btrfs-progs can't be compiled since we don't
have warning_trace defined.
Fix by move it out of #ifndef BTRFS_DISABLE_BACKTRACE block.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ move warning_trace to the right place ]
Signed-off-by: David Sterba <dsterba@suse.com>
All structures that become part of ioctl definition must never change
size. Add the build time checks for that.
Signed-off-by: David Sterba <dsterba@suse.com>
Curretnly WARN_ON would crash but that's not it's purpose. Add helper
that prints the warning, optionally with trace.
Signed-off-by: David Sterba <dsterba@suse.com>
Some fuzzed images cause various tools to crash but the mayfail helper
would not recognize that. We don't mind if the utility failes but it
must not crash.
Signed-off-by: David Sterba <dsterba@suse.com>
If an extent is found to have length 0, we'd loop endlessly in
copy_from_extent_tree. Reproduced by fuzzed image
bko-166361-blocksize-zero.raw within test 002-simple-image .
Signed-off-by: David Sterba <dsterba@suse.com>
Fix use-before-sanity-check leading to undefined behaviour and handle
errors more gracefully.
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156811
Signed-off-by: David Sterba <dsterba@suse.com>
If blocksize is 0, it passes the IS_ALIGNED check but fails later as the
length of ebs will be zero.
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=169311
Signed-off-by: David Sterba <dsterba@suse.com>
Commit 93dabf211d
Author: Mark Fasheh <mfasheh@suse.de>
Date: Fri Jun 17 13:37:48 2016 -0700
btrfs-progs: check: verify qgroups above level 0
This commit introduced a new regression which corrupts
read_qgroup_status, since it iterate leaf with manually specified slot,
not correct path->slot[0].
This leads to wrong slot[0] and read_qgroup_status() will read out wrong
flags, leading to regression.
Fix read_qgroup_status() by using eb and slot instread of wrong path
strucutre.
Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>