NFSv4.1/pNFS: Add a helper to mark the layout as returned
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 28 Dec 2015 16:48:14 +0000 (11:48 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 28 Dec 2015 19:33:04 +0000 (14:33 -0500)
This ensures that we don't reuse the stateid if a layout return or
implied layout return means that we've returned all layout segments

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

index 807eb6ef4f91631264a140758e7e314ca4885771..716cbff244501d57c616931c2d0ac059db3d7394 100644 (file)
@@ -192,6 +192,7 @@ static u32 initiate_file_draining(struct nfs_client *clp,
                NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo,
                        &args->cbl_range);
        }
+       pnfs_mark_layout_returned_if_empty(lo);
 unlock:
        spin_unlock(&ino->i_lock);
        pnfs_free_lseg_list(&free_me_list);
index fcd7a9039020d87c0c1727a5c8d118b2ff8b1d08..883da29b9acec6b4852b3ea3b5cc11dc5ddb0bb7 100644 (file)
@@ -8049,9 +8049,10 @@ static void nfs4_layoutreturn_release(void *calldata)
 
        dprintk("--> %s\n", __func__);
        spin_lock(&lo->plh_inode->i_lock);
+       pnfs_mark_matching_lsegs_invalid(lo, &freeme, &lrp->args.range);
+       pnfs_mark_layout_returned_if_empty(lo);
        if (lrp->res.lrs_present)
                pnfs_set_layout_stateid(lo, &lrp->res.stateid, true);
-       pnfs_mark_matching_lsegs_invalid(lo, &freeme, &lrp->args.range);
        pnfs_clear_layoutreturn_waitbit(lo);
        lo->plh_block_lgets--;
        spin_unlock(&lo->plh_inode->i_lock);
index 6095a8d42766c14fde2e199351ad1975a9776042..b3fb6bb02275f1e53dcb3ccde80c45c4a381b2cd 100644 (file)
@@ -1149,6 +1149,7 @@ void pnfs_roc_set_barrier(struct inode *ino, u32 barrier)
 
        spin_lock(&ino->i_lock);
        lo = NFS_I(ino)->layout;
+       pnfs_mark_layout_returned_if_empty(lo);
        if (pnfs_seqid_is_newer(barrier, lo->plh_barrier))
                lo->plh_barrier = barrier;
        spin_unlock(&ino->i_lock);
index d1990e90e7a02cb048b909d67879198b26e62c08..be24a759b655989be973f79bd7a9157c9dc9d075 100644 (file)
@@ -556,6 +556,19 @@ pnfs_calc_offset_length(u64 offset, u64 end)
        return 1 + end - offset;
 }
 
+/**
+ * pnfs_mark_layout_returned_if_empty - marks the layout as returned
+ * @lo: layout header
+ *
+ * Note: Caller must hold inode->i_lock
+ */
+static inline void
+pnfs_mark_layout_returned_if_empty(struct pnfs_layout_hdr *lo)
+{
+       if (list_empty(&lo->plh_segs))
+               set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
+}
+
 extern unsigned int layoutstats_timer;
 
 #ifdef NFS_DEBUG