Skip to contentSkip to conversation

rpdfs: Initial extended attribute support

PATCH Applied Chris Kirby 2 participants 2 messages Mar 4

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rpdfs: Initial extended attribute support

Initial extended attribute support

This change adds get, set, and remove support for user extended attributes. The XATTR_CREATE and XATTR_REPLACE flags are supported for setxattr.

Add the xattr_creates counter to the rpdfs inode. This is incremented on each xattr create or replace operation and is used as the lsq of the xattr key so that we don't need to worry about collisions on the name hash.

---
 fs/rpdfs/Makefile       |   3 +-
 fs/rpdfs/format-block.h |   3 +
 fs/rpdfs/inode.c        |   7 +
 fs/rpdfs/inode.h        |   4 +
 fs/rpdfs/super.c        |   3 +-
 fs/rpdfs/xattr.c        | 411 ++++++++++++++++++++++++++++++++++++++++
 fs/rpdfs/xattr.h        |   7 +
 7 files changed, 436 insertions(+), 2 deletions(-)
 create mode 100644 fs/rpdfs/xattr.c
 create mode 100644 fs/rpdfs/xattr.h
fs/rpdfs/Makefile +2 -1
index 4241adacf8c0..1466cdf49632 100644
@@ -16,4 +16,5 @@ rpdfs-y	:= balloc.o \
 	   parse.o \
 	   rht.o \
 	   super.o \
-	   txn.o
+	   txn.o \
+	   xattr.o
fs/rpdfs/format-block.h +3 -0
index a5e9dd9ebe12..1ff315668d2f 100644
@@ -224,6 +224,9 @@ struct rpdfs_xattr {
 	};
 };
 
+/* max xattr name length, without null term */
+#define	RPDFS_XATTR_MAX_NAME_LEN	RPDFS_NAME_MAX
+
 /*
  * Maximum size of the xattr struct plus non-null-terminated xattr
  * name/value (see xattr_size()).
fs/rpdfs/inode.c +7 -0
index 3f9a8e9d993f..2d83fa6352be 100644
@@ -73,6 +73,9 @@ static void copy_rinode_to_vfs_inode(struct inode *inode, struct rpdfs_inode *ri
 	inode_set_mtime_to_ts(inode, ns_to_timespec64(le64_to_cpu(rinode->mtime_nsec)));
 
 	ri->dirents = rinode->dirents;
+
+	ri->xattrs = rinode->xattrs;
+	ri->xattr_creates = rinode->xattr_creates;
 }
 
 static __le64 cpu_ts64_to_le64_ns(struct timespec64 ts)
@@ -96,6 +99,9 @@ static void copy_vfs_inode_to_rinode(struct rpdfs_inode *rinode, struct inode *i
 	rinode->mtime_nsec = cpu_ts64_to_le64_ns(inode_get_mtime(inode));
 
 	rinode->dirents = ri->dirents;
+
+	rinode->xattrs = ri->xattrs;
+	rinode->xattr_creates = ri->xattr_creates;
 }
 
 /*
@@ -286,6 +292,7 @@ struct inode *rpdfs_new_inode(struct super_block *sb, struct rpdfs_ino_gen *ig)
 
 	ri = RPDFS_I(inode);
 	ri->refresh_wcount = 0;
+	ri->xattr_creates = 0;
 	ri->ig = *ig;
 	inode->i_ino = le64_to_cpu(ri->ig.ino);
 
fs/rpdfs/inode.h +4 -0
index a57017a4fca0..6b0fddb7f0fb 100644
@@ -15,8 +15,12 @@ struct rpdfs_inode_info {
 	seqlock_t refresh_seqlock;
 	u64 refresh_wcount;
 
+	/* Uniquifier to avoid xattr name hash collisions */
+	__le64 xattr_creates;
+
 	struct rpdfs_ino_gen ig;
 	struct rpdfs_btree_root dirents;
+	struct rpdfs_btree_root xattrs;
 
 	struct inode vfs_inode;
 };
fs/rpdfs/super.c +2 -1
index 9b18c25175b7..6a036d07cb30 100644
@@ -17,6 +17,7 @@
 #include "net_tcp.h"
 #include "parse.h"
 #include "pr.h"
+#include "xattr.h"
 
 struct rpdfs_fs_context {
 	struct rpdfs_net_transport_addr source_addr;
@@ -42,7 +43,7 @@ static const struct super_operations rpdfs_sop = {
 static int rpdfs_set_super(struct super_block *sb, struct fs_context *fc)
 {
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
-	sb->s_xattr = NULL;
+	sb->s_xattr = rpdfs_xattr_handlers;
 	sb->s_op = &rpdfs_sop;
 	sb->s_time_gran = 1;
 	sb->s_time_min = 0;
fs/rpdfs/xattr.c new file +411 -0

411 lines not on this page · raw message

fs/rpdfs/xattr.h new file +7 -0
new file mode 100644
index 000000000000..d185f4ccf532
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef RPDFS_XATTR_H
+#define RPDFS_XATTR_H
+
+extern const struct xattr_handler * const rpdfs_xattr_handlers[];
+
+#endif
Signature · 1 line
2.53.0
Applied
#1 lore raw
Quoted 1 line · Chris Kirby

Initial extended attribute support

Applied, thanks!

- z