@@ -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/
@@ -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);
new file mode 100644
@@ -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)
+{
+}
@@ -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
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