Btrfs: corruption hunt continues
Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
committed by
David Woodhouse
parent
22b0ebda6c
commit
d602557953
@ -2,6 +2,7 @@
|
||||
#define __BTRFS__
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/buffer_head.h>
|
||||
#include "bit-radix.h"
|
||||
|
||||
struct btrfs_trans_handle;
|
||||
@ -834,6 +835,37 @@ static inline struct btrfs_root *btrfs_sb(struct super_block *sb)
|
||||
return sb->s_fs_info;
|
||||
}
|
||||
|
||||
static inline void btrfs_check_bounds(void *vptr, size_t len,
|
||||
void *vcontainer, size_t container_len)
|
||||
{
|
||||
char *ptr = vptr;
|
||||
char *container = vcontainer;
|
||||
WARN_ON(ptr < container);
|
||||
WARN_ON(ptr + len > container + container_len);
|
||||
}
|
||||
|
||||
static inline void btrfs_memcpy(struct btrfs_root *root,
|
||||
void *dst_block,
|
||||
void *dst, const void *src, size_t nr)
|
||||
{
|
||||
btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize);
|
||||
memcpy(dst, src, nr);
|
||||
}
|
||||
|
||||
static inline void btrfs_memmove(struct btrfs_root *root,
|
||||
void *dst_block,
|
||||
void *dst, void *src, size_t nr)
|
||||
{
|
||||
btrfs_check_bounds(dst, nr, dst_block, root->fs_info->sb->s_blocksize);
|
||||
memmove(dst, src, nr);
|
||||
}
|
||||
|
||||
static inline void btrfs_mark_buffer_dirty(struct buffer_head *bh)
|
||||
{
|
||||
WARN_ON(!atomic_read(&bh->b_count));
|
||||
mark_buffer_dirty(bh);
|
||||
}
|
||||
|
||||
/* helper function to cast into the data area of the leaf. */
|
||||
#define btrfs_item_ptr(leaf, slot, type) \
|
||||
((type *)(btrfs_leaf_data(leaf) + \
|
||||
|
Reference in New Issue
Block a user