Btrfs: avoid transaction stuff when btrfs is readonly
RFC PATCH v3 2/5 Btrfs: avoid transaction stuff when btrfs is 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 1 line · liubo
When the filesystem is readonly, avoid transaction stuff by checking =
MS_RDONLY
fs/btrfs/transaction.c static struct btrfs_trans_handle *start_transacti=
Quoted 12 lines
at start transaction time.
Signed-off-by Liu Bo <[email protected]>---
=A0fs/btrfs/transaction.c | =A0 =A03 +++ =A01 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +0
-0@@ -181,6 +181,9 @@ static struct btrfs_trans_handle *start_transacti=
on(struct btrfs_root *root,
Quoted 8 lines
fs/btrfs/transaction.c +3
-0=A0 =A0 =A0 =A0struct btrfs_trans_handle *h; =A0 =A0 =A0 =A0struct btrfs_transaction *cur_trans; =A0 =A0 =A0 =A0int ret; + + =A0 =A0 =A0 if (root->fs_info->sb->s_flags & MS_RDONLY) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return ERR_PTR(-EROFS);=A0again:
=A0 =A0 =A0 =A0h =3D kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_=
NOFS);
Quoted 1 line
=A0 =A0 =A0 =A0if (!h)
There are cases that we need to start transaction when MS_RDONLY flag i= s set.
=46or example, remount FS into read-only mode and log replay. --
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 18 lines · Zheng
Quoted 17 lines · liubo
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.Signed-off-by Liu Bo <[email protected]>--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +1
-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; +
Quoted 8 lines
fs/btrfs/transaction.c static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, · line 189
Quoted 5 lines
fs/btrfs/transaction.c +2
-0+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)There are cases that we need to start transaction when
MS_RDONLYflag is set. For example, remount FS into read-only mode and log replay.
However, is it weird to make changes to disk as fs is in readonly state? IMO, btrfs needs to limit the use of these "disk-change while readonly" cases, as it is not what readonly means.
Since it has been here, we can bypass readonly in those cases(as I did in the 5th patch):
...
flags = sb->s_flags;
if (sb->s_flags & MS_RDONLY)
sb->s_flags &= ~MS_RDONLY
remount()
sb->s_flags = flags;
...
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
Excerpts from liubo's message of 2010-12-15 04:12:14 -0500:
Quoted 28 lines · Zheng
Quoted 18 lines · liubo
Quoted 17 lines
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.Signed-off-by Liu Bo <[email protected]>--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +1
-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; +Quoted 8 lines
fs/btrfs/transaction.c static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, · line 189
Quoted 5 lines
fs/btrfs/transaction.c +2
-0+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)There are cases that we need to start transaction when
MS_RDONLYflag is set. For example, remount FS into read-only mode and log replay.
Quoted 3 lines
However, is it weird to make changes to disk as fs is in readonly state? IMO, btrfs needs to limit the use of these "disk-change while readonly" cases, as it is not what readonly means.
reiserfs and ext3 at least have always done this. Log replay is required even when the FS is readonly.
Quoted 7 lines
Since it has been here, we can bypass readonly in those cases(as I did in the 5th patch):
...
flags =sb->s_flags;
if (sb->s_flags&MS_RDONLY)sb->s_flags &= ~MS_RDONLY
I think we should have a dedicated flag to reflect a filesystem that is forced readonly, and check that flag instead.
-chris
Quoted 29 lines · Chris Mason
Excerpts from liubo's message of 2010-12-15 04:12:14 -0500:
Quoted 28 lines · Zheng
Quoted 26 lines · liubo
Quoted 13 lines
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.Signed-off-by Liu Bo <[email protected]>--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +0
-0fs/btrfs/transaction.c static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, · line 189
Quoted 9 lines
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)There are cases that we need to start transaction when
MS_RDONLYflag is set. For example, remount FS into read-only mode and log replay.
Quoted 7 lines
Quoted 3 lines
However, is it weird to make changes to disk as fs is in readonly state? IMO, btrfs needs to limit the use of these "disk-change while readonly" cases, as it is not what readonly means.
reiserfs and ext3 at least have always done this. Log replay is required even when the FS is readonly.
Just make sure the underlying disk isn't read only, we had problems with this on ext3 a bit ago. Thanks,
Josef
Quoted 27 lines · Chris Mason
Excerpts from liubo's message of 2010-12-15 04:12:14 -0500:
Quoted 26 lines · Zheng
Quoted 25 lines · liubo
Quoted 13 lines
When the filesystem is readonly, avoid transaction stuff by checking
MS_RDONLYat start transaction time.Signed-off-by Liu Bo <[email protected]>--- fs/btrfs/transaction.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/transaction.c +0
-0fs/btrfs/transaction.c static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root, · line 189
Quoted 9 lines
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)There are cases that we need to start transaction when
MS_RDONLYflag is set. For example, remount FS into read-only mode and log replay.
Quoted 7 lines
Quoted 3 lines
However, is it weird to make changes to disk as fs is in readonly state? IMO, btrfs needs to limit the use of these "disk-change while readonly" cases, as it is not what readonly means.
reiserfs and ext3 at least have always done this. Log replay is required even when the FS is readonly.
My concern is:
now we have a forced readonly FS, which is already broken, if we still write something to disk, would it become more broken?
Quoted 9 lines
Quoted 6 lines
Since it has been here, we can bypass readonly in those cases(as I did in the 5th patch):
...
flags =sb->s_flags;
if (sb->s_flags&MS_RDONLY)sb->s_flags &= ~MS_RDONLYI think we should have a dedicated flag to reflect a filesystem that is forced readonly, and check that flag instead.
OK, we did have fs_state, a dedicated flag.
thanks,
Liu Bo
Quoted 7 lines
-chris
--
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