Commit 01b69bf9 authored by Goldwyn Rodrigues's avatar Goldwyn Rodrigues Committed by David Sterba

btrfs: convert put_file_data() to folios

Use folio instead of page in put_file_data(). Add a warning in case
higher order folio is found, this will be implemented in the future.
Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent a16c2c48
...@@ -5274,10 +5274,11 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len) ...@@ -5274,10 +5274,11 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
{ {
struct btrfs_root *root = sctx->send_root; struct btrfs_root *root = sctx->send_root;
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct page *page; struct folio *folio;
pgoff_t index = offset >> PAGE_SHIFT; pgoff_t index = offset >> PAGE_SHIFT;
pgoff_t last_index; pgoff_t last_index;
unsigned pg_offset = offset_in_page(offset); unsigned pg_offset = offset_in_page(offset);
struct address_space *mapping = sctx->cur_inode->i_mapping;
int ret; int ret;
ret = put_data_header(sctx, len); ret = put_data_header(sctx, len);
...@@ -5290,44 +5291,44 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len) ...@@ -5290,44 +5291,44 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
unsigned cur_len = min_t(unsigned, len, unsigned cur_len = min_t(unsigned, len,
PAGE_SIZE - pg_offset); PAGE_SIZE - pg_offset);
page = find_lock_page(sctx->cur_inode->i_mapping, index); folio = filemap_lock_folio(mapping, index);
if (!page) { if (IS_ERR(folio)) {
page_cache_sync_readahead(sctx->cur_inode->i_mapping, page_cache_sync_readahead(mapping,
&sctx->ra, NULL, index, &sctx->ra, NULL, index,
last_index + 1 - index); last_index + 1 - index);
page = find_or_create_page(sctx->cur_inode->i_mapping, folio = filemap_grab_folio(mapping, index);
index, GFP_KERNEL); if (IS_ERR(folio)) {
if (!page) { ret = PTR_ERR(folio);
ret = -ENOMEM;
break; break;
} }
} }
if (PageReadahead(page)) WARN_ON(folio_order(folio));
page_cache_async_readahead(sctx->cur_inode->i_mapping,
&sctx->ra, NULL, page_folio(page), if (folio_test_readahead(folio))
page_cache_async_readahead(mapping, &sctx->ra, NULL, folio,
index, last_index + 1 - index); index, last_index + 1 - index);
if (!PageUptodate(page)) { if (!folio_test_uptodate(folio)) {
btrfs_read_folio(NULL, page_folio(page)); btrfs_read_folio(NULL, folio);
lock_page(page); folio_lock(folio);
if (!PageUptodate(page)) { if (!folio_test_uptodate(folio)) {
unlock_page(page); folio_unlock(folio);
btrfs_err(fs_info, btrfs_err(fs_info,
"send: IO error at offset %llu for inode %llu root %llu", "send: IO error at offset %llu for inode %llu root %llu",
page_offset(page), sctx->cur_ino, folio_pos(folio), sctx->cur_ino,
sctx->send_root->root_key.objectid); sctx->send_root->root_key.objectid);
put_page(page); folio_put(folio);
ret = -EIO; ret = -EIO;
break; break;
} }
} }
memcpy_from_page(sctx->send_buf + sctx->send_size, page, memcpy_from_folio(sctx->send_buf + sctx->send_size, folio,
pg_offset, cur_len); pg_offset, cur_len);
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
index++; index++;
pg_offset = 0; pg_offset = 0;
len -= cur_len; len -= cur_len;
......
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