Commit 9fec848b authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: cleanup duplicated parameters related to create_io_em()

Most parameters of create_io_em() can be replaced by the members with
the same name inside btrfs_file_extent.

Do a direct parameters cleanup here.
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e9ea31fb
...@@ -139,9 +139,6 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode, ...@@ -139,9 +139,6 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode,
u64 end, struct writeback_control *wbc, u64 end, struct writeback_control *wbc,
bool pages_dirty); bool pages_dirty);
static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start, static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
u64 len,
u64 disk_num_bytes,
u64 ram_bytes, int compress_type,
const struct btrfs_file_extent *file_extent, const struct btrfs_file_extent *file_extent,
int type); int type);
...@@ -1208,13 +1205,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk, ...@@ -1208,13 +1205,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
file_extent.offset = 0; file_extent.offset = 0;
file_extent.compression = async_extent->compress_type; file_extent.compression = async_extent->compress_type;
em = create_io_em(inode, start, em = create_io_em(inode, start, &file_extent, BTRFS_ORDERED_COMPRESSED);
async_extent->ram_size, /* len */
ins.offset, /* orig_block_len */
async_extent->ram_size, /* ram_bytes */
async_extent->compress_type,
&file_extent,
BTRFS_ORDERED_COMPRESSED);
if (IS_ERR(em)) { if (IS_ERR(em)) {
ret = PTR_ERR(em); ret = PTR_ERR(em);
goto out_free_reserve; goto out_free_reserve;
...@@ -1444,12 +1435,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode, ...@@ -1444,12 +1435,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
lock_extent(&inode->io_tree, start, start + ram_size - 1, lock_extent(&inode->io_tree, start, start + ram_size - 1,
&cached); &cached);
em = create_io_em(inode, start, ins.offset, /* len */ em = create_io_em(inode, start, &file_extent, BTRFS_ORDERED_REGULAR);
ins.offset, /* orig_block_len */
ram_size, /* ram_bytes */
BTRFS_COMPRESS_NONE, /* compress_type */
&file_extent,
BTRFS_ORDERED_REGULAR /* type */);
if (IS_ERR(em)) { if (IS_ERR(em)) {
unlock_extent(&inode->io_tree, start, unlock_extent(&inode->io_tree, start,
start + ram_size - 1, &cached); start + ram_size - 1, &cached);
...@@ -2166,12 +2152,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode, ...@@ -2166,12 +2152,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
if (is_prealloc) { if (is_prealloc) {
struct extent_map *em; struct extent_map *em;
em = create_io_em(inode, cur_offset, em = create_io_em(inode, cur_offset, &nocow_args.file_extent,
nocow_args.file_extent.num_bytes,
nocow_args.file_extent.disk_num_bytes,
nocow_args.file_extent.ram_bytes,
BTRFS_COMPRESS_NONE,
&nocow_args.file_extent,
BTRFS_ORDERED_PREALLOC); BTRFS_ORDERED_PREALLOC);
if (IS_ERR(em)) { if (IS_ERR(em)) {
unlock_extent(&inode->io_tree, cur_offset, unlock_extent(&inode->io_tree, cur_offset,
...@@ -7034,10 +7015,7 @@ static struct extent_map *btrfs_create_dio_extent(struct btrfs_inode *inode, ...@@ -7034,10 +7015,7 @@ static struct extent_map *btrfs_create_dio_extent(struct btrfs_inode *inode,
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
if (type != BTRFS_ORDERED_NOCOW) { if (type != BTRFS_ORDERED_NOCOW) {
em = create_io_em(inode, start, len, em = create_io_em(inode, start, file_extent, type);
orig_block_len, ram_bytes,
BTRFS_COMPRESS_NONE, /* compress_type */
file_extent, type);
if (IS_ERR(em)) if (IS_ERR(em))
goto out; goto out;
} }
...@@ -7329,9 +7307,6 @@ static int lock_extent_direct(struct inode *inode, u64 lockstart, u64 lockend, ...@@ -7329,9 +7307,6 @@ static int lock_extent_direct(struct inode *inode, u64 lockstart, u64 lockend,
/* The callers of this must take lock_extent() */ /* The callers of this must take lock_extent() */
static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start, static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
u64 len,
u64 disk_num_bytes,
u64 ram_bytes, int compress_type,
const struct btrfs_file_extent *file_extent, const struct btrfs_file_extent *file_extent,
int type) int type)
{ {
...@@ -7353,25 +7328,25 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start, ...@@ -7353,25 +7328,25 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
switch (type) { switch (type) {
case BTRFS_ORDERED_PREALLOC: case BTRFS_ORDERED_PREALLOC:
/* We're only referring part of a larger preallocated extent. */ /* We're only referring part of a larger preallocated extent. */
ASSERT(len <= ram_bytes); ASSERT(file_extent->num_bytes <= file_extent->ram_bytes);
break; break;
case BTRFS_ORDERED_REGULAR: case BTRFS_ORDERED_REGULAR:
/* COW results a new extent matching our file extent size. */ /* COW results a new extent matching our file extent size. */
ASSERT(disk_num_bytes == len); ASSERT(file_extent->disk_num_bytes == file_extent->num_bytes);
ASSERT(ram_bytes == len); ASSERT(file_extent->ram_bytes == file_extent->num_bytes);
/* Since it's a new extent, we should not have any offset. */ /* Since it's a new extent, we should not have any offset. */
ASSERT(file_extent->offset == 0); ASSERT(file_extent->offset == 0);
break; break;
case BTRFS_ORDERED_COMPRESSED: case BTRFS_ORDERED_COMPRESSED:
/* Must be compressed. */ /* Must be compressed. */
ASSERT(compress_type != BTRFS_COMPRESS_NONE); ASSERT(file_extent->compression != BTRFS_COMPRESS_NONE);
/* /*
* Encoded write can make us to refer to part of the * Encoded write can make us to refer to part of the
* uncompressed extent. * uncompressed extent.
*/ */
ASSERT(len <= ram_bytes); ASSERT(file_extent->num_bytes <= file_extent->ram_bytes);
break; break;
} }
...@@ -7380,15 +7355,15 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start, ...@@ -7380,15 +7355,15 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
em->start = start; em->start = start;
em->len = len; em->len = file_extent->num_bytes;
em->disk_bytenr = file_extent->disk_bytenr; em->disk_bytenr = file_extent->disk_bytenr;
em->disk_num_bytes = disk_num_bytes; em->disk_num_bytes = file_extent->disk_num_bytes;
em->ram_bytes = ram_bytes; em->ram_bytes = file_extent->ram_bytes;
em->generation = -1; em->generation = -1;
em->offset = file_extent->offset; em->offset = file_extent->offset;
em->flags |= EXTENT_FLAG_PINNED; em->flags |= EXTENT_FLAG_PINNED;
if (type == BTRFS_ORDERED_COMPRESSED) if (type == BTRFS_ORDERED_COMPRESSED)
extent_map_set_compression(em, compress_type); extent_map_set_compression(em, file_extent->compression);
ret = btrfs_replace_extent_map_range(inode, em, true); ret = btrfs_replace_extent_map_range(inode, em, true);
if (ret) { if (ret) {
...@@ -10306,9 +10281,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from, ...@@ -10306,9 +10281,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
file_extent.ram_bytes = ram_bytes; file_extent.ram_bytes = ram_bytes;
file_extent.offset = encoded->unencoded_offset; file_extent.offset = encoded->unencoded_offset;
file_extent.compression = compression; file_extent.compression = compression;
em = create_io_em(inode, start, num_bytes, em = create_io_em(inode, start, &file_extent, BTRFS_ORDERED_COMPRESSED);
ins.offset, ram_bytes, compression,
&file_extent, BTRFS_ORDERED_COMPRESSED);
if (IS_ERR(em)) { if (IS_ERR(em)) {
ret = PTR_ERR(em); ret = PTR_ERR(em);
goto out_free_reserved; goto out_free_reserved;
......
...@@ -264,7 +264,7 @@ static void insert_ordered_extent(struct btrfs_ordered_extent *entry) ...@@ -264,7 +264,7 @@ static void insert_ordered_extent(struct btrfs_ordered_extent *entry)
*/ */
struct btrfs_ordered_extent *btrfs_alloc_ordered_extent( struct btrfs_ordered_extent *btrfs_alloc_ordered_extent(
struct btrfs_inode *inode, u64 file_offset, struct btrfs_inode *inode, u64 file_offset,
struct btrfs_file_extent *file_extent, unsigned long flags) const struct btrfs_file_extent *file_extent, unsigned long flags)
{ {
struct btrfs_ordered_extent *entry; struct btrfs_ordered_extent *entry;
......
...@@ -186,7 +186,7 @@ struct btrfs_file_extent { ...@@ -186,7 +186,7 @@ struct btrfs_file_extent {
struct btrfs_ordered_extent *btrfs_alloc_ordered_extent( struct btrfs_ordered_extent *btrfs_alloc_ordered_extent(
struct btrfs_inode *inode, u64 file_offset, struct btrfs_inode *inode, u64 file_offset,
struct btrfs_file_extent *file_extent, unsigned long flags); const struct btrfs_file_extent *file_extent, unsigned long flags);
void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry, void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
struct btrfs_ordered_sum *sum); struct btrfs_ordered_sum *sum);
struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *inode, struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *inode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment