e2fsck: reopen the file system with saved flags after a journal replay
PATCH 1/1 e2fsck: reopen the file system with saved flags after a journal replay
After a journal replay, we close and reopen the file system so that any changes in the superblock can get reflected in the libext2fs's internal data structures. We need to save the flags passed to ext2fs_open() that we used when we originally opened the file system.
Otherwise we could end up triggering the following error message when checking a large (or bigalloc) file system after an unclean shutdown:
fsck.ext4: Filesystem too large to use legacy bitmaps while trying to re-open
Addresses-Debian-Bug: 744953
Cc: Андрей Василишин <[email protected]>
Cc: Jon Severinsson <[email protected]>
Cc: [email protected]
---
Distributions will almost certainly want to backport this patch, since it breaks running e2fsck on file system with the 64-bit or bigalloc feature enabled
e2fsck/e2fsck.h | 1 + e2fsck/journal.c | 2 +- e2fsck/unix.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
e2fsck/e2fsck.h +1 -0
@@ -232,6 +232,7 @@ struct e2fsck_struct {blk64_t free_blocks;ino_t free_inodes;int mount_flags; +int openfs_flags;blkid_cache blkid;/* blkid cache */ #ifdef HAVE_SETJMP_H
e2fsck/journal.c +1 -1
@@ -903,7 +903,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)ext2fs_mmp_stop (ctx->fs);ext2fs_free (ctx->fs); - retval =ext2fs_open (ctx->filesystem_name,EXT2_FLAG_RW , + retval =ext2fs_open (ctx->filesystem_name, ctx->openfs_flags, ctx->superblock, blocksize, io_ptr, &ctx->fs);if (retval) {
e2fsck/unix.c +1 -0
@@ -1274,6 +1274,7 @@ restart: flags &= ~EXT2_FLAG_EXCLUSIVE ; } + ctx->openfs_flags = flags; retval =try_open_fs (ctx, flags, io_ptr, &fs); if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
Signature · 6 lines
2.0.0 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Theodore Ts'o
Date: Sat, 5 Jul 2014 23:09:57 -0400
From: Theodore Ts'o <[email protected]>
To: Ext4 Developers List <[email protected]>
Cc: Theodore Ts'o <[email protected]>, Андрей Василишин <[email protected]>,
Jon Severinsson <[email protected]>, [email protected]
Subject: [PATCH] e2fsck: reopen the file system with saved flags after a
journal replayAfter a journal replay, we close and reopen the file system so that any changes in the superblock can get reflected in the libext2fs's internal data structures. We need to save the flags passed to
ext2fs_open()that we used when we originally opened the file system.
Quoted 4 lines
Otherwise we could end up triggering the following error message when checking a large (or bigalloc) file system after an unclean shutdown:
fsck.ext4: Filesystem too large to use legacy bitmaps while trying to re-open
Hi Ted,
couple of comments below.
Quoted 46 lines
Addresses-Debian-Bug: 744953
Cc: Андрей Василишин <[email protected]>
Cc: Jon Severinsson <[email protected]>
Cc: [email protected]
---Distributions will almost certainly want to backport this patch, since it breaks running e2fsck on file system with the 64-bit or bigalloc feature enabled
e2fsck/e2fsck.h | 1 + e2fsck/journal.c | 2 +- e2fsck/unix.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)e2fsck/e2fsck.h +1
-0@@ -232,6 +232,7 @@ struct e2fsck_struct {blk64_t free_blocks;ino_t free_inodes;int mount_flags; +int openfs_flags;blkid_cache blkid;/* blkid cache */ #ifdef HAVE_SETJMP_H e2fsck/journal.c +1
-1@@ -903,7 +903,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)ext2fs_mmp_stop (ctx->fs);ext2fs_free (ctx->fs); - retval =ext2fs_open (ctx->filesystem_name,EXT2_FLAG_RW , + retval =ext2fs_open (ctx->filesystem_name, ctx->openfs_flags, ctx->superblock, blocksize, io_ptr, &ctx->fs);if (retval) {e2fsck/unix.c +0
-0
e2fsck/unix.c restart: · line 1278
Quoted 5 lines
e2fsck/unix.c +1
-0@@ -1274,6 +1274,7 @@ restart: flags &= ~EXT2_FLAG_EXCLUSIVE ; } + ctx->openfs_flags = flags; retval =try_open_fs (ctx, flags, io_ptr, &fs);
Maybe we can get rid of 'flags' argument since it's not needed anymore ?
e2fsck/unix.c restart: · line 1280
Quoted 3 lines
e2fsck/unix.c +0
-0if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
Otherwise the patch looks good, however for some reason I can not reproduce the problem in the big file system (without bigalloc) even though looking at bitmap.c it looks like we really should get that error.
The reason is that after the journal recovery we're going to set the flags again properly and rerun the fsck so everything should be fine. But I wonder whether we're actually going to need that flag, but looking at e2fsck_check_ext3_journal() it looks like we might if something is going bad ?
Thanks!
-Lukas
Quoted 5 lines · Lukáš Czerner
e2fsck/unix.c restart: · line 1278
Quoted 2 lines
e2fsck/unix.c +1
-0+ ctx->openfs_flags = flags; retval =try_open_fs (ctx, flags, io_ptr, &fs);Maybe we can get rid of 'flags' argument since it's not needed anymore ?
Yeah, I thought of that, but I was trying to keep the patch small, since I thought this was one that distros might want to cherry pick.
Quoted 4 lines
Otherwise the patch looks good, however for some reason I can not reproduce the problem in the big file system (without bigalloc) even though looking at
bitmap.cit looks like we really should get that error.
Ah, yes, in the big file system case we don't hit it because we don't actually load the bitmaps before we close and reopen the file system again. But in the bigalloc case, we check and fail at openfs time, which aborts the fsck run.
So we could work around this by moving the bigalloc check to when we open the file system, but you want get the other openfs flags right, especially the EXT2_FLAG_SKIP_MMP flags.
Cheers,
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Lukáš Czerner
Reviewed-byQuoted 10 lines · Theodore Ts'o
Date: Tue, 8 Jul 2014 07:58:27 -0400
From: Theodore Ts'o <[email protected]>
To: Lukáš Czerner <[email protected]>
Cc: Ext4 Developers List <[email protected]>,
Андрей Василишин <[email protected]>,
Jon Severinsson <[email protected]>, [email protected]
Subject: Re: [PATCH] e2fsck: reopen the file system with saved flags after a
journal replayOn Tue, Jul 08, 2014 at 11:03:53AM +0200, Lukáš Czerner wrote:
Quoted 8 lines
Quoted 5 lines
e2fsck/unix.c restart: · line 1278
Quoted 2 lines
e2fsck/unix.c +1
-0+ ctx->openfs_flags = flags; retval =try_open_fs (ctx, flags, io_ptr, &fs);Maybe we can get rid of 'flags' argument since it's not needed anymore ?
Yeah, I thought of that, but I was trying to keep the patch small, since I thought this was one that distros might want to cherry pick.
Makes sense.
Quoted 6 lines
Quoted 5 lines
Otherwise the patch looks good, however for some reason I can not reproduce the problem in the big file system (without bigalloc) even though looking at
bitmap.cit looks like we really should get that error.
Quoted 8 lines
Ah, yes, in the big file system case we don't hit it because we don't actually load the bitmaps before we close and reopen the file system again. But in the bigalloc case, we check and fail at openfs time, which aborts the fsck run.
So we could work around this by moving the bigalloc check to when we open the file system, but you want get the other openfs flags right, especially the
EXT2_FLAG_SKIP_MMPflags.
Yep, I agree with the fix, I was just wondering about the big fs case. Anyway you can add:
Quoted 9 lines
Cheers,
- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Theodore Ts'o
After a journal replay, we close and reopen the file system so that any changes in the superblock can get reflected in the libext2fs's internal data structures. We need to save the flags passed to
ext2fs_open()that we used when we originally opened the file system.Otherwise we could end up triggering the following error message when checking a large (or bigalloc) file system after an unclean shutdown:
fsck.ext4: Filesystem too large to use legacy bitmaps while trying to re-open
I had a patch in my tree that fixed this too, so you can add:
--D
Quoted 60 lines
Addresses-Debian-Bug: 744953
Cc: Андрей Василишин <[email protected]>
Cc: Jon Severinsson <[email protected]>
Cc: [email protected]
---Distributions will almost certainly want to backport this patch, since it breaks running e2fsck on file system with the 64-bit or bigalloc feature enabled
e2fsck/e2fsck.h | 1 + e2fsck/journal.c | 2 +- e2fsck/unix.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)e2fsck/e2fsck.h +1
-0@@ -232,6 +232,7 @@ struct e2fsck_struct {blk64_t free_blocks;ino_t free_inodes;int mount_flags; +int openfs_flags;blkid_cache blkid;/* blkid cache */ #ifdef HAVE_SETJMP_H e2fsck/journal.c +1
-1@@ -903,7 +903,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx)ext2fs_mmp_stop (ctx->fs);ext2fs_free (ctx->fs); - retval =ext2fs_open (ctx->filesystem_name,EXT2_FLAG_RW , + retval =ext2fs_open (ctx->filesystem_name, ctx->openfs_flags, ctx->superblock, blocksize, io_ptr, &ctx->fs);if (retval) {e2fsck/unix.c +1
-0@@ -1274,6 +1274,7 @@ restart: flags &= ~EXT2_FLAG_EXCLUSIVE ; } + ctx->openfs_flags = flags; retval =try_open_fs (ctx, flags, io_ptr, &fs); if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&Signature · 6 lines
2.0.0 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html