diff mbox

[RFC,2/5,v3] Btrfs: avoid transaction stuff when btrfs is readonly

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

Commit Message

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

Patch

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 1fffbc0..14a597d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -181,6 +181,9 @@  static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
 	struct btrfs_trans_handle *h;
 	struct btrfs_transaction *cur_trans;
 	int ret;
+
+	if (root->fs_info->sb->s_flags & MS_RDONLY)
+		return ERR_PTR(-EROFS);
 again:
 	h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);
 	if (!h)