aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2016-05-17 12:28:41 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2016-05-17 15:48:10 -0400
commit3982a6a2d0e64441c938f4e7f93985aff37d8fb3 (patch)
tree6aae542c9fc32ef470004d42107f18b7bc808f6c
parent6675528380f8b7fffa82047211d8352dc6797321 (diff)
pnfs: keep track of the return sequence number in pnfs_layout_hdr
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>
-rw-r--r--fs/nfs/pnfs.c11
-rw-r--r--fs/nfs/pnfs.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c09ced88bd38..3ad6bd377d35 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -899,6 +899,7 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo)
899 if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags)) 899 if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
900 return false; 900 return false;
901 lo->plh_return_iomode = 0; 901 lo->plh_return_iomode = 0;
902 lo->plh_return_seq = 0;
902 pnfs_get_layout_hdr(lo); 903 pnfs_get_layout_hdr(lo);
903 clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); 904 clear_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
904 return true; 905 return true;
@@ -969,6 +970,7 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
969 bool send; 970 bool send;
970 971
971 nfs4_stateid_copy(&stateid, &lo->plh_stateid); 972 nfs4_stateid_copy(&stateid, &lo->plh_stateid);
973 stateid.seqid = cpu_to_be32(lo->plh_return_seq);
972 iomode = lo->plh_return_iomode; 974 iomode = lo->plh_return_iomode;
973 send = pnfs_prepare_layoutreturn(lo); 975 send = pnfs_prepare_layoutreturn(lo);
974 spin_unlock(&inode->i_lock); 976 spin_unlock(&inode->i_lock);
@@ -1747,7 +1749,8 @@ out_forget_reply:
1747} 1749}
1748 1750
1749static void 1751static void
1750pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode) 1752pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
1753 u32 seq)
1751{ 1754{
1752 if (lo->plh_return_iomode == iomode) 1755 if (lo->plh_return_iomode == iomode)
1753 return; 1756 return;
@@ -1755,6 +1758,8 @@ pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode)
1755 iomode = IOMODE_ANY; 1758 iomode = IOMODE_ANY;
1756 lo->plh_return_iomode = iomode; 1759 lo->plh_return_iomode = iomode;
1757 set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags); 1760 set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
1761 if (!lo->plh_return_seq || pnfs_seqid_is_newer(seq, lo->plh_return_seq))
1762 lo->plh_return_seq = seq;
1758} 1763}
1759 1764
1760/** 1765/**
@@ -1793,7 +1798,7 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
1793 continue; 1798 continue;
1794 remaining++; 1799 remaining++;
1795 set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags); 1800 set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
1796 pnfs_set_plh_return_iomode(lo, return_range->iomode); 1801 pnfs_set_plh_return_info(lo, return_range->iomode, lseg->pls_seq);
1797 } 1802 }
1798 return remaining; 1803 return remaining;
1799} 1804}
@@ -1811,7 +1816,7 @@ void pnfs_error_mark_layout_for_return(struct inode *inode,
1811 bool return_now = false; 1816 bool return_now = false;
1812 1817
1813 spin_lock(&inode->i_lock); 1818 spin_lock(&inode->i_lock);
1814 pnfs_set_plh_return_iomode(lo, range.iomode); 1819 pnfs_set_plh_return_info(lo, range.iomode, lseg->pls_seq);
1815 /* 1820 /*
1816 * mark all matching lsegs so that we are sure to have no live 1821 * mark all matching lsegs so that we are sure to have no live
1817 * segments at hand when sending layoutreturn. See pnfs_put_lseg() 1822 * segments at hand when sending layoutreturn. See pnfs_put_lseg()
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 361fa5494aa5..3476c9850678 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -195,6 +195,7 @@ struct pnfs_layout_hdr {
195 unsigned long plh_flags; 195 unsigned long plh_flags;
196 nfs4_stateid plh_stateid; 196 nfs4_stateid plh_stateid;
197 u32 plh_barrier; /* ignore lower seqids */ 197 u32 plh_barrier; /* ignore lower seqids */
198 u32 plh_return_seq;
198 enum pnfs_iomode plh_return_iomode; 199 enum pnfs_iomode plh_return_iomode;
199 loff_t plh_lwb; /* last write byte for layoutcommit */ 200 loff_t plh_lwb; /* last write byte for layoutcommit */
200 struct rpc_cred *plh_lc_cred; /* layoutcommit cred */ 201 struct rpc_cred *plh_lc_cred; /* layoutcommit cred */