Btrfs: avoid transaction stuff when readonly
RFC PATCH v2 2/4 Btrfs: avoid transaction stuff when readonly
When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at start transaction time.
--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/btrfs/transaction.c +3 -0
@@ -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)
Signature · 1 line
1.7.1
Quoted 3 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.
This patch may lead btrfs panic.
Since btrfs allows transaction under readonly fs state, which is a bit weird, btrfs does not even check the returned transaction from start_transaction, although it may return -ENOMEM.
With this patch, if btrfs flips readonly or is mounted readonly, to start a transaction will get a -EROFS. So we needs to check transaction more carefully, rather than just leave it alone.
thanks,
Liu Bo
Quoted 19 lines
Signed-off-by Liu Bo <[email protected]>--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +3
-0@@ -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)
Quoted 10 lines · liubo
Quoted 3 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.This patch may lead btrfs panic.
Since btrfs allows transaction under readonly fs state, which is a bit weird, btrfs does not even check the returned transaction from
start_transaction, although it may return-ENOMEM.
btrfs may do log replay even mount as readonly.
Quoted 5 lines · Zheng
Quoted 4 lines · liubo
Quoted 3 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.
Quoted 7 lines
Quoted 5 lines
This patch may lead btrfs panic.
Since btrfs allows transaction under readonly fs state, which is a bit weird, btrfs does not even check the returned transaction from
start_transaction, although it may return-ENOMEM.btrfs may do log replay even mount as readonly.
Yeah, it it right.
log replay maybe does take place when btrfs is mounted as readonly, but after the FS is broken, is btrfs willing to do log replay in such case?
thanks,
Liu Bo
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Zheng
Quoted 5 lines · liubo
Quoted 3 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.
Quoted 8 lines
Quoted 5 lines
This patch may lead btrfs panic.
Since btrfs allows transaction under readonly fs state, which is a bit weird, btrfs does not even check the returned transaction from
start_transaction, although it may return-ENOMEM.btrfs may do log replay even mount as readonly.
What part is logged besides tree roots and/or superblocks?
Quoted 8 lines · Mike Fedyk
Quoted 7 lines · Zheng
Quoted 6 lines · liubo
Quoted 3 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.This patch may lead btrfs panic.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Since btrfs allows transaction under readonly fs state, which is a bit weird, btrfs does not even check the returned transaction from
start_transaction, although it may return-ENOMEM.btrfs may do log replay even mount as readonly.
What part is logged besides tree roots and/or superblocks?
log tree is used for log replay after crash and fast fsync and O_SYNC, it logs inodes.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html