]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ocfs2: trylock in ocfs2_readpage()
authorMark Fasheh <mark.fasheh@oracle.com>
Mon, 14 May 2007 18:38:51 +0000 (11:38 -0700)
committerMark Fasheh <mark.fasheh@oracle.com>
Fri, 25 May 2007 18:00:23 +0000 (11:00 -0700)
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>
fs/ocfs2/aops.c

index 8e7cafb5fc6c638cded86d0a04c369f62daa5b25..30306707b2caee141f39b69fb7decaf7d37f3045 100644 (file)
@@ -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
@@ -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)