diff mbox

e2fsck: skip fixing UUID on a mounted filesystem with csums

Message ID 1390169374-1775-1-git-send-email-michael.marineau@coreos.com
State Accepted, archived
Headers show

Commit Message

Michael Marineau Jan. 19, 2014, 10:09 p.m. UTC
This fix is similar to 66457fcb for tune2fs. When booting from a root
filesystem with an empty UUID which fsck fixes the following remount
step reliably fails, leaving the filesystem in an inconsistent state.
Like the tune2fs fix this patch resolves the issue by simply refusing to
update the UUID if the filesystem is mounted.

Signed-off-by: Michael Marineau <michael.marineau@coreos.com>
---

This patch is against master but is equally applicable to maint, it
applies to maint with 1 line of fuzz (ext2fs_init_csum_seed).
I've tested it on top of v1.42.9.

It may also be possible to fix this issue with a patch to ext4_remount
in the kernel but I have not investigated that.

 e2fsck/super.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Theodore Ts'o Feb. 24, 2014, 12:21 a.m. UTC | #1
On Sun, Jan 19, 2014 at 02:09:34PM -0800, Michael Marineau wrote:
> This fix is similar to 66457fcb for tune2fs. When booting from a root
> filesystem with an empty UUID which fsck fixes the following remount
> step reliably fails, leaving the filesystem in an inconsistent state.
> Like the tune2fs fix this patch resolves the issue by simply refusing to
> update the UUID if the filesystem is mounted.
> 
> Signed-off-by: Michael Marineau <michael.marineau@coreos.com>

Applied, thanks!

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/e2fsck/super.c b/e2fsck/super.c
index 59c1f97..3c92df2 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -734,8 +734,11 @@  void check_super_block(e2fsck_t ctx)
 #ifndef EXT2_SKIP_UUID
 	/*
 	 * If the UUID field isn't assigned, assign it.
+	 * Skip if checksums are enabled and the filesystem is mounted,
+	 * if the id changes under the kernel remounting rw may fail.
 	 */
-	if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid)) {
+	if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid) &&
+	    (!csum_flag || !(ctx->mount_flags & EXT2_MF_MOUNTED))) {
 		if (fix_problem(ctx, PR_0_ADD_UUID, &pctx)) {
 			uuid_generate(sb->s_uuid);
 			ext2fs_init_csum_seed(fs);