mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
btrfs: drop create parameter to btrfs_get_extent()
We only pass this as 1 from __extent_writepage_io(). The parameter basically means "pretend I didn't pass in a page". This is silly since we can simply not pass in the page. Get rid of the parameter from btrfs_get_extent(), and since it's used as a get_extent_t callback, remove it from get_extent_t and btree_get_extent(), neither of which need it. While we're here, let's document btrfs_get_extent(). Signed-off-by: Omar Sandoval <osandov@fb.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f95d713b54
commit
39b07b5d70
9 changed files with 64 additions and 62 deletions
|
@ -4504,7 +4504,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
|
|||
cur_offset = hole_start;
|
||||
while (1) {
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, cur_offset,
|
||||
block_end - cur_offset, 0);
|
||||
block_end - cur_offset);
|
||||
if (IS_ERR(em)) {
|
||||
err = PTR_ERR(em);
|
||||
em = NULL;
|
||||
|
@ -6283,18 +6283,27 @@ static noinline int uncompress_inline(struct btrfs_path *path,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* a bit scary, this does extent mapping from logical file offset to the disk.
|
||||
* the ugly parts come from merging extents from the disk with the in-ram
|
||||
* representation. This gets more complex because of the data=ordered code,
|
||||
* where the in-ram extents might be locked pending data=ordered completion.
|
||||
/**
|
||||
* btrfs_get_extent - Lookup the first extent overlapping a range in a file.
|
||||
* @inode: file to search in
|
||||
* @page: page to read extent data into if the extent is inline
|
||||
* @pg_offset: offset into @page to copy to
|
||||
* @start: file offset
|
||||
* @len: length of range starting at @start
|
||||
*
|
||||
* This also copies inline extents directly into the page.
|
||||
* This returns the first &struct extent_map which overlaps with the given
|
||||
* range, reading it from the B-tree and caching it if necessary. Note that
|
||||
* there may be more extents which overlap the given range after the returned
|
||||
* extent_map.
|
||||
*
|
||||
* If @page is not NULL and the extent is inline, this also reads the extent
|
||||
* data directly into the page and marks the extent up to date in the io_tree.
|
||||
*
|
||||
* Return: ERR_PTR on error, non-NULL extent_map on success.
|
||||
*/
|
||||
struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
|
||||
struct page *page,
|
||||
size_t pg_offset, u64 start, u64 len,
|
||||
int create)
|
||||
struct page *page, size_t pg_offset,
|
||||
u64 start, u64 len)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = inode->root->fs_info;
|
||||
int ret;
|
||||
|
@ -6311,7 +6320,6 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
|
|||
struct extent_map *em = NULL;
|
||||
struct extent_map_tree *em_tree = &inode->extent_tree;
|
||||
struct extent_io_tree *io_tree = &inode->io_tree;
|
||||
const bool new_inline = !page || create;
|
||||
|
||||
read_lock(&em_tree->lock);
|
||||
em = lookup_extent_mapping(em_tree, start, len);
|
||||
|
@ -6434,8 +6442,7 @@ next:
|
|||
goto insert;
|
||||
}
|
||||
|
||||
btrfs_extent_item_to_extent_map(inode, path, item,
|
||||
new_inline, em);
|
||||
btrfs_extent_item_to_extent_map(inode, path, item, !page, em);
|
||||
|
||||
if (extent_type == BTRFS_FILE_EXTENT_REG ||
|
||||
extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
|
||||
|
@ -6447,7 +6454,7 @@ next:
|
|||
size_t extent_offset;
|
||||
size_t copy_size;
|
||||
|
||||
if (new_inline)
|
||||
if (!page)
|
||||
goto out;
|
||||
|
||||
size = btrfs_file_extent_ram_bytes(leaf, item);
|
||||
|
@ -6530,7 +6537,7 @@ struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
|
|||
u64 delalloc_end;
|
||||
int err = 0;
|
||||
|
||||
em = btrfs_get_extent(inode, NULL, 0, start, len, 0);
|
||||
em = btrfs_get_extent(inode, NULL, 0, start, len);
|
||||
if (IS_ERR(em))
|
||||
return em;
|
||||
/*
|
||||
|
@ -7155,7 +7162,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
|
|||
goto err;
|
||||
}
|
||||
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len, 0);
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len);
|
||||
if (IS_ERR(em)) {
|
||||
ret = PTR_ERR(em);
|
||||
goto unlock_err;
|
||||
|
@ -10166,7 +10173,7 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
|
|||
struct btrfs_block_group *bg;
|
||||
u64 len = isize - start;
|
||||
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len, 0);
|
||||
em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len);
|
||||
if (IS_ERR(em)) {
|
||||
ret = PTR_ERR(em);
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue