* [Ocfs2-devel] [PATCH] ocfs2: fix race between dio and recover orphan
@ 2015-06-26 5:52 Joseph Qi
2015-06-26 7:17 ` WeiWei Wang
0 siblings, 1 reply; 2+ messages in thread
From: Joseph Qi @ 2015-06-26 5:52 UTC (permalink / raw)
To: ocfs2-devel
During direct io the inode will be added to orphan first and then
deleted from orphan. There is a race window that the orphan entry will
be deleted twice and thus trigger the BUG when validating
OCFS2_DIO_ORPHANED_FL in ocfs2_del_inode_from_orphan.
ocfs2_direct_IO_write
...
ocfs2_add_inode_to_orphan
>>>>>>>> race window, another node may rm the file and then down,
this node take care of orphan recovery and clear flag
OCFS2_DIO_ORPHANED_FL
ocfs2_del_inode_from_orphan
Take inode mutex lock to fix this race case.
Reported-by: Yiwen Jiang <jiangyiwen@huawei.com>
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
---
fs/ocfs2/journal.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 8017032..f8206d1 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -2172,6 +2172,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
iter = oi->ip_next_orphan;
oi->ip_next_orphan = NULL;
+ mutex_lock(&inode->i_mutex);
ret = ocfs2_rw_lock(inode, 1);
if (ret < 0) {
mlog_errno(ret);
@@ -2218,6 +2219,7 @@ unlock_inode:
unlock_rw:
ocfs2_rw_unlock(inode, 1);
next:
+ mutex_unlock(&inode->i_mutex);
iput(inode);
brelse(di_bh);
di_bh = NULL;
--
1.8.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Ocfs2-devel] [PATCH] ocfs2: fix race between dio and recover orphan
2015-06-26 5:52 [Ocfs2-devel] [PATCH] ocfs2: fix race between dio and recover orphan Joseph Qi
@ 2015-06-26 7:17 ` WeiWei Wang
0 siblings, 0 replies; 2+ messages in thread
From: WeiWei Wang @ 2015-06-26 7:17 UTC (permalink / raw)
To: ocfs2-devel
On 2015/6/26 13:52, Joseph Qi wrote:
> During direct io the inode will be added to orphan first and then
> deleted from orphan. There is a race window that the orphan entry will
> be deleted twice and thus trigger the BUG when validating
> OCFS2_DIO_ORPHANED_FL in ocfs2_del_inode_from_orphan.
>
> ocfs2_direct_IO_write
> ...
> ocfs2_add_inode_to_orphan
> >>>>>>>> race window, another node may rm the file and then down,
> this node take care of orphan recovery and clear flag
> OCFS2_DIO_ORPHANED_FL
> ocfs2_del_inode_from_orphan
>
> Take inode mutex lock to fix this race case.
>
> Reported-by: Yiwen Jiang <jiangyiwen@huawei.com>
> Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Reviewed-by: Weiwei Wang <wangww631@huawei.com>
> ---
> fs/ocfs2/journal.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 8017032..f8206d1 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -2172,6 +2172,7 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
> iter = oi->ip_next_orphan;
> oi->ip_next_orphan = NULL;
>
> + mutex_lock(&inode->i_mutex);
> ret = ocfs2_rw_lock(inode, 1);
> if (ret < 0) {
> mlog_errno(ret);
> @@ -2218,6 +2219,7 @@ unlock_inode:
> unlock_rw:
> ocfs2_rw_unlock(inode, 1);
> next:
> + mutex_unlock(&inode->i_mutex);
> iput(inode);
> brelse(di_bh);
> di_bh = NULL;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-26 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-26 5:52 [Ocfs2-devel] [PATCH] ocfs2: fix race between dio and recover orphan Joseph Qi
2015-06-26 7:17 ` WeiWei Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.