diff options
author | Joel Becker <joel.becker@oracle.com> | 2006-02-28 20:58:36 -0500 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2006-03-01 14:44:50 -0500 |
commit | 110ba90858a7f619ff26c6b9b43c27b3c0872335 (patch) | |
tree | 2a28b91a66b7570b576a581f50e512f3f316a8af /fs/ocfs2 | |
parent | 93cc9ac4555a9b95c78b2f5dfe536fe8196002a7 (diff) |
ocfs2: Respond to on-disk corruption in the extent map code.
The extent map code has long noticed when the on-disk extent information
is corrupt. However, so far it has only returned an error. We should
take the filesystem read-only, as it is corrupt.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/extent_map.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index b6ba292e9544..e6f207eebab4 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -181,6 +181,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
181 | ret = -EBADR; | 181 | ret = -EBADR; |
182 | if (rec_end > OCFS2_I(inode)->ip_clusters) { | 182 | if (rec_end > OCFS2_I(inode)->ip_clusters) { |
183 | mlog_errno(ret); | 183 | mlog_errno(ret); |
184 | ocfs2_error(inode->i_sb, | ||
185 | "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", | ||
186 | i, | ||
187 | le64_to_cpu(rec->e_blkno), | ||
188 | OCFS2_I(inode)->ip_blkno, | ||
189 | OCFS2_I(inode)->ip_clusters); | ||
184 | goto out_free; | 190 | goto out_free; |
185 | } | 191 | } |
186 | 192 | ||
@@ -226,6 +232,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
226 | ret = -EBADR; | 232 | ret = -EBADR; |
227 | if (blkno) { | 233 | if (blkno) { |
228 | mlog_errno(ret); | 234 | mlog_errno(ret); |
235 | ocfs2_error(inode->i_sb, | ||
236 | "Multiple extents for (cpos = %u, clusters = %u) on inode %"MLFu64"; e_blkno %"MLFu64" and rec %d at e_blkno %"MLFu64"\n", | ||
237 | cpos, clusters, | ||
238 | OCFS2_I(inode)->ip_blkno, | ||
239 | blkno, i, | ||
240 | le64_to_cpu(rec->e_blkno)); | ||
229 | goto out_free; | 241 | goto out_free; |
230 | } | 242 | } |
231 | 243 | ||
@@ -238,6 +250,10 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
238 | */ | 250 | */ |
239 | ret = -EBADR; | 251 | ret = -EBADR; |
240 | if (!blkno) { | 252 | if (!blkno) { |
253 | ocfs2_error(inode->i_sb, | ||
254 | "No record found for (cpos = %u, clusters = %u) on inode %"MLFu64"\n", | ||
255 | cpos, clusters, | ||
256 | OCFS2_I(inode)->ip_blkno); | ||
241 | mlog_errno(ret); | 257 | mlog_errno(ret); |
242 | goto out_free; | 258 | goto out_free; |
243 | } | 259 | } |
@@ -266,6 +282,20 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode, | |||
266 | 282 | ||
267 | for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { | 283 | for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { |
268 | rec = &el->l_recs[i]; | 284 | rec = &el->l_recs[i]; |
285 | |||
286 | if ((le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters)) > | ||
287 | OCFS2_I(inode)->ip_clusters) { | ||
288 | ret = -EBADR; | ||
289 | mlog_errno(ret); | ||
290 | ocfs2_error(inode->i_sb, | ||
291 | "Extent %d at e_blkno %"MLFu64" of inode %"MLFu64" goes past ip_clusters of %u\n", | ||
292 | i, | ||
293 | le64_to_cpu(rec->e_blkno), | ||
294 | OCFS2_I(inode)->ip_blkno, | ||
295 | OCFS2_I(inode)->ip_clusters); | ||
296 | return ret; | ||
297 | } | ||
298 | |||
269 | ret = ocfs2_extent_map_insert(inode, rec, | 299 | ret = ocfs2_extent_map_insert(inode, rec, |
270 | le16_to_cpu(el->l_tree_depth)); | 300 | le16_to_cpu(el->l_tree_depth)); |
271 | if (ret) { | 301 | if (ret) { |
@@ -526,6 +556,10 @@ static int ocfs2_extent_map_insert(struct inode *inode, | |||
526 | OCFS2_I(inode)->ip_map.em_clusters) { | 556 | OCFS2_I(inode)->ip_map.em_clusters) { |
527 | ret = -EBADR; | 557 | ret = -EBADR; |
528 | mlog_errno(ret); | 558 | mlog_errno(ret); |
559 | ocfs2_error(inode->i_sb, | ||
560 | "Zero e_clusters on non-tail extent record at e_blkno %"MLFu64" on inode %"MLFu64"\n", | ||
561 | le64_to_cpu(rec->e_blkno), | ||
562 | OCFS2_I(inode)->ip_blkno); | ||
529 | return ret; | 563 | return ret; |
530 | } | 564 | } |
531 | 565 | ||
@@ -588,12 +622,12 @@ static int ocfs2_extent_map_insert(struct inode *inode, | |||
588 | * Existing record in the extent map: | 622 | * Existing record in the extent map: |
589 | * | 623 | * |
590 | * cpos = 10, len = 10 | 624 | * cpos = 10, len = 10 |
591 | * |---------| | 625 | * |---------| |
592 | * | 626 | * |
593 | * New Record: | 627 | * New Record: |
594 | * | 628 | * |
595 | * cpos = 10, len = 20 | 629 | * cpos = 10, len = 20 |
596 | * |------------------| | 630 | * |------------------| |
597 | * | 631 | * |
598 | * The passed record is the new on-disk record. The new_clusters value | 632 | * The passed record is the new on-disk record. The new_clusters value |
599 | * is how many clusters were added to the file. If the append is a | 633 | * is how many clusters were added to the file. If the append is a |