diff options
author | Joseph Qi <joseph.qi@huawei.com> | 2015-06-24 19:54:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-06-24 20:49:39 -0400 |
commit | cf1776a9e834400ed8e2fea48ffa6daa9da28446 (patch) | |
tree | b1612f8a870a1305cf32cc339119a68635091e6e /fs/ocfs2/aops.c | |
parent | e327284abb8aee3206cef3b790a283fea213a174 (diff) |
ocfs2: fix a tiny race when truncate dio orohaned entry
Once dio crashed it will leave an entry in orphan dir. And orphan scan
will take care of the clean up. There is a tiny race case that the same
entry will be truncated twice and then trigger the BUG in
ocfs2_del_inode_from_orphan.
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index f906a250da6a..395f4b356baa 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -925,13 +925,23 @@ clean_orphan: | |||
925 | int update_isize = written > 0 ? 1 : 0; | 925 | int update_isize = written > 0 ? 1 : 0; |
926 | loff_t end = update_isize ? offset + written : 0; | 926 | loff_t end = update_isize ? offset + written : 0; |
927 | 927 | ||
928 | tmp_ret = ocfs2_del_inode_from_orphan(osb, inode, | 928 | tmp_ret = ocfs2_inode_lock(inode, &di_bh, 1); |
929 | if (tmp_ret < 0) { | ||
930 | ret = tmp_ret; | ||
931 | mlog_errno(ret); | ||
932 | goto out; | ||
933 | } | ||
934 | |||
935 | tmp_ret = ocfs2_del_inode_from_orphan(osb, inode, di_bh, | ||
929 | update_isize, end); | 936 | update_isize, end); |
930 | if (tmp_ret < 0) { | 937 | if (tmp_ret < 0) { |
931 | ret = tmp_ret; | 938 | ret = tmp_ret; |
939 | mlog_errno(ret); | ||
932 | goto out; | 940 | goto out; |
933 | } | 941 | } |
934 | 942 | ||
943 | ocfs2_inode_unlock(inode, 1); | ||
944 | |||
935 | tmp_ret = jbd2_journal_force_commit(journal); | 945 | tmp_ret = jbd2_journal_force_commit(journal); |
936 | if (tmp_ret < 0) { | 946 | if (tmp_ret < 0) { |
937 | ret = tmp_ret; | 947 | ret = tmp_ret; |