1 From: Tiger Yang <tiger.yang@oracle.com>
2 Date: Fri, 20 Feb 2009 11:11:50 +0800
3 Subject: [PATCH] ocfs2: set gap to seperate entry and value when xattr in bucket
6 This patch set a gap (4 bytes) between xattr entry and
7 name/value when xattr in bucket. This gap use to seperate
8 entry and name/value when a bucket is full. It had already
9 been set when xattr in inode/block.
11 Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
12 Signed-off-by: Mark Fasheh <mfasheh@suse.com>
14 fs/ocfs2/xattr.c | 18 ++++++++++--------
15 1 files changed, 10 insertions(+), 8 deletions(-)
17 Index: linux-2.6.27-sle11_ocfs2_update2/fs/ocfs2/xattr.c
18 ===================================================================
19 --- linux-2.6.27-sle11_ocfs2_update2.orig/fs/ocfs2/xattr.c
20 +++ linux-2.6.27-sle11_ocfs2_update2/fs/ocfs2/xattr.c
21 @@ -81,13 +81,14 @@ struct ocfs2_xattr_set_ctxt {
23 #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root))
24 #define OCFS2_XATTR_INLINE_SIZE 80
25 +#define OCFS2_XATTR_HEADER_GAP 4
26 #define OCFS2_XATTR_FREE_IN_IBODY (OCFS2_MIN_XATTR_INLINE_SIZE \
27 - sizeof(struct ocfs2_xattr_header) \
29 + - OCFS2_XATTR_HEADER_GAP)
30 #define OCFS2_XATTR_FREE_IN_BLOCK(ptr) ((ptr)->i_sb->s_blocksize \
31 - sizeof(struct ocfs2_xattr_block) \
32 - sizeof(struct ocfs2_xattr_header) \
34 + - OCFS2_XATTR_HEADER_GAP)
36 static struct ocfs2_xattr_def_value_root def_xv = {
37 .xv.xr_list.l_count = cpu_to_le16(1),
38 @@ -1411,7 +1412,7 @@ static int ocfs2_xattr_set_entry(struct
42 - free = min_offs - ((void *)last - xs->base) - sizeof(__u32);
43 + free = min_offs - ((void *)last - xs->base) - OCFS2_XATTR_HEADER_GAP;
47 @@ -2101,7 +2102,7 @@ static int ocfs2_xattr_can_be_in_inode(s
51 - free = min_offs - ((void *)last - xs->base) - sizeof(__u32);
52 + free = min_offs - ((void *)last - xs->base) - OCFS2_XATTR_HEADER_GAP;
56 @@ -4919,8 +4920,8 @@ try_again:
57 xh_free_start = le16_to_cpu(xh->xh_free_start);
58 header_size = sizeof(struct ocfs2_xattr_header) +
59 count * sizeof(struct ocfs2_xattr_entry);
60 - max_free = OCFS2_XATTR_BUCKET_SIZE -
61 - le16_to_cpu(xh->xh_name_value_len) - header_size;
62 + max_free = OCFS2_XATTR_BUCKET_SIZE - header_size -
63 + le16_to_cpu(xh->xh_name_value_len) - OCFS2_XATTR_HEADER_GAP;
65 mlog_bug_on_msg(header_size > blocksize, "bucket %llu has header size "
66 "of %u which exceed block size\n",
67 @@ -4953,7 +4954,7 @@ try_again:
71 - free = xh_free_start - header_size;
72 + free = xh_free_start - header_size - OCFS2_XATTR_HEADER_GAP;
74 * We need to make sure the new name/value pair
75 * can exist in the same block.
76 @@ -4986,7 +4987,8 @@ try_again:
79 xh_free_start = le16_to_cpu(xh->xh_free_start);
80 - free = xh_free_start - header_size;
81 + free = xh_free_start - header_size
82 + - OCFS2_XATTR_HEADER_GAP;
83 if (xh_free_start % blocksize < need)
84 free -= xh_free_start % blocksize;