diff mbox series

[RFC,18/35] NFSv4.2: add client side xattr caching functions

Message ID 69bcfd7de0c47fb0fd45788394ffa52478a63bdc.1568309119.git.fllinden@amazon.com (mailing list archive)
State New, archived
Headers show
Series user xattr support (RFC8276) | expand

Commit Message

Frank van der Linden Aug. 30, 2019, 11:38 p.m. UTC
Implement client side caching for NFSv4.2 extended attributes.

[note: this currently does nothing]

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 fs/nfs/Makefile             |  1 +
 fs/nfs/internal.h           | 16 +++++++++
 fs/nfs/nfs42xattr.c         | 72 +++++++++++++++++++++++++++++++++++++
 include/uapi/linux/nfs_fs.h |  1 +
 4 files changed, 90 insertions(+)
 create mode 100644 fs/nfs/nfs42xattr.c
diff mbox series

Patch

diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 34cdeaecccf6..0917598db270 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -31,6 +31,7 @@  nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o
 nfsv4-$(CONFIG_SYSCTL)	+= nfs4sysctl.o
 nfsv4-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o pnfs_nfs.o
 nfsv4-$(CONFIG_NFS_V4_2)	+= nfs42proc.o
+nfsv4-$(CONFIG_NFS_V4_XATTR)	+= nfs42xattr.o
 
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += filelayout/
 obj-$(CONFIG_PNFS_BLOCK) += blocklayout/
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 75645d9ff10b..558b9c8ddfbf 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -583,6 +583,22 @@  extern void nfs4_test_session_trunk(struct rpc_clnt *clnt,
 				struct rpc_xprt *xprt,
 				void *data);
 
+#ifdef CONFIG_NFS_V4_XATTR
+extern void nfs4_xattr_cache_add(struct inode *, const char *name,
+				 const char *buf, ssize_t buflen);
+extern void nfs4_xattr_cache_remove(struct inode *, const char *name);
+extern ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name,
+				char *buf, ssize_t buflen);
+extern void nfs4_xattr_cache_set_list(struct inode *, const char *buf,
+				      ssize_t buflen);
+extern ssize_t nfs4_xattr_cache_list(struct inode *, char *buf, ssize_t buflen);
+extern void nfs4_xattr_cache_zap(struct inode *);
+#else
+static inline void nfs4_xattr_cache_zap(struct inode *)
+{
+}
+#endif
+
 static inline struct inode *nfs_igrab_and_active(struct inode *inode)
 {
 	inode = igrab(inode);
diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c
new file mode 100644
index 000000000000..40c190cfaa75
--- /dev/null
+++ b/fs/nfs/nfs42xattr.c
@@ -0,0 +1,72 @@ 
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright 2019 Amazon.com, Inc. or its affiliates. All rights reserved.
+ *
+ * User extended attribute client side cache functions.
+ *
+ * Author: Frank van der Linden <fllinden@amazon.com>
+ */
+
+#include <linux/errno.h>
+#include <linux/nfs_fs.h>
+
+#include "nfs4_fs.h"
+#include "internal.h"
+
+#define NFSDBG_FACILITY         NFSDBG_XATTRCACHE
+
+
+/*
+ * Retrieve an xattr from the cache.
+ */
+ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name, char *buf,
+			 ssize_t buflen)
+{
+	return -ENOENT;
+}
+
+/*
+ * Retrieve a cached list of xattrs from the cache.
+ */
+ssize_t nfs4_xattr_cache_list(struct inode *inode, char *buf, ssize_t buflen)
+{
+	return -ENOENT;
+}
+
+/*
+ * Add an xattr to the cache.
+ *
+ * This also invalidates the xattr list cache.
+ */
+void nfs4_xattr_cache_add(struct inode *inode, const char *name,
+			  const char *buf, ssize_t buflen)
+{
+}
+
+
+/*
+ * Remove an xattr to the cache.
+ *
+ * This also invalidates the xattr list cache.
+ */
+void nfs4_xattr_cache_remove(struct inode *inode, const char *name)
+{
+}
+
+/*
+ * Cache listxattr output, replacing any possible old one.
+ *
+ * Should validate existing cache entries.
+ */
+void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
+			       ssize_t buflen)
+{
+}
+
+/*
+ * Zap the entire cache.
+ */
+void nfs4_xattr_cache_zap(struct inode *inode)
+{
+}
diff --git a/include/uapi/linux/nfs_fs.h b/include/uapi/linux/nfs_fs.h
index 7bcc8cd6831d..3afe3767c55d 100644
--- a/include/uapi/linux/nfs_fs.h
+++ b/include/uapi/linux/nfs_fs.h
@@ -56,6 +56,7 @@ 
 #define NFSDBG_PNFS		0x1000
 #define NFSDBG_PNFS_LD		0x2000
 #define NFSDBG_STATE		0x4000
+#define NFSDBG_XATTRCACHE	0x8000
 #define NFSDBG_ALL		0xFFFF