From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [PATCH -V3 3/3] tune2fs: handle bad blocks when resizing inodes
Date: Thu, 6 Aug 2009 11:42:31 +0530 [thread overview]
Message-ID: <1249539151-3191-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1249539151-3191-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
When increasing inode size if we find that the new block
that we needed to increase the inode table size is a bad
block we fail. This make sure we don't end up with a corrupt
file system when doing inode resize on a file system having
bad blocks.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
misc/tune2fs.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 966738b..546dab9 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -969,9 +969,15 @@ static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp,
ext2fs_block_bitmap bmap)
{
dgrp_t i;
+ int retval;
+ ext2_badblocks_list bb_list = 0;
blk_t j, needed_blocks = 0;
blk_t start_blk, end_blk;
+ retval = ext2fs_read_bb_inode(fs, &bb_list);
+ if (retval)
+ return retval;
+
for (i = 0; i < fs->group_desc_count; i++) {
start_blk = fs->group_desc[i].bg_inode_table +
fs->inode_blocks_per_group;
@@ -981,10 +987,14 @@ static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp,
for (j = start_blk; j < end_blk; j++) {
if (ext2fs_test_block_bitmap(fs->block_map, j)) {
- /* FIXME!!
- * What happens if the block is marked
- * as a bad block
+ /*
+ * IF the block is a bad block we fail
*/
+ if (ext2fs_badblocks_list_test(bb_list, j)) {
+ ext2fs_badblocks_list_free(bb_list);
+ return ENOSPC;
+ }
+
ext2fs_mark_block_bitmap(bmap, j);
} else {
/*
@@ -997,6 +1007,7 @@ static int get_move_bitmaps(ext2_filsys fs, int new_ino_blks_per_grp,
needed_blocks += end_blk - start_blk;
}
+ ext2fs_badblocks_list_free(bb_list);
if (needed_blocks > fs->super->s_free_blocks_count)
return ENOSPC;
--
1.6.4.13.ge6580
next prev parent reply other threads:[~2009-08-06 6:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-06 6:12 [PATCH -V3 1/3] tune2fs: Make e2fsprogs handle ENOSPC better with inode resize Aneesh Kumar K.V
2009-08-06 6:12 ` [PATCH -V3 2/3] tune2fs: Handle fs meta-data blocks during " Aneesh Kumar K.V
2009-08-06 6:12 ` Aneesh Kumar K.V [this message]
2009-08-06 6:18 ` [PATCH -V3 1/3] tune2fs: Make e2fsprogs handle ENOSPC better with " Aneesh Kumar K.V
2009-08-20 7:06 ` Aneesh Kumar K.V
2009-08-21 12:25 ` Theodore Tso
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=1249539151-3191-3-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).