]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/extent_map.c
[PATCH] splice: rearrange moving to/from pipe helpers
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / extent_map.c
index f2fb40cd296a2890b1af082794c1324ba6969c0d..4601fc256f111254e41d124d08e95f216357b11e 100644 (file)
@@ -181,6 +181,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
                        ret = -EBADR;
                        if (rec_end > OCFS2_I(inode)->ip_clusters) {
                                mlog_errno(ret);
+                               ocfs2_error(inode->i_sb,
+                                           "Extent %d at e_blkno %llu of inode %llu goes past ip_clusters of %u\n",
+                                           i,
+                                           (unsigned long long)le64_to_cpu(rec->e_blkno),
+                                           (unsigned long long)OCFS2_I(inode)->ip_blkno,
+                                           OCFS2_I(inode)->ip_clusters);
                                goto out_free;
                        }
 
@@ -226,6 +232,12 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
                        ret = -EBADR;
                        if (blkno) {
                                mlog_errno(ret);
+                               ocfs2_error(inode->i_sb,
+                                           "Multiple extents for (cpos = %u, clusters = %u) on inode %llu; e_blkno %llu and rec %d at e_blkno %llu\n",
+                                           cpos, clusters,
+                                           (unsigned long long)OCFS2_I(inode)->ip_blkno,
+                                           (unsigned long long)blkno, i,
+                                           (unsigned long long)le64_to_cpu(rec->e_blkno));
                                goto out_free;
                        }
 
@@ -238,6 +250,10 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
                 */
                ret = -EBADR;
                if (!blkno) {
+                       ocfs2_error(inode->i_sb,
+                                   "No record found for (cpos = %u, clusters = %u) on inode %llu\n",
+                                   cpos, clusters,
+                                   (unsigned long long)OCFS2_I(inode)->ip_blkno);
                        mlog_errno(ret);
                        goto out_free;
                }
@@ -262,11 +278,24 @@ static int ocfs2_extent_map_find_leaf(struct inode *inode,
                el = &eb->h_list;
        }
 
-       if (el->l_tree_depth)
-               BUG();
+       BUG_ON(el->l_tree_depth);
 
        for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) {
                rec = &el->l_recs[i];
+
+               if ((le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters)) >
+                   OCFS2_I(inode)->ip_clusters) {
+                       ret = -EBADR;
+                       mlog_errno(ret);
+                       ocfs2_error(inode->i_sb,
+                                   "Extent %d at e_blkno %llu of inode %llu goes past ip_clusters of %u\n",
+                                   i,
+                                   (unsigned long long)le64_to_cpu(rec->e_blkno),
+                                   (unsigned long long)OCFS2_I(inode)->ip_blkno,
+                                   OCFS2_I(inode)->ip_clusters);
+                       return ret;
+               }
+
                ret = ocfs2_extent_map_insert(inode, rec,
                                              le16_to_cpu(el->l_tree_depth));
                if (ret) {
@@ -364,8 +393,8 @@ static int ocfs2_extent_map_lookup_read(struct inode *inode,
                return ret;
        }
 
-       if (ent->e_tree_depth)
-               BUG();  /* FIXME: Make sure this isn't a corruption */
+       /* FIXME: Make sure this isn't a corruption */
+       BUG_ON(ent->e_tree_depth);
 
        *ret_ent = ent;
 
@@ -423,8 +452,7 @@ static int ocfs2_extent_map_try_insert(struct inode *inode,
                                          le32_to_cpu(rec->e_clusters), NULL,
                                          NULL);
 
-       if (!old_ent)
-               BUG();
+       BUG_ON(!old_ent);
 
        ret = -EEXIST;
        if (old_ent->e_tree_depth < tree_depth)
@@ -528,6 +556,10 @@ static int ocfs2_extent_map_insert(struct inode *inode,
                    OCFS2_I(inode)->ip_map.em_clusters) {
                        ret = -EBADR;
                        mlog_errno(ret);
+                       ocfs2_error(inode->i_sb,
+                                   "Zero e_clusters on non-tail extent record at e_blkno %llu on inode %llu\n",
+                                   (unsigned long long)le64_to_cpu(rec->e_blkno),
+                                   (unsigned long long)OCFS2_I(inode)->ip_blkno);
                        return ret;
                }
 
@@ -590,12 +622,12 @@ static int ocfs2_extent_map_insert(struct inode *inode,
  * Existing record in the extent map:
  *
  *     cpos = 10, len = 10
- *     |---------|
+ *     |---------|
  *
  * New Record:
  *
  *     cpos = 10, len = 20
- *     |------------------|
+ *     |------------------|
  *
  * The passed record is the new on-disk record.  The new_clusters value
  * is how many clusters were added to the file.  If the append is a
@@ -628,10 +660,10 @@ int ocfs2_extent_map_append(struct inode *inode,
        mlog_bug_on_msg((le32_to_cpu(rec->e_cpos) +
                         le32_to_cpu(rec->e_clusters)) !=
                        (em->em_clusters + new_clusters),
-                       "Inode %"MLFu64":\n"
+                       "Inode %llu:\n"
                        "rec->e_cpos = %u + rec->e_clusters = %u = %u\n"
                        "em->em_clusters = %u + new_clusters = %u = %u\n",
-                       OCFS2_I(inode)->ip_blkno,
+                       (unsigned long long)OCFS2_I(inode)->ip_blkno,
                        le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters),
                        le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters),
                        em->em_clusters, new_clusters,
@@ -988,7 +1020,7 @@ int __init init_ocfs2_extent_maps(void)
        return 0;
 }
 
-void __exit exit_ocfs2_extent_maps(void)
+void exit_ocfs2_extent_maps(void)
 {
        kmem_cache_destroy(ocfs2_em_ent_cachep);
 }