Merge branch 'slab/urgent' into slab/next
[pandora-kernel.git] / fs / ext4 / block_validity.c
index fac90f3..8efb2f0 100644 (file)
@@ -246,3 +246,24 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
        return 1;
 }
 
+int ext4_check_blockref(const char *function, unsigned int line,
+                       struct inode *inode, __le32 *p, unsigned int max)
+{
+       struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
+       __le32 *bref = p;
+       unsigned int blk;
+
+       while (bref < p+max) {
+               blk = le32_to_cpu(*bref++);
+               if (blk &&
+                   unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
+                                                   blk, 1))) {
+                       es->s_last_error_block = cpu_to_le64(blk);
+                       ext4_error_inode(inode, function, line, blk,
+                                        "invalid block");
+                       return -EIO;
+               }
+       }
+       return 0;
+}
+