mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-09 21:27:25 +00:00
scoutfs: have xattr use max val size
The xattr code had a static defintion of the largest part item that it would create. Change it to be a function of the largest fs item value that can be created and clean up the code a bit in the process. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -225,7 +225,7 @@ static inline const struct scoutfs_item_count SIC_XATTR_SET(unsigned old_parts,
|
||||
cnt.items++;
|
||||
|
||||
if (creating) {
|
||||
new_parts = SCOUTFS_XATTR_NR_PARTS(name_len, size)
|
||||
new_parts = SCOUTFS_XATTR_NR_PARTS(name_len, size);
|
||||
|
||||
cnt.items += new_parts;
|
||||
cnt.vals += sizeof(struct scoutfs_xattr) + name_len + size;
|
||||
|
||||
@@ -611,11 +611,11 @@ enum {
|
||||
|
||||
#define SCOUTFS_XATTR_MAX_NAME_LEN 255
|
||||
#define SCOUTFS_XATTR_MAX_VAL_LEN 65535
|
||||
#define SCOUTFS_XATTR_MAX_PART_SIZE 512U
|
||||
#define SCOUTFS_XATTR_MAX_PART_SIZE SCOUTFS_MAX_VAL_SIZE
|
||||
|
||||
#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);
|
||||
(unsigned int)SCOUTFS_XATTR_MAX_PART_SIZE)
|
||||
|
||||
#define SCOUTFS_LOCK_INODE_GROUP_NR 1024
|
||||
#define SCOUTFS_LOCK_INODE_GROUP_MASK (SCOUTFS_LOCK_INODE_GROUP_NR - 1)
|
||||
|
||||
@@ -270,8 +270,8 @@ static int create_xattr_items(struct inode *inode, u64 id,
|
||||
struct super_block *sb = inode->i_sb;
|
||||
struct scoutfs_key key;
|
||||
unsigned int part_bytes;
|
||||
unsigned int total;
|
||||
struct kvec val;
|
||||
int total;
|
||||
int ret;
|
||||
|
||||
init_xattr_key(&key, scoutfs_ino(inode),
|
||||
@@ -280,7 +280,8 @@ static int create_xattr_items(struct inode *inode, u64 id,
|
||||
total = 0;
|
||||
ret = 0;
|
||||
while (total < bytes) {
|
||||
part_bytes = min(bytes - total, SCOUTFS_XATTR_MAX_PART_SIZE);
|
||||
part_bytes = min_t(unsigned int, bytes - total,
|
||||
SCOUTFS_XATTR_MAX_PART_SIZE);
|
||||
kvec_init(&val, (void *)xat + total, part_bytes);
|
||||
|
||||
ret = scoutfs_forest_create(sb, &key, &val, lock);
|
||||
|
||||
Reference in New Issue
Block a user