diff options
Diffstat (limited to 'fs/ocfs2/extent_map.c')
-rw-r--r-- | fs/ocfs2/extent_map.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index 937c2722b753..ea0ce41d4193 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -50,13 +50,15 @@ static int ocfs2_search_extent_list(struct ocfs2_extent_list *el, | |||
50 | int ret = -1; | 50 | int ret = -1; |
51 | int i; | 51 | int i; |
52 | struct ocfs2_extent_rec *rec; | 52 | struct ocfs2_extent_rec *rec; |
53 | u32 rec_end, rec_start; | 53 | u32 rec_end, rec_start, clusters; |
54 | 54 | ||
55 | for(i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { | 55 | for(i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { |
56 | rec = &el->l_recs[i]; | 56 | rec = &el->l_recs[i]; |
57 | 57 | ||
58 | rec_start = le32_to_cpu(rec->e_cpos); | 58 | rec_start = le32_to_cpu(rec->e_cpos); |
59 | rec_end = rec_start + le32_to_cpu(rec->e_clusters); | 59 | clusters = ocfs2_rec_clusters(el, rec); |
60 | |||
61 | rec_end = rec_start + clusters; | ||
60 | 62 | ||
61 | if (v_cluster >= rec_start && v_cluster < rec_end) { | 63 | if (v_cluster >= rec_start && v_cluster < rec_end) { |
62 | ret = i; | 64 | ret = i; |
@@ -98,6 +100,15 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, | |||
98 | 100 | ||
99 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; | 101 | eb = (struct ocfs2_extent_block *) eb_bh->b_data; |
100 | el = &eb->h_list; | 102 | el = &eb->h_list; |
103 | |||
104 | if (el->l_tree_depth) { | ||
105 | ocfs2_error(inode->i_sb, | ||
106 | "Inode %lu has non zero tree depth in " | ||
107 | "leaf block %llu\n", inode->i_ino, | ||
108 | (unsigned long long)eb_bh->b_blocknr); | ||
109 | ret = -EROFS; | ||
110 | goto out; | ||
111 | } | ||
101 | } | 112 | } |
102 | 113 | ||
103 | i = ocfs2_search_extent_list(el, v_cluster); | 114 | i = ocfs2_search_extent_list(el, v_cluster); |
@@ -118,7 +129,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, | |||
118 | ocfs2_error(inode->i_sb, "Inode %lu has bad extent " | 129 | ocfs2_error(inode->i_sb, "Inode %lu has bad extent " |
119 | "record (%u, %u, 0)", inode->i_ino, | 130 | "record (%u, %u, 0)", inode->i_ino, |
120 | le32_to_cpu(rec->e_cpos), | 131 | le32_to_cpu(rec->e_cpos), |
121 | le32_to_cpu(rec->e_clusters)); | 132 | ocfs2_rec_clusters(el, rec)); |
122 | ret = -EROFS; | 133 | ret = -EROFS; |
123 | goto out; | 134 | goto out; |
124 | } | 135 | } |
@@ -130,7 +141,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, | |||
130 | *p_cluster = *p_cluster + coff; | 141 | *p_cluster = *p_cluster + coff; |
131 | 142 | ||
132 | if (num_clusters) | 143 | if (num_clusters) |
133 | *num_clusters = le32_to_cpu(rec->e_clusters) - coff; | 144 | *num_clusters = ocfs2_rec_clusters(el, rec) - coff; |
134 | } | 145 | } |
135 | 146 | ||
136 | out: | 147 | out: |