* [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
@ 2010-12-01 10:20 liubo
2010-12-02 3:42 ` liubo
0 siblings, 1 reply; 6+ messages in thread
From: liubo @ 2010-12-01 10:20 UTC (permalink / raw)
To: Linux Btrfs; +Cc: Josef Bacik, liubo
When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
start transaction time.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
---
fs/btrfs/transaction.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
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)
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
2010-12-01 10:20 [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly liubo
@ 2010-12-02 3:42 ` liubo
2010-12-02 4:28 ` Yan, Zheng
0 siblings, 1 reply; 6+ messages in thread
From: liubo @ 2010-12-02 3:42 UTC (permalink / raw)
To: Linux Btrfs; +Cc: Josef Bacik, Tsutomu Itoh
On 12/01/2010 06:20 PM, liubo wrote:
> When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
> 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
> Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
> ---
> fs/btrfs/transaction.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> 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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
2010-12-02 3:42 ` liubo
@ 2010-12-02 4:28 ` Yan, Zheng
2010-12-02 5:38 ` liubo
2010-12-02 5:41 ` Mike Fedyk
0 siblings, 2 replies; 6+ messages in thread
From: Yan, Zheng @ 2010-12-02 4:28 UTC (permalink / raw)
To: liubo; +Cc: Linux Btrfs, Josef Bacik, Tsutomu Itoh
On Thu, Dec 2, 2010 at 11:42 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
> On 12/01/2010 06:20 PM, liubo wrote:
>> When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
>> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
2010-12-02 4:28 ` Yan, Zheng
@ 2010-12-02 5:38 ` liubo
2010-12-02 5:41 ` Mike Fedyk
1 sibling, 0 replies; 6+ messages in thread
From: liubo @ 2010-12-02 5:38 UTC (permalink / raw)
To: Yan, Zheng ; +Cc: Linux Btrfs, Josef Bacik, Tsutomu Itoh
On 12/02/2010 12:28 PM, Yan, Zheng wrote:
> On Thu, Dec 2, 2010 at 11:42 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>> On 12/01/2010 06:20 PM, liubo wrote:
>>> When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
>>> 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.
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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
2010-12-02 4:28 ` Yan, Zheng
2010-12-02 5:38 ` liubo
@ 2010-12-02 5:41 ` Mike Fedyk
2010-12-02 6:36 ` liubo
1 sibling, 1 reply; 6+ messages in thread
From: Mike Fedyk @ 2010-12-02 5:41 UTC (permalink / raw)
To: Yan, Zheng; +Cc: liubo, Linux Btrfs, Josef Bacik, Tsutomu Itoh
On Wed, Dec 1, 2010 at 8:28 PM, Yan, Zheng <yanzheng@21cn.com> wrote:
> On Thu, Dec 2, 2010 at 11:42 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>> On 12/01/2010 06:20 PM, liubo wrote:
>>> When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
>>> 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.
>
What part is logged besides tree roots and/or superblocks?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly
2010-12-02 5:41 ` Mike Fedyk
@ 2010-12-02 6:36 ` liubo
0 siblings, 0 replies; 6+ messages in thread
From: liubo @ 2010-12-02 6:36 UTC (permalink / raw)
To: Mike Fedyk; +Cc: Yan, Zheng, Linux Btrfs, Josef Bacik, Tsutomu Itoh
On 12/02/2010 01:41 PM, Mike Fedyk wrote:
> On Wed, Dec 1, 2010 at 8:28 PM, Yan, Zheng <yanzheng@21cn.com> wrote:
>> On Thu, Dec 2, 2010 at 11:42 AM, liubo <liubo2009@cn.fujitsu.com> wrote:
>>> On 12/01/2010 06:20 PM, liubo wrote:
>>>> When the filesystem is readonly, avoid transaction stuff by checking MS_RDONLY at
>>>> 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.
>>
>
> 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.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-12-02 6:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 10:20 [RFC PATCH 2/4 v2] Btrfs: avoid transaction stuff when readonly liubo
2010-12-02 3:42 ` liubo
2010-12-02 4:28 ` Yan, Zheng
2010-12-02 5:38 ` liubo
2010-12-02 5:41 ` Mike Fedyk
2010-12-02 6:36 ` liubo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).