linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* e2fsprogs: Fsck of read-only FS w/ external journal fails after 1.42.5?
@ 2013-05-04 19:53 Calvin Owens
  2013-05-04 23:33 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Calvin Owens @ 2013-05-04 19:53 UTC (permalink / raw)
  To: Theodore Ts'o, Eric Sandeen; +Cc: linux-ext4

Hello all,

Commit a85f8350 (http://goo.gl/aCykm) makes it impossible to fsck an
ext4 filesystem w/ external journal if it is mounted read-only. Certain
distros (Gentoo in my case) expect to be able to do this on the root
filesystem at boot time, and get very upset if they can't.

With journal checks forced now, e2fsck tries to open() the external
journal device, which always fails with -EBUSY if the filesystem is
mounted, read-only or otherwise. Is this the expected behavior? Maybe
the kernel shouldn't be returning an error there? It's been doing so
since at least v3.6.

Clearly this doesn't impact many people, since it's been in the tree for
almost a year now... but I thought I'd mention it.

Thoughts?

Thanks very much,
Calvin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: e2fsprogs: Fsck of read-only FS w/ external journal fails after 1.42.5?
  2013-05-04 19:53 e2fsprogs: Fsck of read-only FS w/ external journal fails after 1.42.5? Calvin Owens
@ 2013-05-04 23:33 ` Theodore Ts'o
  2013-05-05  0:33   ` Calvin Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Ts'o @ 2013-05-04 23:33 UTC (permalink / raw)
  To: Calvin Owens; +Cc: Eric Sandeen, linux-ext4

On Sat, May 04, 2013 at 02:53:50PM -0500, Calvin Owens wrote:
> 
> Commit a85f8350 (http://goo.gl/aCykm) makes it impossible to fsck an
> ext4 filesystem w/ external journal if it is mounted read-only. Certain
> distros (Gentoo in my case) expect to be able to do this on the root
> filesystem at boot time, and get very upset if they can't.

The fact that e2fsck would working with root file systems with an
external journal between commits 47c1b8e166 and a85f8350 was by accident.
Can you try this patch?  This should allow external journals on the
root file system to work properly.

						- Ted

>From 26991d026e4b555229a4466ae4d003420321bbd2 Mon Sep 17 00:00:00 2001
From: Theodore Ts'o <tytso@mit.edu>
Date: Sat, 4 May 2013 19:07:18 -0400
Subject: [PATCH] e2fsck: don't use IO_FLAG_EXCLUSIVE for read-only root file
 systems

When opening the external journal, use the same logic to decide
whether or not to open the file system with EXT2_FLAG_EXCLUSIVE found
in main().

Otherwise, it's not posible to use e2fsck when the root file system is
using an external journal.

Reported-by: Calvin Owens <jcalvinowens@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 e2fsck/journal.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/e2fsck/journal.c b/e2fsck/journal.c
index 767ea10..69771da 100644
--- a/e2fsck/journal.c
+++ b/e2fsck/journal.c
@@ -372,9 +372,19 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
 #ifndef USE_INODE_IO
 	if (ext_journal)
 #endif
-		retval = io_ptr->open(journal_name,
-				      IO_FLAG_RW | IO_FLAG_EXCLUSIVE,
+	{
+		int flags = IO_FLAG_RW;
+		if (!(ctx->mount_flags & EXT2_MF_ISROOT &&
+		      ctx->mount_flags & EXT2_MF_READONLY))
+			flags |= IO_FLAG_EXCLUSIVE;
+		if ((ctx->mount_flags & EXT2_MF_READONLY) &&
+		    (ctx->options & E2F_OPT_FORCE))
+			flags &= ~IO_FLAG_EXCLUSIVE;
+
+
+		retval = io_ptr->open(journal_name, flags,
 				      &ctx->journal_io);
+	}
 	if (retval)
 		goto errout;
 
-- 
1.7.12.rc0.22.gcdd159b


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: e2fsprogs: Fsck of read-only FS w/ external journal fails after 1.42.5?
  2013-05-04 23:33 ` Theodore Ts'o
@ 2013-05-05  0:33   ` Calvin Owens
  0 siblings, 0 replies; 3+ messages in thread
From: Calvin Owens @ 2013-05-05  0:33 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Eric Sandeen, linux-ext4

On Saturday 05/04 at 19:33 -0400, Theodore Ts'o wrote:
> On Sat, May 04, 2013 at 02:53:50PM -0500, Calvin Owens wrote:
> > 
> > Commit a85f8350 (http://goo.gl/aCykm) makes it impossible to fsck an
> > ext4 filesystem w/ external journal if it is mounted read-only. Certain
> > distros (Gentoo in my case) expect to be able to do this on the root
> > filesystem at boot time, and get very upset if they can't.
> 
> The fact that e2fsck would working with root file systems with an
> external journal between commits 47c1b8e166 and a85f8350 was by accident.
> Can you try this patch?  This should allow external journals on the
> root file system to work properly.
> 
> 						- Ted

Tested - your patch fixes the issue.

Thanks,
Calvin

> 
> From 26991d026e4b555229a4466ae4d003420321bbd2 Mon Sep 17 00:00:00 2001
> From: Theodore Ts'o <tytso@mit.edu>
> Date: Sat, 4 May 2013 19:07:18 -0400
> Subject: [PATCH] e2fsck: don't use IO_FLAG_EXCLUSIVE for read-only root file
>  systems
> 
> When opening the external journal, use the same logic to decide
> whether or not to open the file system with EXT2_FLAG_EXCLUSIVE found
> in main().
> 
> Otherwise, it's not posible to use e2fsck when the root file system is
> using an external journal.
> 
> Reported-by: Calvin Owens <jcalvinowens@gmail.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  e2fsck/journal.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/e2fsck/journal.c b/e2fsck/journal.c
> index 767ea10..69771da 100644
> --- a/e2fsck/journal.c
> +++ b/e2fsck/journal.c
> @@ -372,9 +372,19 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
>  #ifndef USE_INODE_IO
>  	if (ext_journal)
>  #endif
> -		retval = io_ptr->open(journal_name,
> -				      IO_FLAG_RW | IO_FLAG_EXCLUSIVE,
> +	{
> +		int flags = IO_FLAG_RW;
> +		if (!(ctx->mount_flags & EXT2_MF_ISROOT &&
> +		      ctx->mount_flags & EXT2_MF_READONLY))
> +			flags |= IO_FLAG_EXCLUSIVE;
> +		if ((ctx->mount_flags & EXT2_MF_READONLY) &&
> +		    (ctx->options & E2F_OPT_FORCE))
> +			flags &= ~IO_FLAG_EXCLUSIVE;
> +
> +
> +		retval = io_ptr->open(journal_name, flags,
>  				      &ctx->journal_io);
> +	}
>  	if (retval)
>  		goto errout;
>  
> -- 
> 1.7.12.rc0.22.gcdd159b
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-05  0:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-04 19:53 e2fsprogs: Fsck of read-only FS w/ external journal fails after 1.42.5? Calvin Owens
2013-05-04 23:33 ` Theodore Ts'o
2013-05-05  0:33   ` Calvin Owens

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).