]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
NFS: Add a helper to set attribute barriers
authorTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 26 Feb 2015 22:42:42 +0000 (17:42 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 2 Mar 2015 04:23:05 +0000 (23:23 -0500)
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Tested-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfs/inode.c
include/linux/nfs_fs.h

index 83107be3dd0109ab54c5f2b0c72fa59c64dd8d57..b0cbc1ba82dab8ed82b707133d03845a9f72ef19 100644 (file)
@@ -1260,6 +1260,22 @@ void nfs_fattr_init(struct nfs_fattr *fattr)
 }
 EXPORT_SYMBOL_GPL(nfs_fattr_init);
 
+/**
+ * nfs_fattr_set_barrier
+ * @fattr: attributes
+ *
+ * Used to set a barrier after an attribute was updated. This
+ * barrier ensures that older attributes from RPC calls that may
+ * have raced with our update cannot clobber these new values.
+ * Note that you are still responsible for ensuring that other
+ * operations which change the attribute on the server do not
+ * collide.
+ */
+void nfs_fattr_set_barrier(struct nfs_fattr *fattr)
+{
+       fattr->gencount = nfs_inc_attr_generation_counter();
+}
+
 struct nfs_fattr *nfs_alloc_fattr(void)
 {
        struct nfs_fattr *fattr;
index 2f77e0c651c89874a641c8a04a723aaf60dd2837..3a4ffb5856cd6a2cf298c4962411857ceb0c44ab 100644 (file)
@@ -369,6 +369,7 @@ extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ct
 extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
 extern u64 nfs_compat_user_ino64(u64 fileid);
 extern void nfs_fattr_init(struct nfs_fattr *fattr);
+extern void nfs_fattr_set_barrier(struct nfs_fattr *fattr);
 extern unsigned long nfs_inc_attr_generation_counter(void);
 
 extern struct nfs_fattr *nfs_alloc_fattr(void);