Merge tag 'afs-fixes-20171124' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowe...
[sfrench/cifs-2.6.git] / fs / nfs / delegation.c
index 606dd3871f66b0881c2760af3bbc3839748f9bc2..ade44ca0c66c391d7dd6472a7d42622307842a27 100644 (file)
@@ -1040,6 +1040,33 @@ int nfs_delegations_present(struct nfs_client *clp)
        return ret;
 }
 
+/**
+ * nfs4_refresh_delegation_stateid - Update delegation stateid seqid
+ * @dst: stateid to refresh
+ * @inode: inode to check
+ *
+ * Returns "true" and updates "dst->seqid" * if inode had a delegation
+ * that matches our delegation stateid. Otherwise "false" is returned.
+ */
+bool nfs4_refresh_delegation_stateid(nfs4_stateid *dst, struct inode *inode)
+{
+       struct nfs_delegation *delegation;
+       bool ret = false;
+       if (!inode)
+               goto out;
+
+       rcu_read_lock();
+       delegation = rcu_dereference(NFS_I(inode)->delegation);
+       if (delegation != NULL &&
+           nfs4_stateid_match_other(dst, &delegation->stateid)) {
+               dst->seqid = delegation->stateid.seqid;
+               return ret;
+       }
+       rcu_read_unlock();
+out:
+       return ret;
+}
+
 /**
  * nfs4_copy_delegation_stateid - Copy inode's state ID information
  * @inode: inode to check