Commit ae0d22a7 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: migrate insert_inline_extent() to folio interfaces

Since insert_inline_extent() now only accepts a single page, it's much
easier to convert it to use folio interfaces.
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 eb1fa9ab
...@@ -512,7 +512,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -512,7 +512,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode, bool extent_inserted, struct btrfs_inode *inode, bool extent_inserted,
size_t size, size_t compressed_size, size_t size, size_t compressed_size,
int compress_type, int compress_type,
struct page *compressed_page, struct folio *compressed_folio,
bool update_i_size) bool update_i_size)
{ {
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
...@@ -537,12 +537,12 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -537,12 +537,12 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
* The compressed size also needs to be no larger than a sector. * The compressed size also needs to be no larger than a sector.
* That's also why we only need one page as the parameter. * That's also why we only need one page as the parameter.
*/ */
if (compressed_page) if (compressed_folio)
ASSERT(compressed_size <= sectorsize); ASSERT(compressed_size <= sectorsize);
else else
ASSERT(compressed_size == 0); ASSERT(compressed_size == 0);
if (compressed_size && compressed_page) if (compressed_size && compressed_folio)
cur_size = compressed_size; cur_size = compressed_size;
if (!extent_inserted) { if (!extent_inserted) {
...@@ -570,7 +570,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -570,7 +570,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
ptr = btrfs_file_extent_inline_start(ei); ptr = btrfs_file_extent_inline_start(ei);
if (compress_type != BTRFS_COMPRESS_NONE) { if (compress_type != BTRFS_COMPRESS_NONE) {
kaddr = kmap_local_page(compressed_page); kaddr = kmap_local_folio(compressed_folio, 0);
write_extent_buffer(leaf, kaddr, ptr, compressed_size); write_extent_buffer(leaf, kaddr, ptr, compressed_size);
kunmap_local(kaddr); kunmap_local(kaddr);
...@@ -623,7 +623,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans, ...@@ -623,7 +623,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size, static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size,
size_t compressed_size, size_t compressed_size,
int compress_type, int compress_type,
struct page *compressed_page, struct folio *compressed_folio,
bool update_i_size) bool update_i_size)
{ {
struct btrfs_drop_extents_args drop_args = { 0 }; struct btrfs_drop_extents_args drop_args = { 0 };
...@@ -671,7 +671,7 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size, ...@@ -671,7 +671,7 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 size,
ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted, ret = insert_inline_extent(trans, path, inode, drop_args.extent_inserted,
size, compressed_size, compress_type, size, compressed_size, compress_type,
compressed_page, update_i_size); compressed_folio, update_i_size);
if (ret && ret != -ENOSPC) { if (ret && ret != -ENOSPC) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out; goto out;
...@@ -979,7 +979,8 @@ static void compress_file_range(struct btrfs_work *work) ...@@ -979,7 +979,8 @@ static void compress_file_range(struct btrfs_work *work)
} else { } else {
ret = cow_file_range_inline(inode, actual_end, ret = cow_file_range_inline(inode, actual_end,
total_compressed, total_compressed,
compress_type, pages[0], compress_type,
page_folio(pages[0]),
false); false);
} }
if (ret <= 0) { if (ret <= 0) {
...@@ -10463,7 +10464,8 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from, ...@@ -10463,7 +10464,8 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
if (start == 0 && encoded->unencoded_len == encoded->len && if (start == 0 && encoded->unencoded_len == encoded->len &&
encoded->unencoded_offset == 0) { encoded->unencoded_offset == 0) {
ret = cow_file_range_inline(inode, encoded->len, orig_count, ret = cow_file_range_inline(inode, encoded->len, orig_count,
compression, pages[0], true); compression, page_folio(pages[0]),
true);
if (ret <= 0) { if (ret <= 0) {
if (ret == 0) if (ret == 0)
ret = orig_count; ret = orig_count;
......
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