Commit 4442f518 authored by Tiger Yang's avatar Tiger Yang Committed by Mark Fasheh

ocfs2: set gap to seperate entry and value when xattr in bucket

This patch set a gap (4 bytes) between xattr entry and
name/value when xattr in bucket. This gap use to seperate
entry and name/value when a bucket is full. It had already
been set when xattr in inode/block.
Signed-off-by: default avatarTiger Yang <tiger.yang@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent c8b9cf9a
...@@ -82,13 +82,14 @@ struct ocfs2_xattr_set_ctxt { ...@@ -82,13 +82,14 @@ struct ocfs2_xattr_set_ctxt {
#define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
#define OCFS2_XATTR_INLINE_SIZE 80 #define OCFS2_XATTR_INLINE_SIZE 80
#define OCFS2_XATTR_HEADER_GAP 4
#define OCFS2_XATTR_FREE_IN_IBODY (OCFS2_MIN_XATTR_INLINE_SIZE \ #define OCFS2_XATTR_FREE_IN_IBODY (OCFS2_MIN_XATTR_INLINE_SIZE \
- sizeof(struct ocfs2_xattr_header) \ - sizeof(struct ocfs2_xattr_header) \
- sizeof(__u32)) - OCFS2_XATTR_HEADER_GAP)
#define OCFS2_XATTR_FREE_IN_BLOCK(ptr) ((ptr)->i_sb->s_blocksize \ #define OCFS2_XATTR_FREE_IN_BLOCK(ptr) ((ptr)->i_sb->s_blocksize \
- sizeof(struct ocfs2_xattr_block) \ - sizeof(struct ocfs2_xattr_block) \
- sizeof(struct ocfs2_xattr_header) \ - sizeof(struct ocfs2_xattr_header) \
- sizeof(__u32)) - OCFS2_XATTR_HEADER_GAP)
static struct ocfs2_xattr_def_value_root def_xv = { static struct ocfs2_xattr_def_value_root def_xv = {
.xv.xr_list.l_count = cpu_to_le16(1), .xv.xr_list.l_count = cpu_to_le16(1),
...@@ -1511,7 +1512,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode, ...@@ -1511,7 +1512,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
last += 1; last += 1;
} }
free = min_offs - ((void *)last - xs->base) - sizeof(__u32); free = min_offs - ((void *)last - xs->base) - OCFS2_XATTR_HEADER_GAP;
if (free < 0) if (free < 0)
return -EIO; return -EIO;
...@@ -2194,7 +2195,7 @@ static int ocfs2_xattr_can_be_in_inode(struct inode *inode, ...@@ -2194,7 +2195,7 @@ static int ocfs2_xattr_can_be_in_inode(struct inode *inode,
last += 1; last += 1;
} }
free = min_offs - ((void *)last - xs->base) - sizeof(__u32); free = min_offs - ((void *)last - xs->base) - OCFS2_XATTR_HEADER_GAP;
if (free < 0) if (free < 0)
return 0; return 0;
...@@ -5065,8 +5066,8 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, ...@@ -5065,8 +5066,8 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
xh_free_start = le16_to_cpu(xh->xh_free_start); xh_free_start = le16_to_cpu(xh->xh_free_start);
header_size = sizeof(struct ocfs2_xattr_header) + header_size = sizeof(struct ocfs2_xattr_header) +
count * sizeof(struct ocfs2_xattr_entry); count * sizeof(struct ocfs2_xattr_entry);
max_free = OCFS2_XATTR_BUCKET_SIZE - max_free = OCFS2_XATTR_BUCKET_SIZE - header_size -
le16_to_cpu(xh->xh_name_value_len) - header_size; le16_to_cpu(xh->xh_name_value_len) - OCFS2_XATTR_HEADER_GAP;
mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size " mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size "
"of %u which exceed block size\n", "of %u which exceed block size\n",
...@@ -5099,7 +5100,7 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, ...@@ -5099,7 +5100,7 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
need = 0; need = 0;
} }
free = xh_free_start - header_size; free = xh_free_start - header_size - OCFS2_XATTR_HEADER_GAP;
/* /*
* We need to make sure the new name/value pair * We need to make sure the new name/value pair
* can exist in the same block. * can exist in the same block.
...@@ -5132,7 +5133,8 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode, ...@@ -5132,7 +5133,8 @@ static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
} }
xh_free_start = le16_to_cpu(xh->xh_free_start); xh_free_start = le16_to_cpu(xh->xh_free_start);
free = xh_free_start - header_size; free = xh_free_start - header_size
- OCFS2_XATTR_HEADER_GAP;
if (xh_free_start % blocksize < need) if (xh_free_start % blocksize < need)
free -= xh_free_start % blocksize; free -= xh_free_start % blocksize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment