From d4b624c219fd5b22411ec03f75fb0b7c62269f32 Mon Sep 17 00:00:00 2001 From: Andy Adamson Date: Wed, 20 Jun 2012 15:03:33 -0400 Subject: [PATCH] --- yaml --- r: 320215 b: refs/heads/master c: 366d50521c57939e61e25dc27f009367447563e6 h: refs/heads/master i: 320213: f76a82f51e39c817d7c84fd7197bafe6ce47b7e6 320211: bb9bfb2f60f6e0ca8995fc5a5c99c88d6b04eb0a 320207: 80424419d3d06b6b2a8bd49a9e9fb55b6317f241 v: v3 --- [refs] | 2 +- trunk/fs/nfs/pnfs.c | 10 ++++++++-- trunk/fs/nfs/pnfs.h | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 82e3560dd573..9e3e45e690af 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: baf6c2a44af02cf6f7cec1ff177189c78fc30f9a +refs/heads/master: 366d50521c57939e61e25dc27f009367447563e6 diff --git a/trunk/fs/nfs/pnfs.c b/trunk/fs/nfs/pnfs.c index 2617831afd39..3ad768f2cef4 100644 --- a/trunk/fs/nfs/pnfs.c +++ b/trunk/fs/nfs/pnfs.c @@ -662,11 +662,11 @@ _pnfs_return_layout(struct inode *ino) nfs4_stateid stateid; int status = 0; - dprintk("--> %s\n", __func__); + dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino); spin_lock(&ino->i_lock); lo = nfsi->layout; - if (!lo) { + if (!lo || pnfs_test_layout_returned(lo)) { spin_unlock(&ino->i_lock); dprintk("%s: no layout to return\n", __func__); return status; @@ -676,6 +676,7 @@ _pnfs_return_layout(struct inode *ino) get_layout_hdr(lo); mark_matching_lsegs_invalid(lo, &tmp_list, NULL); lo->plh_block_lgets++; + pnfs_mark_layout_returned(lo); spin_unlock(&ino->i_lock); pnfs_free_lseg_list(&tmp_list); @@ -686,6 +687,7 @@ _pnfs_return_layout(struct inode *ino) status = -ENOMEM; set_bit(NFS_LAYOUT_RW_FAILED, &lo->plh_flags); set_bit(NFS_LAYOUT_RO_FAILED, &lo->plh_flags); + pnfs_clear_layout_returned(lo); put_layout_hdr(lo); goto out; } @@ -1075,6 +1077,10 @@ pnfs_update_layout(struct inode *ino, get_layout_hdr(lo); if (list_empty(&lo->plh_segs)) first = true; + + /* Enable LAYOUTRETURNs */ + pnfs_clear_layout_returned(lo); + spin_unlock(&ino->i_lock); if (first) { /* The lo must be on the clp list if there is any diff --git a/trunk/fs/nfs/pnfs.h b/trunk/fs/nfs/pnfs.h index 592beb02c955..2c6c80503ba4 100644 --- a/trunk/fs/nfs/pnfs.h +++ b/trunk/fs/nfs/pnfs.h @@ -64,6 +64,7 @@ enum { NFS_LAYOUT_ROC, /* some lseg had roc bit set */ NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */ NFS_LAYOUT_INVALID, /* layout is being destroyed */ + NFS_LAYOUT_RETURNED, /* layout has already been returned */ }; enum layoutdriver_policy_flags { @@ -255,6 +256,24 @@ struct nfs4_deviceid_node *nfs4_insert_deviceid_node(struct nfs4_deviceid_node * bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *); void nfs4_deviceid_purge_client(const struct nfs_client *); +static inline void +pnfs_mark_layout_returned(struct pnfs_layout_hdr *lo) +{ + set_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); +} + +static inline void +pnfs_clear_layout_returned(struct pnfs_layout_hdr *lo) +{ + clear_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); +} + +static inline bool +pnfs_test_layout_returned(struct pnfs_layout_hdr *lo) +{ + return test_bit(NFS_LAYOUT_RETURNED, &lo->plh_flags); +} + static inline int lo_fail_bit(u32 iomode) { return iomode == IOMODE_RW ?