]> git.karo-electronics.de Git - linux-beck.git/commitdiff
pnfs: keep track of the return sequence number in pnfs_layout_hdr
authorJeff Layton <jlayton@poochiereds.net>
Tue, 17 May 2016 16:28:41 +0000 (12:28 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Tue, 17 May 2016 19:48:10 +0000 (15:48 -0400)
When we want to selectively do a LAYOUTRETURN, we need to specify a
stateid that represents most recent layout acquisition that is to be
returned.

When we mark a layout stateid to be returned, we update the return
sequence number in the layout header with that value, if it's newer
than the existing one. Then, when we go to do a LAYOUTRETURN on
layout header put, we overwrite the seqid in the stateid with the
saved one, and then zero it out.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/pnfs.c
fs/nfs/pnfs.h

index c09ced88bd388867e2b4b31fca4297ea4a96833d..3ad6bd377d35e4f3264b55487d777e13dad6783c 100644 (file)
@@ -899,6 +899,7 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo)
        if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
                return false;
        lo->plh_return_iomode = 0;
+       lo->plh_return_seq = 0;
        pnfs_get_layout_hdr(lo);
        clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
        return true;
@@ -969,6 +970,7 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
                bool send;
 
                nfs4_stateid_copy(&stateid, &lo->plh_stateid);
+               stateid.seqid = cpu_to_be32(lo->plh_return_seq);
                iomode = lo->plh_return_iomode;
                send = pnfs_prepare_layoutreturn(lo);
                spin_unlock(&inode->i_lock);
@@ -1747,7 +1749,8 @@ out_forget_reply:
 }
 
 static void
-pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode)
+pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
+                        u32 seq)
 {
        if (lo->plh_return_iomode == iomode)
                return;
@@ -1755,6 +1758,8 @@ pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode)
                iomode = IOMODE_ANY;
        lo->plh_return_iomode = iomode;
        set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
+       if (!lo->plh_return_seq || pnfs_seqid_is_newer(seq, lo->plh_return_seq))
+               lo->plh_return_seq = seq;
 }
 
 /**
@@ -1793,7 +1798,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
                                continue;
                        remaining++;
                        set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
-                       pnfs_set_plh_return_iomode(lo, return_range->iomode);
+                       pnfs_set_plh_return_info(lo, return_range->iomode, lseg->pls_seq);
                }
        return remaining;
 }
@@ -1811,7 +1816,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,
        bool return_now = false;
 
        spin_lock(&inode->i_lock);
-       pnfs_set_plh_return_iomode(lo, range.iomode);
+       pnfs_set_plh_return_info(lo, range.iomode, lseg->pls_seq);
        /*
         * mark all matching lsegs so that we are sure to have no live
         * segments at hand when sending layoutreturn. See pnfs_put_lseg()
index 361fa5494aa5d2d4b662d944a860ebb54b7ffa71..3476c98506783674738cf658d77e94615e8c08c3 100644 (file)
@@ -195,6 +195,7 @@ struct pnfs_layout_hdr {
        unsigned long           plh_flags;
        nfs4_stateid            plh_stateid;
        u32                     plh_barrier; /* ignore lower seqids */
+       u32                     plh_return_seq;
        enum pnfs_iomode        plh_return_iomode;
        loff_t                  plh_lwb; /* last write byte for layoutcommit */
        struct rpc_cred         *plh_lc_cred; /* layoutcommit cred */