Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
btrfsprogs
0026-btrfs-progs-convert-Fix-bugs-in-backup-sup...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0026-btrfs-progs-convert-Fix-bugs-in-backup-superblock-mi.patch of Package btrfsprogs
From: Qu Wenruo <quwenruo@cn.fujitsu.com> Date: Tue, 31 May 2016 16:49:33 +0800 Subject: btrfs-progs: convert: Fix bugs in backup superblock migration Git-commit: 0c621b519d531600655f179f1ebf62c0dd95e478 Patch-mainline: v4.6 References: bsc#1042369 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-convert.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/btrfs-convert.c b/btrfs-convert.c index 2c76bc8..a67883e 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -1263,12 +1263,55 @@ static int create_image_file_range(struct btrfs_trans_handle *trans, struct btrfs_block_group_cache *bg_cache; u64 len = *ret_len; u64 disk_bytenr; + int i; int ret; BUG_ON(bytenr != round_down(bytenr, root->sectorsize)); BUG_ON(len != round_down(len, root->sectorsize)); len = min_t(u64, len, BTRFS_MAX_EXTENT_SIZE); + /* + * Skip sb ranges first + * [0, 1M), [sb_offset(1), +64K), [sb_offset(2), +64K]. + * + * Or we will insert a hole into current image file, and later + * migrate block will fail as there is already a file extent. + */ + if (bytenr < 1024 * 1024) { + *ret_len = 1024 * 1024 - bytenr; + return 0; + } + for (i = 1; i < BTRFS_SUPER_MIRROR_MAX; i++) { + u64 cur = btrfs_sb_offset(i); + + if (bytenr >= cur && bytenr < cur + BTRFS_STRIPE_LEN) { + *ret_len = cur + BTRFS_STRIPE_LEN - bytenr; + return 0; + } + } + for (i = 1; i < BTRFS_SUPER_MIRROR_MAX; i++) { + u64 cur = btrfs_sb_offset(i); + + /* + * |--reserved--| + * |----range-------| + * May still need to go through file extent inserts + */ + if (bytenr < cur && bytenr + len >= cur) { + len = min_t(u64, len, cur - bytenr); + break; + } + /* + * |--reserved--| + * |---range---| + * Drop out, no need to insert anything + */ + if (bytenr >= cur && bytenr < cur + BTRFS_STRIPE_LEN) { + *ret_len = cur + BTRFS_STRIPE_LEN - bytenr; + return 0; + } + } + cache = search_cache_extent(used, bytenr); if (cache) { if (cache->start <= bytenr) { @@ -1425,7 +1468,7 @@ static int migrate_reserved_ranges(struct btrfs_trans_handle *trans, /* second sb(fisrt sb is included in 0~1M) */ cur_off = btrfs_sb_offset(1); cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off; - if (cur_off < total_bytes) + if (cur_off > total_bytes) return ret; ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino, cur_off, cur_len, datacsum); @@ -1435,7 +1478,7 @@ static int migrate_reserved_ranges(struct btrfs_trans_handle *trans, /* Last sb */ cur_off = btrfs_sb_offset(2); cur_len = min(total_bytes, cur_off + BTRFS_STRIPE_LEN) - cur_off; - if (cur_off < total_bytes) + if (cur_off > total_bytes) return ret; ret = migrate_one_reserved_range(trans, root, used, inode, fd, ino, cur_off, cur_len, datacsum); -- 2.12.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor