Skip to content

Commit d03360a

Browse files
trondmyamschuma-ntap
authored andcommitted
pNFS: Ensure we return the error if someone kills a waiting layoutget
If someone interrupts a wait on one or more outstanding layoutgets in pnfs_update_layout() then return the ERESTARTSYS/EINTR error. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 2a534a7 commit d03360a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

fs/nfs/pnfs.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,16 +1740,16 @@ static bool pnfs_within_mdsthreshold(struct nfs_open_context *ctx,
17401740
return ret;
17411741
}
17421742

1743-
static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo)
1743+
static int pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo)
17441744
{
17451745
/*
17461746
* send layoutcommit as it can hold up layoutreturn due to lseg
17471747
* reference
17481748
*/
17491749
pnfs_layoutcommit_inode(lo->plh_inode, false);
1750-
return !wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN,
1750+
return wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN,
17511751
nfs_wait_bit_killable,
1752-
TASK_UNINTERRUPTIBLE);
1752+
TASK_KILLABLE);
17531753
}
17541754

17551755
static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo)
@@ -1830,7 +1830,9 @@ pnfs_update_layout(struct inode *ino,
18301830
}
18311831

18321832
lookup_again:
1833-
nfs4_client_recover_expired_lease(clp);
1833+
lseg = ERR_PTR(nfs4_client_recover_expired_lease(clp));
1834+
if (IS_ERR(lseg))
1835+
goto out;
18341836
first = false;
18351837
spin_lock(&ino->i_lock);
18361838
lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
@@ -1863,9 +1865,9 @@ pnfs_update_layout(struct inode *ino,
18631865
if (list_empty(&lo->plh_segs) &&
18641866
atomic_read(&lo->plh_outstanding) != 0) {
18651867
spin_unlock(&ino->i_lock);
1866-
if (wait_var_event_killable(&lo->plh_outstanding,
1867-
atomic_read(&lo->plh_outstanding) == 0
1868-
|| !list_empty(&lo->plh_segs)))
1868+
lseg = ERR_PTR(wait_var_event_killable(&lo->plh_outstanding,
1869+
atomic_read(&lo->plh_outstanding)));
1870+
if (IS_ERR(lseg) || !list_empty(&lo->plh_segs))
18691871
goto out_put_layout_hdr;
18701872
pnfs_put_layout_hdr(lo);
18711873
goto lookup_again;
@@ -1898,8 +1900,11 @@ pnfs_update_layout(struct inode *ino,
18981900
if (test_and_set_bit(NFS_LAYOUT_FIRST_LAYOUTGET,
18991901
&lo->plh_flags)) {
19001902
spin_unlock(&ino->i_lock);
1901-
wait_on_bit(&lo->plh_flags, NFS_LAYOUT_FIRST_LAYOUTGET,
1902-
TASK_UNINTERRUPTIBLE);
1903+
lseg = ERR_PTR(wait_on_bit(&lo->plh_flags,
1904+
NFS_LAYOUT_FIRST_LAYOUTGET,
1905+
TASK_KILLABLE));
1906+
if (IS_ERR(lseg))
1907+
goto out_put_layout_hdr;
19031908
pnfs_put_layout_hdr(lo);
19041909
dprintk("%s retrying\n", __func__);
19051910
goto lookup_again;
@@ -1925,7 +1930,8 @@ pnfs_update_layout(struct inode *ino,
19251930
if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) {
19261931
spin_unlock(&ino->i_lock);
19271932
dprintk("%s wait for layoutreturn\n", __func__);
1928-
if (pnfs_prepare_to_retry_layoutget(lo)) {
1933+
lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));
1934+
if (!IS_ERR(lseg)) {
19291935
if (first)
19301936
pnfs_clear_first_layoutget(lo);
19311937
pnfs_put_layout_hdr(lo);

0 commit comments

Comments
 (0)