mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-19 02:04:19 +08:00
btrfs: Make btrfs_clear_bit_hook take btrfs_inode
Signed-off-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9cdc512410
commit
6fc0ef6870
@ -428,7 +428,8 @@ static void clear_state_cb(struct extent_io_tree *tree,
|
|||||||
struct extent_state *state, unsigned *bits)
|
struct extent_state *state, unsigned *bits)
|
||||||
{
|
{
|
||||||
if (tree->ops && tree->ops->clear_bit_hook)
|
if (tree->ops && tree->ops->clear_bit_hook)
|
||||||
tree->ops->clear_bit_hook(tree->mapping->host, state, bits);
|
tree->ops->clear_bit_hook(BTRFS_I(tree->mapping->host),
|
||||||
|
state, bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_state_bits(struct extent_io_tree *tree,
|
static void set_state_bits(struct extent_io_tree *tree,
|
||||||
|
@ -84,6 +84,7 @@ extern void le_bitmap_clear(u8 *map, unsigned int start, int len);
|
|||||||
|
|
||||||
struct extent_state;
|
struct extent_state;
|
||||||
struct btrfs_root;
|
struct btrfs_root;
|
||||||
|
struct btrfs_inode;
|
||||||
struct btrfs_io_bio;
|
struct btrfs_io_bio;
|
||||||
struct io_failure_record;
|
struct io_failure_record;
|
||||||
|
|
||||||
@ -107,8 +108,9 @@ struct extent_io_ops {
|
|||||||
struct extent_state *state, int uptodate);
|
struct extent_state *state, int uptodate);
|
||||||
void (*set_bit_hook)(struct inode *inode, struct extent_state *state,
|
void (*set_bit_hook)(struct inode *inode, struct extent_state *state,
|
||||||
unsigned *bits);
|
unsigned *bits);
|
||||||
void (*clear_bit_hook)(struct inode *inode, struct extent_state *state,
|
void (*clear_bit_hook)(struct btrfs_inode *inode,
|
||||||
unsigned *bits);
|
struct extent_state *state,
|
||||||
|
unsigned *bits);
|
||||||
void (*merge_extent_hook)(struct inode *inode,
|
void (*merge_extent_hook)(struct inode *inode,
|
||||||
struct extent_state *new,
|
struct extent_state *new,
|
||||||
struct extent_state *other);
|
struct extent_state *other);
|
||||||
|
@ -1703,18 +1703,18 @@ static void btrfs_set_bit_hook(struct inode *inode,
|
|||||||
/*
|
/*
|
||||||
* extent_io.c clear_bit_hook, see set_bit_hook for why
|
* extent_io.c clear_bit_hook, see set_bit_hook for why
|
||||||
*/
|
*/
|
||||||
static void btrfs_clear_bit_hook(struct inode *inode,
|
static void btrfs_clear_bit_hook(struct btrfs_inode *inode,
|
||||||
struct extent_state *state,
|
struct extent_state *state,
|
||||||
unsigned *bits)
|
unsigned *bits)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
|
||||||
u64 len = state->end + 1 - state->start;
|
u64 len = state->end + 1 - state->start;
|
||||||
u32 num_extents = count_max_extents(len);
|
u32 num_extents = count_max_extents(len);
|
||||||
|
|
||||||
spin_lock(&BTRFS_I(inode)->lock);
|
spin_lock(&inode->lock);
|
||||||
if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG))
|
if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG))
|
||||||
BTRFS_I(inode)->defrag_bytes -= len;
|
inode->defrag_bytes -= len;
|
||||||
spin_unlock(&BTRFS_I(inode)->lock);
|
spin_unlock(&inode->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set_bit and clear bit hooks normally require _irqsave/restore
|
* set_bit and clear bit hooks normally require _irqsave/restore
|
||||||
@ -1722,15 +1722,15 @@ static void btrfs_clear_bit_hook(struct inode *inode,
|
|||||||
* bit, which is only set or cleared with irqs on
|
* bit, which is only set or cleared with irqs on
|
||||||
*/
|
*/
|
||||||
if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) {
|
if ((state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) {
|
||||||
struct btrfs_root *root = BTRFS_I(inode)->root;
|
struct btrfs_root *root = inode->root;
|
||||||
bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode));
|
bool do_list = !btrfs_is_free_space_inode(inode);
|
||||||
|
|
||||||
if (*bits & EXTENT_FIRST_DELALLOC) {
|
if (*bits & EXTENT_FIRST_DELALLOC) {
|
||||||
*bits &= ~EXTENT_FIRST_DELALLOC;
|
*bits &= ~EXTENT_FIRST_DELALLOC;
|
||||||
} else if (!(*bits & EXTENT_DO_ACCOUNTING)) {
|
} else if (!(*bits & EXTENT_DO_ACCOUNTING)) {
|
||||||
spin_lock(&BTRFS_I(inode)->lock);
|
spin_lock(&inode->lock);
|
||||||
BTRFS_I(inode)->outstanding_extents -= num_extents;
|
inode->outstanding_extents -= num_extents;
|
||||||
spin_unlock(&BTRFS_I(inode)->lock);
|
spin_unlock(&inode->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1740,7 +1740,7 @@ static void btrfs_clear_bit_hook(struct inode *inode,
|
|||||||
*/
|
*/
|
||||||
if (*bits & EXTENT_DO_ACCOUNTING &&
|
if (*bits & EXTENT_DO_ACCOUNTING &&
|
||||||
root != fs_info->tree_root)
|
root != fs_info->tree_root)
|
||||||
btrfs_delalloc_release_metadata(BTRFS_I(inode), len);
|
btrfs_delalloc_release_metadata(inode, len);
|
||||||
|
|
||||||
/* For sanity tests. */
|
/* For sanity tests. */
|
||||||
if (btrfs_is_testing(fs_info))
|
if (btrfs_is_testing(fs_info))
|
||||||
@ -1750,18 +1750,19 @@ static void btrfs_clear_bit_hook(struct inode *inode,
|
|||||||
&& do_list && !(state->state & EXTENT_NORESERVE)
|
&& do_list && !(state->state & EXTENT_NORESERVE)
|
||||||
&& (*bits & (EXTENT_DO_ACCOUNTING |
|
&& (*bits & (EXTENT_DO_ACCOUNTING |
|
||||||
EXTENT_CLEAR_DATA_RESV)))
|
EXTENT_CLEAR_DATA_RESV)))
|
||||||
btrfs_free_reserved_data_space_noquota(inode,
|
btrfs_free_reserved_data_space_noquota(
|
||||||
|
&inode->vfs_inode,
|
||||||
state->start, len);
|
state->start, len);
|
||||||
|
|
||||||
__percpu_counter_add(&fs_info->delalloc_bytes, -len,
|
__percpu_counter_add(&fs_info->delalloc_bytes, -len,
|
||||||
fs_info->delalloc_batch);
|
fs_info->delalloc_batch);
|
||||||
spin_lock(&BTRFS_I(inode)->lock);
|
spin_lock(&inode->lock);
|
||||||
BTRFS_I(inode)->delalloc_bytes -= len;
|
inode->delalloc_bytes -= len;
|
||||||
if (do_list && BTRFS_I(inode)->delalloc_bytes == 0 &&
|
if (do_list && inode->delalloc_bytes == 0 &&
|
||||||
test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
|
test_bit(BTRFS_INODE_IN_DELALLOC_LIST,
|
||||||
&BTRFS_I(inode)->runtime_flags))
|
&inode->runtime_flags))
|
||||||
btrfs_del_delalloc_inode(root, inode);
|
btrfs_del_delalloc_inode(root, &inode->vfs_inode);
|
||||||
spin_unlock(&BTRFS_I(inode)->lock);
|
spin_unlock(&inode->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user