Commit e9dfc0b2 authored by Mark Fasheh's avatar Mark Fasheh

ocfs2: trylock in ocfs2_readpage()

Similarly to the page lock / cluster lock inversion in ocfs2_readpage, we
can deadlock on ip_alloc_sem. We can down_read_trylock() instead and just
return AOP_TRUNCATED_PAGE if the operation fails.
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 1c1ee4c3
...@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page) ...@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page)
goto out; goto out;
} }
down_read(&OCFS2_I(inode)->ip_alloc_sem); if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) {
ret = AOP_TRUNCATED_PAGE;
goto out_meta_unlock;
}
/* /*
* i_size might have just been updated as we grabed the meta lock. We * i_size might have just been updated as we grabed the meta lock. We
...@@ -258,6 +261,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) ...@@ -258,6 +261,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
ocfs2_data_unlock(inode, 0); ocfs2_data_unlock(inode, 0);
out_alloc: out_alloc:
up_read(&OCFS2_I(inode)->ip_alloc_sem); up_read(&OCFS2_I(inode)->ip_alloc_sem);
out_meta_unlock:
ocfs2_meta_unlock(inode, 0); ocfs2_meta_unlock(inode, 0);
out: out:
if (unlock) if (unlock)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment