summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
Commit message (Collapse)AuthorAge
* btrfs-progs: convert: check source file system stateLakshmipathi.G2016-10-03
| | | | | | Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in> [ add doc note ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, kill trivial btrfs_key_type helperDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, kill trivial btrfs_set_key_type helperDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve error handling in do_rollbackDavid Sterba2016-10-03
| | | | | | Handle transaction errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use standard allocation functions in non-kenrel codeDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve error handling in create_image_file_rangeDavid Sterba2016-09-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: use preallocated buffers for config uuidsDavid Sterba2016-09-21
| | | | | | | No need for dynamic allocation, the buffers are small, remove the now-useless error conditions. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: switch to common error helpers in do_rollbackDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: reword message when conversion failsDavid Sterba2016-08-24
| | | | | | | The filesystem will not be finalized, no difference if it's before or after the chunk mapping fixups. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: switch to message helpers in do_convertDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: remove redundant checkDavid Sterba2016-08-24
| | | | | | | The check for sectorsize is properly done in do_convert, remove the BUG_ON. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve error hanling of init_btrfsDavid Sterba2016-08-24
| | | | | | Replace BUG_ONs and verbosely report the errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve error hanling of create_subvolDavid Sterba2016-08-24
| | | | | | Replace BUG_ONs and verbosely report the errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: improve error hanling of link_subvolDavid Sterba2016-08-24
| | | | | | Replace BUG_ONs and verbosely report the errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: make ext2 compilation honor the configure optionsDavid Sterba2016-08-24
| | | | | | | Now ext2 conversion will be built in iff it's selected by --with-convert option. Default is yes. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move prepare_system_chunk_sbDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move migrate_super_blockDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move init_btrfsDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move make_convert_data_block_groupsDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move create_subvolDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move link_subvolDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move create_imageDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move convert_read_used_spaceDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move calculate_available_spaceDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move wipe_reserved_rangesDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move wipe_one_reserved_rangeDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move _expand_extent_cacheDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move migrate_reserved_rangesDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move migrate_one_reserved_rangeDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move create_image_file_rangeDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move block_iterate_procDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move record_file_blocksDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move init_blk_iterate_dataDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move csum_disk_extentDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move read_disk_extentDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move convert_insert_direntDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move intersect_with_sbDavid Sterba2016-08-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: prefix all ext2-related helpersDavid Sterba2016-08-24
| | | | | | Add ext2_ prefix to all functions that seem to be ext2-specific. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build: extend convert optionsDavid Sterba2016-08-24
| | | | | | | | Add --with-convert[=VALUE] option to configure. Accepts ext2, auto, yes, or no, but will be extended to more in the future. The configure-time defines are not used in the code, ext2 is built-in unconditionally. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: two staged filesystem creationDavid Sterba2016-08-24
| | | | | | | | | | | | | | | | | | | | | | | | The filesystem existence on a device is manifested by the signature, during the mkfs process we write it first and then create other structures. Such filesystem is not valid and should not be registered during device scan nor listed among devices from blkid. This patch will introduce two staged creation. In the first phase, the signature is wrong, but recognized as a partially created filesystem (by open or scan helpers). Once we successfully create and write everything, we fixup the signature. At this point automated scanning should find a valid filesystem on all devices. We can also rely on the partially created filesystem to do better error handling during creation. We can just bail out and do not need to clean up. The partial signature is '!BHRfS_M', can be shown by btrfs inspect-internal dump-super -F image Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix a regression that ext2_save/image is not readonlyQu Wenruo2016-08-19
| | | | | | | | | | | | | | | | | | The new convert treats the convert image as a normal file, without any special flags and permissions. This is different from original code: 1) Permission changed from 0400 to 0600 2) Inode lacks READONLY flag This makes we can read-write mount the ext2 image and cause rollback failure. Follow old code behavior, use 0400 permission and add back READONLY flag to fix it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix a bug which fails to insert hole file extentQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | | When copying inode, if there is a file referring part of a hole range, convert will fail. The problem is, when calculating real extent bytenr, it doesn't check if the original extent is a hole. In case the orinal extent is a hole, we still calculate bytenr using file_pos - found_extent_file_pos, causing non-zero value, and later btrfs_record_file_extent() detects that we are pointing to non-exist extent and aborts convert. Fix it by checking the disk_bytenr before calculating real disk bytenr. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Insert needed holes for superblock migrationQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | | | New convert doesn't insert holes for superblock migration range. Unlike the old design, which only relocates 4K (superblock size) to other places. In the new design, to make sure convert can handle different page sizes and align chunks bytenr, we relocate the whole 64K range. And if there is only a 4K used block inside 64K superblock migration range, it will make converted the fs have discontiguous file extents. This patch will fix it by inserting needed holes to avoid such discontinuous error. Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix bugs in backup superblock migrationQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | | | | New convert has several bugs with backup superblock migration 1) Backup superblocks are not migrated due to incorrect condition Two wrong checks cause backup superblocks not to be migrated at all 2) Converted ext* image doesn't keep hole for backup superblocks Since we are creating file extents according to tmp_used, which has wiped out backup superblock ranges. In that case, later superblock migration will fail, since migration will insert file extent range into ext* image. Fix above bugs will make convert on ext2 image filled about 100M data successful. Reported-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Fix a bug that makes convert asserts at scan timeQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | When a ext2 fs filled with a 57M file, it's possible that convert fails with assert in add_merge_cache_extent(). The problem is that the ext2 used space just takes some of the second superblock. And due to a bug in reserving superblock space, it corrupted used space tree and cause assert. Fix in by doing better used space merging for case where superblock range is inside the ext2 used space. Reported-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Add support to rollback new convert imageQu Wenruo2016-06-07
| | | | | | | | | | | | For new btrfs-convert, it's less restrict for metadata chunk allocation. While the may_rollback() function is still following the restrict 1:1 mapping check for all chunks, it will not allow some new convert image to be rolled back. Add new per extent check for new convert to allow it to be rolled back. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Cleanup old btrfs-convertQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | | | | | | Cleanup all the old btrfs-convert facilities, including: 1) btrfs_convert_operations->alloc/free/test_extents* No need to do non-standard extent allocation. After init_btrfs() everything can be done by normal routine. Now only 4 functions are needed in btrfs_convert_operations. 1) open_fs 2) read_used_space 3) copy_inodes 4) close_fs 2) fs_info->extent_ops Same as above. 3) Old init_btrfs(), create_image(), create_file_image_range() Replaced with newer and cleaner one. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Strictly avoid meta or system chunk allocationQu Wenruo2016-06-07
| | | | | | | | | | | | | Before this patch, btrfs-convert only rely on large enough initial system/metadata chunk size to ensure no newer system/meta chunk will be created. But that's not safe enough. So add two new members in fs_info, avoid_sys/meta_chunk_alloc flags to prevent any newer system or meta chunks to be created before init_btrfs_v2(). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Convert: Add support for rollback new convert behaviorQu Wenruo2016-06-07
| | | | | | | | | | | | | | | | | | | | Add support to rollback new btrfs-convert. The support is quite easy unlike the new convert behavior, which in fact makes the rollback less restricted. The core is, rollback must support both old and new convert result. For old convert, all fs image extents can be covered by any chunk type. But any extents inside reserved range must be covered by chunk. For new convert, all fs image extents are covered by data chunk. Allowing any condition will just make another fail to pass. So make the convert condition a little less restricted to allow both can be converted. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce do_convert_v2 functionQu Wenruo2016-06-07
| | | | | | | | Introduce new function do_convert_v2() to do new convert. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ use __strncpy_null for label ] Signed-off-by: David Sterba <dsterba@suse.com>