aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2012-06-20 15:03:33 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-07-16 14:37:25 -0400
commit366d50521c57939e61e25dc27f009367447563e6 (patch)
treed69e02a6fad26e4d746710a7b8dd2caa0047efed
parentbaf6c2a44af02cf6f7cec1ff177189c78fc30f9a (diff)
NFSv4.1 mark layout when already returned
When the file layout driver is fencing a DS, _pnfs_return_layout can be called mulitple times per inode due to in-flight i/o referencing lsegs on it's plh_segs list. Remember that LAYOUTRETURN has been called, and do not call it again. Allow LAYOUTRETURNs after a subsequent LAYOUTGET. Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/pnfs.c10
-rw-r--r--fs/nfs/pnfs.h19
2 files changed, 27 insertions, 2 deletions
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 2617831afd39..3ad768f2cef4 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -662,11 +662,11 @@ _pnfs_return_layout(struct inode *ino)
662 nfs4_stateid stateid; 662 nfs4_stateid stateid;
663 int status = 0; 663 int status = 0;
664 664
665 dprintk("--> %s\n", __func__); 665 dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino);
666 666
667 spin_lock(&ino->i_lock); 667 spin_lock(&ino->i_lock);
668 lo = nfsi->layout; 668 lo = nfsi->layout;
669 if (!lo) { 669 if (!lo || pnfs_test_layout_returned(lo)) {
670 spin_unlock(&ino->i_lock); 670 spin_unlock(&ino->i_lock);
671 dprintk("%s: no layout to return\n", __func__); 671 dprintk("%s: no layout to return\n", __func__);
672 return status; 672 return status;
@@ -676,6 +676,7 @@ _pnfs_return_layout(struct inode *ino)
676 get_layout_hdr(lo); 676 get_layout_hdr(lo);
677 mark_matching_lsegs_invalid(lo, &tmp_list, NULL); 677 mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
678 lo->plh_block_lgets++; 678 lo->plh_block_lgets++;
679 pnfs_mark_layout_returned(lo);
679 spin_unlock(&ino->i_lock); 680 spin_unlock(&ino->i_lock);
680 pnfs_free_lseg_list(&tmp_list); 681 pnfs_free_lseg_list(&tmp_list);
681 682
@@ -686,6 +687,7 @@ _pnfs_return_layout(struct inode *ino)
686 status = -ENOMEM; 687 status = -ENOMEM;
687 set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); 688 set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags);
688 set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); 689 set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags);
690 pnfs_clear_layout_returned(lo);
689 put_layout_hdr(lo); 691 put_layout_hdr(lo);
690 goto out; 692 goto out;
691 } 693 }
@@ -1075,6 +1077,10 @@ pnfs_update_layout(struct inode *ino,
1075 get_layout_hdr(lo); 1077 get_layout_hdr(lo);
1076 if (list_empty(&lo->plh_segs)) 1078 if (list_empty(&lo->plh_segs))
1077 first = true; 1079 first = true;
1080
1081 /* Enable LAYOUTRETURNs */
1082 pnfs_clear_layout_returned(lo);
1083
1078 spin_unlock(&ino->i_lock); 1084 spin_unlock(&ino->i_lock);
1079 if (first) { 1085 if (first) {
1080 /* The lo must be on the clp list if there is any 1086 /* The lo must be on the clp list if there is any
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 592beb02c955..2c6c80503ba4 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -64,6 +64,7 @@ enum {
64 NFS_LAYOUT_ROC, /* some lseg had roc bit set */ 64 NFS_LAYOUT_ROC, /* some lseg had roc bit set */
65 NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */ 65 NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */
66 NFS_LAYOUT_INVALID, /* layout is being destroyed */ 66 NFS_LAYOUT_INVALID, /* layout is being destroyed */
67 NFS_LAYOUT_RETURNED, /* layout has already been returned */
67}; 68};
68 69
69enum layoutdriver_policy_flags { 70enum layoutdriver_policy_flags {
@@ -255,6 +256,24 @@ struct nfs4_deviceid_node *nfs4_insert_deviceid_node(struct nfs4_deviceid_node *
255bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *); 256bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *);
256void nfs4_deviceid_purge_client(const struct nfs_client *); 257void nfs4_deviceid_purge_client(const struct nfs_client *);
257 258
259static inline void
260pnfs_mark_layout_returned(struct pnfs_layout_hdr *lo)
261{
262 set_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags);
263}
264
265static inline void
266pnfs_clear_layout_returned(struct pnfs_layout_hdr *lo)
267{
268 clear_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags);
269}
270
271static inline bool
272pnfs_test_layout_returned(struct pnfs_layout_hdr *lo)
273{
274 return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags);
275}
276
258static inline int lo_fail_bit(u32 iomode) 277static inline int lo_fail_bit(u32 iomode)
259{ 278{
260 return iomode == IOMODE_RW ? 279 return iomode == IOMODE_RW ?