]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
pNFS: Fix a deadlock when coalescing writes and returning the layout
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 1 May 2017 21:06:56 +0000 (17:06 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 2 May 2017 16:35:33 +0000 (12:35 -0400)
Consider the following deadlock:

Process P1 Process P2 Process P3
========== ========== ==========
lock_page(page)

lseg = pnfs_update_layout(inode)

lo = NFS_I(inode)->layout
pnfs_error_mark_layout_for_return(lo)

lock_page(page)

lseg = pnfs_update_layout(inode)

In this scenario,
- P1 has declared the layout to be in error, but P2 holds a reference to
  a layout segment on that inode, so the layoutreturn is deferred.
- P2 is waiting for a page lock held by P3.
- P3 is asking for a new layout segment, but is blocked waiting
  for the layoutreturn.

The fix is to ensure that pnfs_error_mark_layout_for_return() does
not set the NFS_LAYOUT_RETURN flag, which blocks P3. Instead, we allow
the latter to call LAYOUTGET so that it can make progress and unblock
P2.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/pnfs.c

index cea1e838efae8f9a163b47d3a70b4059f60eb4a4..adc6ec28d4b59d3181c76ca8f33a9fed25d68ce9 100644 (file)
@@ -2063,8 +2063,6 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,
                return;
        }
        pnfs_set_plh_return_info(lo, range.iomode, 0);
-       /* Block LAYOUTGET */
-       set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
        /*
         * mark all matching lsegs so that we are sure to have no live
         * segments at hand when sending layoutreturn. See pnfs_put_lseg()