]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.suse/ocfs2-reserve-inline-space-for-extend.patch
Move xen patchset to new version's subdir.
[ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / ocfs2-reserve-inline-space-for-extend.patch
CommitLineData
00e5a55c
BS
1From: Tiger Yang <tiger.yang@oracle.com>
2Subject: [PATCH 08/16] ocfs2: reserve inline space for extended attribute
3Patch-mainline: 2.6.28?
4References: FATE302067
5
6Add the structures and helper functions we want for handling inline extended
7attributes. We also update the inline-data handlers so that they properly
8function in the event that we have both inline data and inline attributes
9sharing an inode block.
10
11Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
12Signed-off-by: Mark Fasheh <mfasheh@suse.com>
13---
14 fs/ocfs2/alloc.c | 22 ++++++++++++++++------
15 fs/ocfs2/ocfs2.h | 1 +
16 fs/ocfs2/ocfs2_fs.h | 46 +++++++++++++++++++++++++++++++++++++++++++---
17 fs/ocfs2/super.c | 2 ++
18 4 files changed, 62 insertions(+), 9 deletions(-)
19
20diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
21index 130988f..d175db1 100644
22--- a/fs/ocfs2/alloc.c
23+++ b/fs/ocfs2/alloc.c
24@@ -6586,20 +6586,29 @@ out:
25 return ret;
26 }
27
28-static void ocfs2_zero_dinode_id2(struct inode *inode, struct ocfs2_dinode *di)
29+static void ocfs2_zero_dinode_id2_with_xattr(struct inode *inode,
30+ struct ocfs2_dinode *di)
31 {
32 unsigned int blocksize = 1 << inode->i_sb->s_blocksize_bits;
33+ unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
34
35- memset(&di->id2, 0, blocksize - offsetof(struct ocfs2_dinode, id2));
36+ if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
37+ memset(&di->id2, 0, blocksize -
38+ offsetof(struct ocfs2_dinode, id2) -
39+ xattrsize);
40+ else
41+ memset(&di->id2, 0, blocksize -
42+ offsetof(struct ocfs2_dinode, id2));
43 }
44
45 void ocfs2_dinode_new_extent_list(struct inode *inode,
46 struct ocfs2_dinode *di)
47 {
48- ocfs2_zero_dinode_id2(inode, di);
49+ ocfs2_zero_dinode_id2_with_xattr(inode, di);
50 di->id2.i_list.l_tree_depth = 0;
51 di->id2.i_list.l_next_free_rec = 0;
52- di->id2.i_list.l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(inode->i_sb));
53+ di->id2.i_list.l_count = cpu_to_le16(
54+ ocfs2_extent_recs_per_inode_with_xattr(inode->i_sb, di));
55 }
56
57 void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di)
58@@ -6616,9 +6625,10 @@ void ocfs2_set_inode_data_inline(struct inode *inode, struct ocfs2_dinode *di)
59 * We clear the entire i_data structure here so that all
60 * fields can be properly initialized.
61 */
62- ocfs2_zero_dinode_id2(inode, di);
63+ ocfs2_zero_dinode_id2_with_xattr(inode, di);
64
65- idata->id_count = cpu_to_le16(ocfs2_max_inline_data(inode->i_sb));
66+ idata->id_count = cpu_to_le16(
67+ ocfs2_max_inline_data_with_xattr(inode->i_sb, di));
68 }
69
70 int ocfs2_convert_inline_data_to_extents(struct inode *inode,
71diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
72index 7f625f2..9275923 100644
73--- a/fs/ocfs2/ocfs2.h
74+++ b/fs/ocfs2/ocfs2.h
75@@ -241,6 +241,7 @@ struct ocfs2_super
76 int s_sectsize_bits;
77 int s_clustersize;
78 int s_clustersize_bits;
79+ unsigned int s_xattr_inline_size;
80
81 atomic_t vol_state;
82 struct mutex recovery_lock;
83diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h
84index 1b46505..1055ba0 100644
85--- a/fs/ocfs2/ocfs2_fs.h
86+++ b/fs/ocfs2/ocfs2_fs.h
87@@ -300,6 +300,12 @@ struct ocfs2_new_group_input {
88 */
89 #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
90
91+/*
92+ * Inline extended attribute size (in bytes)
93+ * The value chosen should be aligned to 16 byte boundaries.
94+ */
95+#define OCFS2_MIN_XATTR_INLINE_SIZE 256
96+
97 struct ocfs2_system_inode_info {
98 char *si_name;
99 int si_iflags;
100@@ -622,7 +628,8 @@ struct ocfs2_dinode {
101 belongs to */
102 __le16 i_suballoc_bit; /* Bit offset in suballocator
103 block group */
104-/*10*/ __le32 i_reserved0;
105+/*10*/ __le16 i_reserved0;
106+ __le16 i_xattr_inline_size;
107 __le32 i_clusters; /* Cluster count */
108 __le32 i_uid; /* Owner UID */
109 __le32 i_gid; /* Owning GID */
110@@ -641,11 +648,12 @@ struct ocfs2_dinode {
111 __le32 i_atime_nsec;
112 __le32 i_ctime_nsec;
113 __le32 i_mtime_nsec;
114- __le32 i_attr;
115+/*70*/ __le32 i_attr;
116 __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL
117 was set in i_flags */
118 __le16 i_dyn_features;
119-/*70*/ __le64 i_reserved2[8];
120+ __le64 i_xattr_loc;
121+/*80*/ __le64 i_reserved2[7];
122 /*B8*/ union {
123 __le64 i_pad1; /* Generic way to refer to this
124 64bit union */
125@@ -846,6 +854,20 @@ static inline int ocfs2_max_inline_data(struct super_block *sb)
126 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
127 }
128
129+static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
130+ struct ocfs2_dinode *di)
131+{
132+ unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
133+
134+ if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
135+ return sb->s_blocksize -
136+ offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
137+ xattrsize;
138+ else
139+ return sb->s_blocksize -
140+ offsetof(struct ocfs2_dinode, id2.i_data.id_data);
141+}
142+
143 static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
144 {
145 int size;
146@@ -856,6 +878,24 @@ static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
147 return size / sizeof(struct ocfs2_extent_rec);
148 }
149
150+static inline int ocfs2_extent_recs_per_inode_with_xattr(
151+ struct super_block *sb,
152+ struct ocfs2_dinode *di)
153+{
154+ int size;
155+ unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
156+
157+ if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
158+ size = sb->s_blocksize -
159+ offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
160+ xattrsize;
161+ else
162+ size = sb->s_blocksize -
163+ offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
164+
165+ return size / sizeof(struct ocfs2_extent_rec);
166+}
167+
168 static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
169 {
170 int size;
171diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
172index 88255d3..4029fce 100644
173--- a/fs/ocfs2/super.c
174+++ b/fs/ocfs2/super.c
175@@ -1421,6 +1421,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
176
177 osb->slot_num = OCFS2_INVALID_SLOT;
178
179+ osb->s_xattr_inline_size = OCFS2_MIN_XATTR_INLINE_SIZE;
180+
181 osb->local_alloc_state = OCFS2_LA_UNUSED;
182 osb->local_alloc_bh = NULL;
183
184--
1851.5.4.5
186