Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:Update
btrfsprogs.5036
0001-btrfs-progs-convert-add-compatibility-laye...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-btrfs-progs-convert-add-compatibility-layer-for-e2fs.patch of Package btrfsprogs.5036
From: Qu Wenruo <quwenruo@cn.fujitsu.com> Date: Mon, 9 May 2016 12:46:46 +0800 Subject: btrfs-progs: convert: add compatibility layer for e2fsprogs < 1.42 Git-commit: de34a25eb30bbe4b41bdef714f69fd8057ece7a9 Patch-mainline: v4.6 References: bsc#1042369 The new convert framework copies code from current dumpe2fs, which uses BIGALLOC feature introduced in e2fsprogs v1.42. While there are a lot of enterprise distributions which are still using v1.41 e2fsprogs, this will cause compile error for them. This patch introduces backward compatibility for new convert framework, by manually introduce macros for ext2 BIGALLOC feature. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com> --- btrfs-convert.c | 27 +++++++++++++++++++++++++++ configure.ac | 6 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/btrfs-convert.c b/btrfs-convert.c index b49775c..2a8d79a 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -44,6 +44,18 @@ #define INO_OFFSET (BTRFS_FIRST_FREE_OBJECTID - EXT2_ROOT_INO) #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID +/* + * Compatibility code for e2fsprogs 1.41 which doesn't support RO compat flag + * BIGALLOC. + * Unlike normal RO compat flag, BIGALLOC affects how e2fsprogs check used + * space, and btrfs-convert heavily relies on it. + */ +#ifdef HAVE_OLD_E2FSPROGS +#define EXT2FS_CLUSTER_RATIO(fs) (1) +#define EXT2_CLUSTERS_PER_GROUP(s) (EXT2_BLOCKS_PER_GROUP(s)) +#define EXT2FS_B2C(fs, blk) (blk) +#endif + struct task_ctx { uint32_t max_copy_inodes; uint32_t cur_copy_inodes; @@ -183,9 +195,23 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name) errcode_t ret; ext2_filsys ext2_fs; ext2_ino_t ino; + u32 ro_feature; + ret = ext2fs_open(name, 0, 0, 0, unix_io_manager, &ext2_fs); if (ret) { fprintf(stderr, "ext2fs_open: %s\n", error_message(ret)); + return -1; + } + /* + * We need to know exactly the used space, some RO compat flags like + * BIGALLOC will affect how used space is present. + * So we need manuall check any unsupported RO compat flags + */ + ro_feature = ext2_fs->super->s_feature_ro_compat; + if (ro_feature & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) { + error( +"unsupported RO features detected: %x, abort convert to avoid possible corruption", + ro_feature & ~EXT2_LIB_FEATURE_COMPAT_SUPP); goto fail; } ret = ext2fs_read_inode_bitmap(ext2_fs); @@ -227,6 +253,7 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name) cctx->free_inodes_count = ext2_fs->super->s_free_inodes_count; return 0; fail: + ext2fs_close(ext2_fs); return -1; } diff --git a/configure.ac b/configure.ac index 797eb79..84b7b2d 100644 --- a/configure.ac +++ b/configure.ac @@ -105,7 +105,11 @@ AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFS AC_SUBST([DISABLE_BTRFSCONVERT]) if test "x$enable_convert" = xyes; then - PKG_CHECK_MODULES(EXT2FS, [ext2fs >= 1.41]) + PKG_CHECK_MODULES(EXT2FS, [ext2fs >= 1.42],, + [PKG_CHECK_MODULES(EXT2FS, [ext2fs], + [AC_DEFINE([HAVE_OLD_E2FSPROGS], [1], + [E2fsprogs does not support BIGALLOC])] + )]) PKG_CHECK_MODULES(COM_ERR, [com_err]) fi -- 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