diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-30 14:27:56 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-30 14:27:56 -0400 |
commit | d6025579531b7ea170ba283b171ff7a6bf7d0e12 (patch) | |
tree | c3b742fda3a6ac8541c06011bb3c26635db99212 /fs/btrfs/ctree.h | |
parent | 22b0ebda6c63a1ad66b6a9e806bd226a4a03a049 (diff) |
Btrfs: corruption hunt continues
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index df1a025a771c..9ec0d65ebe9b 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __BTRFS__ | 2 | #define __BTRFS__ |
3 | 3 | ||
4 | #include <linux/fs.h> | 4 | #include <linux/fs.h> |
5 | #include <linux/buffer_head.h> | ||
5 | #include "bit-radix.h" | 6 | #include "bit-radix.h" |
6 | 7 | ||
7 | struct btrfs_trans_handle; | 8 | struct btrfs_trans_handle; |
@@ -834,6 +835,37 @@ static inline struct btrfs_root *btrfs_sb(struct super_block *sb) | |||
834 | return sb->s_fs_info; | 835 | return sb->s_fs_info; |
835 | } | 836 | } |
836 | 837 | ||
838 | static inline void btrfs_check_bounds(void *vptr, size_t len, | ||
839 | void *vcontainer, size_t container_len) | ||
840 | { | ||
841 | char *ptr = vptr; | ||
842 | char *container = vcontainer; | ||
843 | WARN_ON(ptr < container); | ||
844 | WARN_ON(ptr + len > container + container_len); | ||
845 | } | ||
846 | |||
847 | static inline void btrfs_memcpy(struct btrfs_root *root, | ||
848 | void *dst_block, | ||
849 | void *dst, const void *src, size_t nr) | ||
850 | { | ||
851 | btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize); | ||
852 | memcpy(dst, src, nr); | ||
853 | } | ||
854 | |||
855 | static inline void btrfs_memmove(struct btrfs_root *root, | ||
856 | void *dst_block, | ||
857 | void *dst, void *src, size_t nr) | ||
858 | { | ||
859 | btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize); | ||
860 | memmove(dst, src, nr); | ||
861 | } | ||
862 | |||
863 | static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh) | ||
864 | { | ||
865 | WARN_ON(!atomic_read(&bh->b_count)); | ||
866 | mark_buffer_dirty(bh); | ||
867 | } | ||
868 | |||
837 | /* helper function to cast into the data area of the leaf. */ | 869 | /* helper function to cast into the data area of the leaf. */ |
838 | #define btrfs_item_ptr(leaf, slot, type) \ | 870 | #define btrfs_item_ptr(leaf, slot, type) \ |
839 | ((type *)(btrfs_leaf_data(leaf) + \ | 871 | ((type *)(btrfs_leaf_data(leaf) + \ |