diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2007-05-14 14:38:51 -0400 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2007-05-25 14:00:23 -0400 |
commit | e9dfc0b2bc42761410e8db6c252c6c5889e178b8 (patch) | |
tree | d42beb9d6b2c54bc205e48bc75cdf26ec0eeddc3 /fs/ocfs2 | |
parent | 1c1ee4c3e7e16d23166a624a132889df3c540a18 (diff) |
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: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/aops.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 8e7cafb5fc6c..30306707b2ca 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -222,7 +222,10 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
222 | goto out; | 222 | goto out; |
223 | } | 223 | } |
224 | 224 | ||
225 | down_read(&OCFS2_I(inode)->ip_alloc_sem); | 225 | if (down_read_trylock(&OCFS2_I(inode)->ip_alloc_sem) == 0) { |
226 | ret = AOP_TRUNCATED_PAGE; | ||
227 | goto out_meta_unlock; | ||
228 | } | ||
226 | 229 | ||
227 | /* | 230 | /* |
228 | * i_size might have just been updated as we grabed the meta lock. We | 231 | * 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 | ocfs2_data_unlock(inode, 0); | 261 | ocfs2_data_unlock(inode, 0); |
259 | out_alloc: | 262 | out_alloc: |
260 | up_read(&OCFS2_I(inode)->ip_alloc_sem); | 263 | up_read(&OCFS2_I(inode)->ip_alloc_sem); |
264 | out_meta_unlock: | ||
261 | ocfs2_meta_unlock(inode, 0); | 265 | ocfs2_meta_unlock(inode, 0); |
262 | out: | 266 | out: |
263 | if (unlock) | 267 | if (unlock) |