Skip to content

Commit

Permalink
btrfs: make extent_clear_unlock_delalloc take btrfs_inode
Browse files Browse the repository at this point in the history
It has one VFS and 1 btrfs inode usages but converting it to btrfs_inode
interface will allow seamless conversion of its callers.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Nikolay Borisov authored and David Sterba committed Jul 27, 2020
1 parent 4b67c11 commit ad7ff17
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
7 changes: 3 additions & 4 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2018,15 +2018,14 @@ static int __process_pages_contig(struct address_space *mapping,
return err;
}

void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
struct page *locked_page,
unsigned clear_bits,
unsigned long page_ops)
{
clear_extent_bit(&BTRFS_I(inode)->io_tree, start, end, clear_bits, 1, 0,
NULL);
clear_extent_bit(&inode->io_tree, start, end, clear_bits, 1, 0, NULL);

__process_pages_contig(inode->i_mapping, locked_page,
__process_pages_contig(inode->vfs_inode.i_mapping, locked_page,
start >> PAGE_SHIFT, end >> PAGE_SHIFT,
page_ops, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void clear_extent_buffer_uptodate(struct extent_buffer *eb);
int extent_buffer_under_io(const struct extent_buffer *eb);
void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end);
void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end);
void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
struct page *locked_page,
unsigned bits_to_clear,
unsigned long page_ops);
Expand Down
29 changes: 16 additions & 13 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ static noinline int compress_file_range(struct async_chunk *async_chunk)
* our outstanding extent for clearing delalloc for this
* range.
*/
extent_clear_unlock_delalloc(inode, start, end, NULL,
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
NULL,
clear_flags,
PAGE_UNLOCK |
PAGE_CLEAR_DIRTY |
Expand Down Expand Up @@ -878,7 +879,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
/*
* clear dirty, set writeback and unlock the pages.
*/
extent_clear_unlock_delalloc(inode, async_extent->start,
extent_clear_unlock_delalloc(BTRFS_I(inode), async_extent->start,
async_extent->start +
async_extent->ram_size - 1,
NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
Expand All @@ -900,7 +901,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
btrfs_writepage_endio_finish_ordered(p, start, end, 0);

p->mapping = NULL;
extent_clear_unlock_delalloc(inode, start, end,
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
NULL, 0,
PAGE_END_WRITEBACK |
PAGE_SET_ERROR);
Expand All @@ -915,7 +916,7 @@ static noinline void submit_compressed_extents(struct async_chunk *async_chunk)
btrfs_dec_block_group_reservations(fs_info, ins.objectid);
btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
out_free:
extent_clear_unlock_delalloc(inode, async_extent->start,
extent_clear_unlock_delalloc(BTRFS_I(inode), async_extent->start,
async_extent->start +
async_extent->ram_size - 1,
NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
Expand Down Expand Up @@ -1017,7 +1018,8 @@ static noinline int cow_file_range(struct inode *inode,
* our outstanding extent for clearing delalloc for this
* range.
*/
extent_clear_unlock_delalloc(inode, start, end, NULL,
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
NULL,
EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
Expand Down Expand Up @@ -1115,7 +1117,7 @@ static noinline int cow_file_range(struct inode *inode,
page_ops = unlock ? PAGE_UNLOCK : 0;
page_ops |= PAGE_SET_PRIVATE2;

extent_clear_unlock_delalloc(inode, start,
extent_clear_unlock_delalloc(BTRFS_I(inode), start,
start + ram_size - 1,
locked_page,
EXTENT_LOCKED | EXTENT_DELALLOC,
Expand Down Expand Up @@ -1160,7 +1162,7 @@ static noinline int cow_file_range(struct inode *inode,
* it the flag EXTENT_CLEAR_DATA_RESV.
*/
if (extent_reserved) {
extent_clear_unlock_delalloc(inode, start,
extent_clear_unlock_delalloc(BTRFS_I(inode), start,
start + cur_alloc_size - 1,
locked_page,
clear_bits,
Expand All @@ -1169,7 +1171,7 @@ static noinline int cow_file_range(struct inode *inode,
if (start >= end)
goto out;
}
extent_clear_unlock_delalloc(inode, start, end, locked_page,
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end, locked_page,
clear_bits | EXTENT_CLEAR_DATA_RESV,
page_ops);
goto out;
Expand Down Expand Up @@ -1277,8 +1279,8 @@ static int cow_file_range_async(struct inode *inode,
PAGE_SET_WRITEBACK | PAGE_END_WRITEBACK |
PAGE_SET_ERROR;

extent_clear_unlock_delalloc(inode, start, end, locked_page,
clear_bits, page_ops);
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
locked_page, clear_bits, page_ops);
return -ENOMEM;
}

Expand Down Expand Up @@ -1468,7 +1470,8 @@ static noinline int run_delalloc_nocow(struct inode *inode,

path = btrfs_alloc_path();
if (!path) {
extent_clear_unlock_delalloc(inode, start, end, locked_page,
extent_clear_unlock_delalloc(BTRFS_I(inode), start, end,
locked_page,
EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DO_ACCOUNTING |
EXTENT_DEFRAG, PAGE_UNLOCK |
Expand Down Expand Up @@ -1746,7 +1749,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
ret = btrfs_reloc_clone_csums(BTRFS_I(inode), cur_offset,
num_bytes);

extent_clear_unlock_delalloc(inode, cur_offset,
extent_clear_unlock_delalloc(BTRFS_I(inode), cur_offset,
cur_offset + num_bytes - 1,
locked_page, EXTENT_LOCKED |
EXTENT_DELALLOC |
Expand Down Expand Up @@ -1783,7 +1786,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
btrfs_dec_nocow_writers(fs_info, disk_bytenr);

if (ret && cur_offset < end)
extent_clear_unlock_delalloc(inode, cur_offset, end,
extent_clear_unlock_delalloc(BTRFS_I(inode), cur_offset, end,
locked_page, EXTENT_LOCKED |
EXTENT_DELALLOC | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
Expand Down

0 comments on commit ad7ff17

Please sign in to comment.