]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.suse/ocfs2-Add-an-insertion-check-to-ocfs2_extent_tree_o.patch
Merge branch 'master' of git://git.ipfire.org/ipfire-2.x
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / ocfs2-Add-an-insertion-check-to-ocfs2_extent_tree_o.patch
CommitLineData
2cb7cef9
BS
1From: Joel Becker <joel.becker@oracle.com>
2Subject: ocfs2: Add an insertion check to ocfs2_extent_tree_operations.
3Patch-mainline: 2.6.28?
4References: FATE302067
5
6A couple places check an extent_tree for a valid inode. We move that
7out to add an eo_insert_check() operation. It can be called from
8ocfs2_insert_extent() and elsewhere.
9
10We also have the wrapper calls ocfs2_et_insert_check() and
11ocfs2_et_sanity_check() ignore NULL ops. That way we don't have to
12provide useless operations for xattr types.
13
14Signed-off-by: Joel Becker <joel.becker@oracle.com>
15Acked-by: Mark Fasheh <mark.fasheh@suse.com>
16---
17 fs/ocfs2/alloc.c | 69 ++++++++++++++++++++++++++++++++++-------------------
18 1 files changed, 44 insertions(+), 25 deletions(-)
19
20diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
21index 243bacf..2083c2c 100644
22--- a/fs/ocfs2/alloc.c
23+++ b/fs/ocfs2/alloc.c
24@@ -71,6 +71,9 @@ struct ocfs2_extent_tree_operations {
25 void (*eo_update_clusters)(struct inode *inode,
26 struct ocfs2_extent_tree *et,
27 u32 new_clusters);
28+ int (*eo_insert_check)(struct inode *inode,
29+ struct ocfs2_extent_tree *et,
30+ struct ocfs2_extent_rec *rec);
31 int (*eo_sanity_check)(struct inode *inode, struct ocfs2_extent_tree *et);
32
33 /* These are internal to ocfs2_extent_tree and don't have
34@@ -125,6 +128,25 @@ static void ocfs2_dinode_update_clusters(struct inode *inode,
35 spin_unlock(&OCFS2_I(inode)->ip_lock);
36 }
37
38+static int ocfs2_dinode_insert_check(struct inode *inode,
39+ struct ocfs2_extent_tree *et,
40+ struct ocfs2_extent_rec *rec)
41+{
42+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
43+
44+ BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL);
45+ mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) &&
46+ (OCFS2_I(inode)->ip_clusters != rec->e_cpos),
47+ "Device %s, asking for sparse allocation: inode %llu, "
48+ "cpos %u, clusters %u\n",
49+ osb->dev_str,
50+ (unsigned long long)OCFS2_I(inode)->ip_blkno,
51+ rec->e_cpos,
52+ OCFS2_I(inode)->ip_clusters);
53+
54+ return 0;
55+}
56+
57 static int ocfs2_dinode_sanity_check(struct inode *inode,
58 struct ocfs2_extent_tree *et)
59 {
60@@ -148,6 +170,7 @@ static struct ocfs2_extent_tree_operations ocfs2_dinode_et_ops = {
61 .eo_set_last_eb_blk = ocfs2_dinode_set_last_eb_blk,
62 .eo_get_last_eb_blk = ocfs2_dinode_get_last_eb_blk,
63 .eo_update_clusters = ocfs2_dinode_update_clusters,
64+ .eo_insert_check = ocfs2_dinode_insert_check,
65 .eo_sanity_check = ocfs2_dinode_sanity_check,
66 .eo_fill_root_el = ocfs2_dinode_fill_root_el,
67 };
68@@ -186,17 +209,10 @@ static void ocfs2_xattr_value_update_clusters(struct inode *inode,
69 le32_add_cpu(&xv->xr_clusters, clusters);
70 }
71
72-static int ocfs2_xattr_value_sanity_check(struct inode *inode,
73- struct ocfs2_extent_tree *et)
74-{
75- return 0;
76-}
77-
78 static struct ocfs2_extent_tree_operations ocfs2_xattr_value_et_ops = {
79 .eo_set_last_eb_blk = ocfs2_xattr_value_set_last_eb_blk,
80 .eo_get_last_eb_blk = ocfs2_xattr_value_get_last_eb_blk,
81 .eo_update_clusters = ocfs2_xattr_value_update_clusters,
82- .eo_sanity_check = ocfs2_xattr_value_sanity_check,
83 .eo_fill_root_el = ocfs2_xattr_value_fill_root_el,
84 };
85
86@@ -241,17 +257,10 @@ static void ocfs2_xattr_tree_update_clusters(struct inode *inode,
87 le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, clusters);
88 }
89
90-static int ocfs2_xattr_tree_sanity_check(struct inode *inode,
91- struct ocfs2_extent_tree *et)
92-{
93- return 0;
94-}
95-
96 static struct ocfs2_extent_tree_operations ocfs2_xattr_tree_et_ops = {
97 .eo_set_last_eb_blk = ocfs2_xattr_tree_set_last_eb_blk,
98 .eo_get_last_eb_blk = ocfs2_xattr_tree_get_last_eb_blk,
99 .eo_update_clusters = ocfs2_xattr_tree_update_clusters,
100- .eo_sanity_check = ocfs2_xattr_tree_sanity_check,
101 .eo_fill_root_el = ocfs2_xattr_tree_fill_root_el,
102 .eo_fill_max_leaf_clusters = ocfs2_xattr_tree_fill_max_leaf_clusters,
103 };
104@@ -344,10 +353,25 @@ static inline void ocfs2_et_update_clusters(struct inode *inode,
105 et->et_ops->eo_update_clusters(inode, et, clusters);
106 }
107
108+static inline int ocfs2_et_insert_check(struct inode *inode,
109+ struct ocfs2_extent_tree *et,
110+ struct ocfs2_extent_rec *rec)
111+{
112+ int ret = 0;
113+
114+ if (et->et_ops->eo_insert_check)
115+ ret = et->et_ops->eo_insert_check(inode, et, rec);
116+ return ret;
117+}
118+
119 static inline int ocfs2_et_sanity_check(struct inode *inode,
120 struct ocfs2_extent_tree *et)
121 {
122- return et->et_ops->eo_sanity_check(inode, et);
123+ int ret = 0;
124+
125+ if (et->et_ops->eo_sanity_check)
126+ ret = et->et_ops->eo_sanity_check(inode, et);
127+ return ret;
128 }
129
130 static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc);
131@@ -4408,24 +4432,19 @@ static int ocfs2_insert_extent(struct ocfs2_super *osb,
132 struct ocfs2_insert_type insert = {0, };
133 struct ocfs2_extent_rec rec;
134
135- BUG_ON(OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL);
136-
137 mlog(0, "add %u clusters at position %u to inode %llu\n",
138 new_clusters, cpos, (unsigned long long)OCFS2_I(inode)->ip_blkno);
139
140- mlog_bug_on_msg(!ocfs2_sparse_alloc(osb) &&
141- (OCFS2_I(inode)->ip_clusters != cpos),
142- "Device %s, asking for sparse allocation: inode %llu, "
143- "cpos %u, clusters %u\n",
144- osb->dev_str,
145- (unsigned long long)OCFS2_I(inode)->ip_blkno, cpos,
146- OCFS2_I(inode)->ip_clusters);
147-
148 memset(&rec, 0, sizeof(rec));
149 rec.e_cpos = cpu_to_le32(cpos);
150 rec.e_blkno = cpu_to_le64(start_blk);
151 rec.e_leaf_clusters = cpu_to_le16(new_clusters);
152 rec.e_flags = flags;
153+ status = ocfs2_et_insert_check(inode, et, &rec);
154+ if (status) {
155+ mlog_errno(status);
156+ goto bail;
157+ }
158
159 status = ocfs2_figure_insert_type(inode, et, &last_eb_bh, &rec,
160 &free_records, &insert);
161--
1621.5.4.5
163