2009-03-03 03:04:26

by Peng Tao

[permalink] [raw]
Subject: [e2fsprogs][PATCH-v2] Allow tune2fs -I if only one group per flex

This can be caused by tune2fs -O flex_bg.
And tune2fs -I should work okay if bitmaps and inode tables are still within
the group.

Signed-off-by: Peng Tao <[email protected]>
---
lib/ext2fs/check_desc.c | 12 +++++++++---
lib/ext2fs/ext2fs.h | 1 +
misc/tune2fs.c | 3 ++-
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c
index 299cb01..496c634 100644
--- a/lib/ext2fs/check_desc.c
+++ b/lib/ext2fs/check_desc.c
@@ -26,10 +26,17 @@
#include "ext2_fs.h"
#include "ext2fs.h"

+errcode_t ext2fs_check_desc(ext2_filsys fs)
+{
+ return ext2fs_check_desc_sanity(fs,
+ !EXT2_HAS_INCOMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_INCOMPAT_FLEX_BG));
+}
+
/*
* This routine sanity checks the group descriptors
*/
-errcode_t ext2fs_check_desc(ext2_filsys fs)
+errcode_t ext2fs_check_desc_sanity(ext2_filsys fs, int within_group)
{
ext2fs_block_bitmap bmap;
errcode_t retval;
@@ -49,8 +56,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs)
ext2fs_reserve_super_and_bgd(fs, i, bmap);

for (i = 0; i < fs->group_desc_count; i++) {
- if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
- EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
+ if (within_group) {
first_block = ext2fs_group_first_block(fs, i);
last_block = ext2fs_group_last_block(fs, i);
if (i == (fs->group_desc_count - 1))
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index d5026bc..29fb129 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -724,6 +724,7 @@ extern errcode_t ext2fs_move_blocks(ext2_filsys fs,

/* check_desc.c */
extern errcode_t ext2fs_check_desc(ext2_filsys fs);
+extern errcode_t ext2fs_check_desc_sanity(ext2_filsys fs, int within_group);

/* closefs.c */
extern errcode_t ext2fs_close(ext2_filsys fs);
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 887a702..f6b4fb2 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1715,7 +1715,8 @@ retry_open:
exit(1);
}
if (fs->super->s_feature_incompat &
- EXT4_FEATURE_INCOMPAT_FLEX_BG) {
+ EXT4_FEATURE_INCOMPAT_FLEX_BG &&
+ ext2fs_check_desc_sanity(fs, 1)) {
fputs(_("Changing the inode size not supported for "
"filesystems with the flex_bg\n"
"feature enabled.\n"),
--
1.6.1.3