Skip to content

Commit

Permalink
ocfs2: trylock in ocfs2_readpage()
Browse files Browse the repository at this point in the history
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: Mark Fasheh <mark.fasheh@oracle.com>
  • Loading branch information
Mark Fasheh committed May 25, 2007
1 parent 1c1ee4c commit e9dfc0b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ocfs2/aops.c
Expand Up @@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page)
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
Expand Down Expand Up @@ -258,6 +261,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
ocfs2_data_unlock(inode, 0);
out_alloc:
up_read(&OCFS2_I(inode)->ip_alloc_sem);
out_meta_unlock:
ocfs2_meta_unlock(inode, 0);
out:
if (unlock)
Expand Down

0 comments on commit e9dfc0b

Please sign in to comment.