Push out common convert operations into function pointers that we can
ultimately allow other file systems to use to provide their own
conversions.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Catch a buggy condition fixed by "btrfs-progs: fsck: Fix a false alert
where extent record has wrong metadata flag"
Signed-off-by: David Sterba <dsterba@suse.com>
In process_extent_item(), it gives 'metadata' initial value 0, but for
non-skinny-metadata case, metadata extent can't be judged just from key
type and it forgot that case.
This causes a lot of false alert in non-skinny-metadata filesystem.
Fix it by set correct metadata value before calling add_extent_rec().
Reported-by: Christoph Anton Mitterer <calestyo@scientia.net>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
* split copies to copies and parity and add a common header for all the
raid options
* add missing RAID1
* n/a were dropped
Based on feedback from Duncan <1i5t5.duncan@cox.net>.
Signed-off-by: David Sterba <dsterba@suse.com>
If sectorsize is not BTRFS_SUPER_INFO_SIZE (4k), the superblock checksum
is wrong and mkfs fails. This has been reported on ppc64 where we pick
sectorisize from page size (64k). This has been broken since ages
(2008) and discovered by the recently added superblock checks.
Reported-by: Dinar Valeev <dvaleev@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Create filesystem on a partitioned loop device, test for "btrfs-progs:
Fix partitioned loop devices resolving".
Signed-off-by: David Sterba <dsterba@suse.com>
The loop_info64::lo_file_name might not be null terminated. Avoid strlen
and trim the length to whatever size of the loop_info buffer.
Signed-off-by: David Sterba <dsterba@suse.com>
When using partitions on a loop device, the device's name can be
e.g. /dev/loop0p1 or similar, and no relevant entry exists in the /sys
filesystem, so the current resolve_loop_device function fails.
Instead of using string functions to extract the device name and reading
this file, this patch uses the loop device API through ioctl to get the
correct backing file.
Signed-off-by: Florian Margaine <florian@platform.sh>
[ changed checks of error values from open and ioctl ]
Signed-off-by: David Sterba <dsterba@suse.com>
Add support to search chunk root, as we only need to search tree roots
in system chunk, which should be very easy to add, just iterate in
system chunks.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ renamed to btrfs_next_bg_* ]
Signed-off-by: David Sterba <dsterba@suse.com>
1: Remove more_than_one variable, use iterators value instead
2: Remove "out" label, we use break instead.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[ changelog update ]
Signed-off-by: David Sterba <dsterba@suse.com>
Switch to common warning()/error() for cmds-device.c.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
[ minor tweaks ]
Signed-off-by: David Sterba <dsterba@suse.com>
periodic.timer_fd's value is 0 on inititlize-failed case,
if no value-checking before read(), the code will run as
read(STDIN).
This patch fixed above case.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
A test for "btrfs-progs: mkfs: increase buffer size in is_ssd". Create a
device with a long name through loop device wrapped to a device mapper
linear device, switch it to the "ssd" mode status.
Signed-off-by: David Sterba <dsterba@suse.com>
In current versions of util-linux the buffer passed to blkid_devno_to_wholedisk
has to be sufficiently large to not only hold the device name but the complete
target of the /sys/dev/block/<maj:min> symlink. This was changed only recently
in 4419ffb9eff5801fdbd385a4a6199b3877f802ad.
The small buffer size currently can lead to failure of is_ssd due to truncated
device names:
readlink("/sys/dev/block/254:7", "../../devices/virtual/block/dm-", 31) = 31
open("/sys/block/dm-/queue/rotational", O_RDONLY) = -1 ENOENT (No such file or directory)
Signed-off-by: Michael Lass <bevan@bi-co.net>
Signed-off-by: David Sterba <dsterba@suse.com>
Device deletion procedures ensures the device is a block device.
This patch introduces 'missing' as keyword again, correctly
passing it on to the kernel instead of complaining about
'missing' not being a block device.
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Rewrite the loop so we don't need to allocate sectorsize and write in 4k
steps instead. We know that sectorsize is divisible by 4096.
Signed-off-by: David Sterba <dsterba@suse.com>
With the rootdir option we try to guess the final size of the image and
fill it with zeros, preceded by truncation. After patch
"Btrfs-progs: Do not force mixed block group creation unless '-M' option
is specified"
the misc test 002 will fail, because of the non-mixed mode. I think we
should not touch the image size (no change for block devices) and try to
fit into whatever is provided by user.
Signed-off-by: David Sterba <dsterba@suse.com>
Btrfs_leaf_free_space() function is used to determine the leaf/node
size.
It's OK to use root->nodesize to determine nodesize, but in fact,
extent_buffer->len can also be used to determine the nodesize if caller
can ensure it's a tree block.
So this patch will add support for NULL root for btrfs_leaf_free_space()
function, to allow btrfs_print_leaf() functions to be called in gdb or
to debug temporary btrfs in make_btrfs() without a valid root.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
When do following command in a vm, whose disks are created by
qemu-img create -f raw 11 2.6G:
# mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
# btrfs-show-super /dev/vdd /dev/vde /dev/vdf | grep dev_item.total_bytes
dev_item.total_bytes 2791727104
dev_item.total_bytes 2791729152
dev_item.total_bytes 2791729152
We can see that the first device's size is little smaller.
And it fails xfstests btrfs/011.
Reason:
First device's size is rounded down to sectorsize in make_btrfs(),
but other devices are not.
Fix:
Round down remain devices' size in btrfs_add_to_fsid().
Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
There are two total_bytes in btrfs_add_to_fsid(), local variable
of total_bytes means fs_total_bytes, and device->total_bytes means
device's total_bytes.
And device's total_bytes in argument is named block_count in current
code.
This patch rename:
total_bytes -> fs_total_bytes
block_count -> device_total_bytes
To make code more readable.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Add output for dev uuid for print_chunk().
Quite useful to debug temporary btrfs in btrfs-convert.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Variant named dev_uuid and uuid_unparse() for set its value are
not used, remove it.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
list_for_each_entry_reverse() in current code can not output
devices in sorted order, because the sequence are broken in
btrfs_alloc_chunk().
We can use list_sort() instead.
Before patch:
# mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
...
Number of devices: 3
Devices:
ID SIZE PATH
3 2.60GiB /dev/vdf
1 2.60GiB /dev/vdd
2 2.60GiB /dev/vde
After patch:
# mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
...
Number of devices: 3
Devices:
ID SIZE PATH
1 2.60GiB /dev/vdd
2 2.60GiB /dev/vde
3 2.60GiB /dev/vdf
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Currently it's one by a single "=", but we might want to use
a different filler, let's make it explicit by "*".
Signed-off-by: David Sterba <dsterba@suse.com>