From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: George Spelvin <linux@horizon.com>, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 4/6] resize2fs: handle bg descriptors which overlap with other bg's metadata
Date: Sat, 29 Dec 2012 03:55:26 -0500 [thread overview]
Message-ID: <1356771328-18196-5-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1356771328-18196-1-git-send-email-tytso@mit.edu>
With flex_bg file systems, bg-specific metadata (i.e., bitmaps and the
inode table blocks) can be located in another block group. Hence,
when we grow the number of block group descriptors, we need to check
if we need to relocate metadata blocks not just for the block group
where the bgd blocks are located, but in all block groups.
This change fixes the following test case:
rm -f foo.img; touch foo.img
truncate -s 32G foo.img
mke2fs -F -t ext4 -E resize=12582912 foo.img
e2fsck -f foo.img
truncate -s 256G foo.img
./resize2fs foo.img
e2fsck -fy foo.img
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
resize/resize2fs.c | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 9702645..159846d 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -745,14 +745,41 @@ static void mark_fs_metablock(ext2_resize_t rfs,
if (IS_BLOCK_BM(fs, group, blk)) {
ext2fs_block_bitmap_loc_set(fs, group, 0);
rfs->needed_blocks++;
- } else if (IS_INODE_BM(fs, group, blk)) {
+ return;
+ }
+ if (IS_INODE_BM(fs, group, blk)) {
ext2fs_inode_bitmap_loc_set(fs, group, 0);
rfs->needed_blocks++;
- } else if (IS_INODE_TB(fs, group, blk)) {
+ return;
+ }
+ if (IS_INODE_TB(fs, group, blk)) {
ext2fs_inode_table_loc_set(fs, group, 0);
rfs->needed_blocks++;
- } else if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
+ return;
+ }
+ if (fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_FLEX_BG) {
+ dgrp_t i;
+
+ for (i=0; i < rfs->old_fs->group_desc_count; i++) {
+ if (IS_BLOCK_BM(fs, i, blk)) {
+ ext2fs_block_bitmap_loc_set(fs, i, 0);
+ rfs->needed_blocks++;
+ return;
+ }
+ if (IS_INODE_BM(fs, i, blk)) {
+ ext2fs_inode_bitmap_loc_set(fs, i, 0);
+ rfs->needed_blocks++;
+ return;
+ }
+ if (IS_INODE_TB(fs, i, blk)) {
+ ext2fs_inode_table_loc_set(fs, i, 0);
+ rfs->needed_blocks++;
+ return;
+ }
+ }
+ }
+ if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
(ext2fs_bg_flags_test(fs, group, EXT2_BG_BLOCK_UNINIT))) {
/*
* If the block bitmap is uninitialized, which means
--
1.7.12.rc0.22.gcdd159b
next prev parent reply other threads:[~2012-12-29 8:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-29 8:55 [PATCH RFC 0/6] add full off-line resize2fs support for flex_bg file systems Theodore Ts'o
2012-12-29 8:55 ` [PATCH 1/6] mke2fs: fix crash when parsing "-E resize=NNN" with "-O 64bit" Theodore Ts'o
2012-12-29 8:55 ` [PATCH 2/6] resize2fs: reserve fs metadata blocks first in blocks_to_move() Theodore Ts'o
2012-12-29 8:55 ` [PATCH 3/6] resize2fs: reserve all metadata blocks for flex_bg file systems Theodore Ts'o
2012-12-29 8:55 ` Theodore Ts'o [this message]
2012-12-29 8:55 ` [PATCH 5/6] resize2fs: allow resizing flex_bg && !resize_inode " Theodore Ts'o
2012-12-29 8:55 ` [PATCH 6/6] resize2fs: create optimized flex_bg block groups Theodore Ts'o
2012-12-29 9:32 ` [PATCH RFC 0/6] add full off-line resize2fs support for flex_bg file systems Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1356771328-18196-5-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=linux@horizon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).