* [RESEND e2progs] get_backup_sb: Consider block size when searching for backups
@ 2007-05-29 21:26 Daniel Drake
2007-05-29 23:06 ` Andreas Dilger
2007-05-31 15:56 ` Theodore Tso
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Drake @ 2007-05-29 21:26 UTC (permalink / raw)
To: tytso; +Cc: linux-ext4
I sent this in a few weeks ago, and it hasn't been applied to the hg tree.
Any comments? Thanks.
I've been investigating why e2fsck refuses to restore the backup superblock
of a partition with a broken primary superblock.
The partition in question has a block size of 4096, and mke2fs reports that
backup superblocks were created on blocks 32768, 98304, 163840, ...
When running e2fsck, get_backup_sb starts by guessing a block size of 1024
and backup superblock at block 8193. I'm not sure why, but it actually finds
a superblock at this location, so returns a context with superblock 8193,
blocksize 1024.
Later on, ext2fs_open2() tries to process this superblock. It then realises
that the block size value stored in the superblock (4096) does not match what
it was told (1024), so it bails out with EXT2_ET_UNEXPECTED_BLOCK_SIZE. fsck
aborts without fixing the partition.
The following patch solves the problem by discounting superblocks which do
not meet the currently-sought block size.
As a result, block 32768 (blocksize=4096) is now used to restore the backup,
which agrees with the first location that mke2fs listed.
This doesn't explain why a superblock backup also appears to exist at
block 8193 (blocksize=1024), which in terms of my real filesystem is actually
offset into block 2048 (blocksize=4096). I assume there is an explanation
for this...
Signed-off-by: Daniel Drake <d.drake@mmm.com>
Index: e2fsprogs-1.39/e2fsck/util.c
===================================================================
--- e2fsprogs-1.39.orig/e2fsck/util.c
+++ e2fsprogs-1.39/e2fsck/util.c
@@ -453,7 +453,8 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_f
if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
ext2fs_swap_super(sb);
#endif
- if (sb->s_magic == EXT2_SUPER_MAGIC) {
+ if (sb->s_magic == EXT2_SUPER_MAGIC &&
+ EXT2_BLOCK_SIZE(sb) == blocksize) {
ret_sb = superblock;
if (ctx) {
ctx->superblock = superblock;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RESEND e2progs] get_backup_sb: Consider block size when searching for backups
2007-05-29 21:26 [RESEND e2progs] get_backup_sb: Consider block size when searching for backups Daniel Drake
@ 2007-05-29 23:06 ` Andreas Dilger
2007-05-31 15:56 ` Theodore Tso
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Dilger @ 2007-05-29 23:06 UTC (permalink / raw)
To: Daniel Drake; +Cc: tytso, linux-ext4
On May 29, 2007 22:26 +0100, Daniel Drake wrote:
> The partition in question has a block size of 4096, and mke2fs reports that
> backup superblocks were created on blocks 32768, 98304, 163840, ...
>
> When running e2fsck, get_backup_sb starts by guessing a block size of 1024
> and backup superblock at block 8193. I'm not sure why, but it actually finds
> a superblock at this location, so returns a context with superblock 8193,
> blocksize 1024.
This might be due to the superblock being in the journal at that location...
This would fit right in the 32MB = 8192 block * 4kB block journal default.
I wonder if e2fsck should start by guessing the default blocksize based on
the size of the device, as we might otherwise find old superblocks from
previous fdisk/mke2fs incarnations.
> The following patch solves the problem by discounting superblocks which do
> not meet the currently-sought block size.
> As a result, block 32768 (blocksize=4096) is now used to restore the backup,
> which agrees with the first location that mke2fs listed.
Looks reasonable.
> @@ -453,7 +453,8 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_f
> if (sb->s_magic == ext2fs_swab16(EXT2_SUPER_MAGIC))
> ext2fs_swap_super(sb);
> #endif
> - if (sb->s_magic == EXT2_SUPER_MAGIC) {
> + if (sb->s_magic == EXT2_SUPER_MAGIC &&
> + EXT2_BLOCK_SIZE(sb) == blocksize) {
> ret_sb = superblock;
> if (ctx) {
> ctx->superblock = superblock;
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RESEND e2progs] get_backup_sb: Consider block size when searching for backups
2007-05-29 21:26 [RESEND e2progs] get_backup_sb: Consider block size when searching for backups Daniel Drake
2007-05-29 23:06 ` Andreas Dilger
@ 2007-05-31 15:56 ` Theodore Tso
1 sibling, 0 replies; 3+ messages in thread
From: Theodore Tso @ 2007-05-31 15:56 UTC (permalink / raw)
To: Daniel Drake; +Cc: linux-ext4
On Tue, May 29, 2007 at 10:26:44PM +0100, Daniel Drake wrote:
> I sent this in a few weeks ago, and it hasn't been applied to the hg tree.
> Any comments? Thanks.
Thanks, applied. Sorry for the delay.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-31 15:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-29 21:26 [RESEND e2progs] get_backup_sb: Consider block size when searching for backups Daniel Drake
2007-05-29 23:06 ` Andreas Dilger
2007-05-31 15:56 ` Theodore Tso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox