mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-19 14:34:16 +00:00
scoutfs-utils: update format for xattr cleanups
xattr items are now stored at the hash of the name and have a header in the first part. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
+19
-15
@@ -362,22 +362,24 @@ struct scoutfs_orphan_key {
|
||||
__be64 ino;
|
||||
} __packed;
|
||||
|
||||
/* value is each item's part of the full xattr value for the off/len */
|
||||
struct scoutfs_xattr_key {
|
||||
__u8 zone;
|
||||
__be64 ino;
|
||||
__u8 type;
|
||||
__u8 name[0];
|
||||
} __packed;
|
||||
|
||||
struct scoutfs_xattr_key_footer {
|
||||
__u8 null;
|
||||
__be32 name_hash;
|
||||
__be64 id;
|
||||
__u8 part;
|
||||
} __packed;
|
||||
|
||||
struct scoutfs_xattr_val_header {
|
||||
__le16 part_len;
|
||||
__u8 last_part;
|
||||
/*
|
||||
* The first xattr part item has a header that describes the xattr. The
|
||||
* name and value are then packed into the following bytes in the first
|
||||
* part item and overflow into the values of the rest of the part items.
|
||||
*/
|
||||
struct scoutfs_xattr {
|
||||
__u8 name_len;
|
||||
__le16 val_len;
|
||||
__u8 name[0];
|
||||
} __packed;
|
||||
|
||||
/* size determines nr needed to store full target path in their values */
|
||||
@@ -472,6 +474,7 @@ struct scoutfs_inode {
|
||||
__le64 online_blocks;
|
||||
__le64 offline_blocks;
|
||||
__le64 next_readdir_pos;
|
||||
__le64 next_xattr_id;
|
||||
__le32 nlink;
|
||||
__le32 uid;
|
||||
__le32 gid;
|
||||
@@ -529,12 +532,13 @@ enum {
|
||||
|
||||
#define SCOUTFS_MAX_VAL_SIZE SCOUTFS_BLOCK_MAPPING_MAX_BYTES
|
||||
|
||||
#define SCOUTFS_XATTR_MAX_NAME_LEN 255
|
||||
#define SCOUTFS_XATTR_MAX_SIZE 65536
|
||||
#define SCOUTFS_XATTR_PART_SIZE \
|
||||
(SCOUTFS_MAX_VAL_SIZE - sizeof(struct scoutfs_xattr_val_header))
|
||||
#define SCOUTFS_XATTR_MAX_PARTS \
|
||||
DIV_ROUND_UP(SCOUTFS_XATTR_MAX_SIZE, SCOUTFS_XATTR_PART_SIZE)
|
||||
#define SCOUTFS_XATTR_MAX_NAME_LEN 255
|
||||
#define SCOUTFS_XATTR_MAX_VAL_LEN 65535
|
||||
#define SCOUTFS_XATTR_MAX_PART_SIZE 512U
|
||||
|
||||
#define SCOUTFS_XATTR_NR_PARTS(name_len, val_len) \
|
||||
DIV_ROUND_UP(sizeof(struct scoutfs_xattr) + name_len + val_len, \
|
||||
SCOUTFS_XATTR_MAX_PART_SIZE);
|
||||
|
||||
/*
|
||||
* structures used by dlm
|
||||
|
||||
+4
-4
@@ -236,13 +236,13 @@ static int pr_inode(char *buf, struct scoutfs_key_buf *key, size_t size)
|
||||
static int pr_xattr(char *buf, struct scoutfs_key_buf *key, size_t size)
|
||||
{
|
||||
struct scoutfs_xattr_key *xkey = key->data;
|
||||
int len = (int)key->key_len -
|
||||
offsetof(struct scoutfs_xattr_key, name[1]);
|
||||
|
||||
return snprintf_key(buf, size, key,
|
||||
sizeof(struct scoutfs_xattr_key), key->key_len,
|
||||
"fs.%llu.xat.%.*s",
|
||||
be64_to_cpu(xkey->ino), len, xkey->name);
|
||||
"fs.%llu.xat.%08x.%llu.%u",
|
||||
be64_to_cpu(xkey->ino),
|
||||
be32_to_cpu(xkey->name_hash),
|
||||
be64_to_cpu(xkey->id), xkey->part);
|
||||
}
|
||||
|
||||
static int pr_dirent(char *buf, struct scoutfs_key_buf *key, size_t size)
|
||||
|
||||
+9
-8
@@ -125,15 +125,16 @@ static u8 *global_printable_name(u8 *name, int name_len)
|
||||
static void print_xattr(void *key, int key_len, void *val, int val_len)
|
||||
{
|
||||
struct scoutfs_xattr_key *xkey = key;
|
||||
struct scoutfs_xattr_key_footer *foot = key + key_len - sizeof(*foot);
|
||||
struct scoutfs_xattr_val_header *vh = val;
|
||||
unsigned int name_len = key_len - sizeof(*xkey) - sizeof(*foot);
|
||||
u8 *name = global_printable_name(xkey->name, name_len);
|
||||
struct scoutfs_xattr *xat = val;
|
||||
|
||||
printf(" xattr: ino %llu part %u part_len %u last_part %u\n"
|
||||
" name %s\n",
|
||||
be64_to_cpu(xkey->ino), foot->part, le16_to_cpu(vh->part_len),
|
||||
vh->last_part, name);
|
||||
printf(" xattr: ino %llu name_hash %08x id %llu part %u\n",
|
||||
be64_to_cpu(xkey->ino), be32_to_cpu(xkey->name_hash),
|
||||
be64_to_cpu(xkey->id), xkey->part);
|
||||
|
||||
if (xkey->part == 0)
|
||||
printf(" name_len %u val_len %u name %s\n",
|
||||
xat->name_len, le16_to_cpu(xat->val_len),
|
||||
global_printable_name(xat->name, xat->name_len));
|
||||
}
|
||||
|
||||
static void print_dirent(void *key, int key_len, void *val, int val_len)
|
||||
|
||||
Reference in New Issue
Block a user