All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 5/5 v3] Btrfs: avoid log replay when btrfs is insane
@ 2010-12-03  8:17 liubo
  0 siblings, 0 replies; only message in thread
From: liubo @ 2010-12-03  8:17 UTC (permalink / raw)
  To: Linux Btrfs; +Cc: Josef Bacik, Tsutomu Itoh, Yan, Zheng, Wenyi Liu, Mike Fedyk

btrfs may do log replay even as mounted readonly, since we have added
readonly check at start transaction time, in order to keep the original
attribute, it needs to set and to restore readonly flags around log
replay.
However, we do not permit log replay when btrfs is insane, and log replay
can start once btrfs is mounted in good state.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
 fs/btrfs/disk-io.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 15d795a..727e156 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1937,9 +1937,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 		btrfs_set_opt(fs_info->mount_opt, SSD);
 	}
 
-	if (btrfs_super_log_root(disk_super) != 0) {
+	if (btrfs_super_log_root(disk_super) != 0 &&
+	    !(fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR)) {
 		u64 bytenr = btrfs_super_log_root(disk_super);
 
+		unsigned int s_flags = sb->s_flags;
+		if (s_flags & MS_RDONLY)
+			sb->s_flags &= ~MS_RDONLY;
+
 		if (fs_devices->rw_devices == 0) {
 			printk(KERN_WARNING "Btrfs log replay required "
 			       "on RO media\n");
@@ -1969,6 +1974,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
 			ret =  btrfs_commit_super(tree_root);
 			BUG_ON(ret);
 		}
+
+		sb->s_flags = s_flags;
 	}
 
 	ret = btrfs_find_orphan_roots(tree_root);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-03  8:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-03  8:17 [RFC PATCH 5/5 v3] Btrfs: avoid log replay when btrfs is insane liubo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.