diff mbox

[RFC,5/5,v3] Btrfs: avoid log replay when btrfs is insane

Message ID 4CF8A7A4.9020405@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

liubo Dec. 3, 2010, 8:17 a.m. UTC
None
diff mbox

Patch

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