Skip to content

Commit

Permalink
pNFS: pnfs_roc_drain should return 'true' when sleeping
Browse files Browse the repository at this point in the history
Also clean up the case where we don't find a return-on-close layout segment.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Trond Myklebust committed Jul 11, 2015
1 parent c5d7371 commit df9cecc
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions fs/nfs/pnfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,14 +1146,14 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task)
struct pnfs_layout_segment *lseg;
nfs4_stateid stateid;
u32 current_seqid;
bool found = false, layoutreturn = false;
bool layoutreturn = false;

spin_lock(&ino->i_lock);
list_for_each_entry(lseg, &nfsi->layout->plh_segs, pls_list)
if (test_bit(NFS_LSEG_ROC, &lseg->pls_flags)) {
rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
found = true;
goto out;
spin_unlock(&ino->i_lock);
return true;
}
lo = nfsi->layout;
current_seqid = be32_to_cpu(lo->plh_stateid.seqid);
Expand All @@ -1162,23 +1162,21 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task)
* a barrier, we choose the worst-case barrier.
*/
*barrier = current_seqid + atomic_read(&lo->plh_outstanding);
out:
if (!found) {
stateid = lo->plh_stateid;
layoutreturn =
test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
stateid = lo->plh_stateid;
layoutreturn = test_and_clear_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
&lo->plh_flags);
if (layoutreturn) {
lo->plh_block_lgets++;
pnfs_get_layout_hdr(lo);
}
if (layoutreturn) {
lo->plh_block_lgets++;
pnfs_get_layout_hdr(lo);
}

spin_unlock(&ino->i_lock);
if (layoutreturn) {
rpc_sleep_on(&NFS_SERVER(ino)->roc_rpcwaitq, task, NULL);
pnfs_send_layoutreturn(lo, stateid, IOMODE_ANY, false);
return true;
}
return found;
return false;
}

/*
Expand Down

0 comments on commit df9cecc

Please sign in to comment.