static void btrfs_free_compressed_pages(struct compressed_bio *cb)
{
for (unsigned int i = 0; i < cb->nr_pages; i++)
- btrfs_free_compr_page(cb->compressed_pages[i]);
+ btrfs_free_compr_folio(page_folio(cb->compressed_pages[i]));
kfree(cb->compressed_pages);
}
/*
* Common wrappers for page allocation from compression wrappers
*/
-struct page *btrfs_alloc_compr_page(void)
+struct folio *btrfs_alloc_compr_folio(void)
{
- struct page *page = NULL;
+ struct folio *folio = NULL;
spin_lock(&compr_pool.lock);
if (compr_pool.count > 0) {
- page = list_first_entry(&compr_pool.list, struct page, lru);
- list_del_init(&page->lru);
+ folio = list_first_entry(&compr_pool.list, struct folio, lru);
+ list_del_init(&folio->lru);
compr_pool.count--;
}
spin_unlock(&compr_pool.lock);
- if (page)
- return page;
+ if (folio)
+ return folio;
- return alloc_page(GFP_NOFS);
+ return folio_alloc(GFP_NOFS, 0);
}
-void btrfs_free_compr_page(struct page *page)
+void btrfs_free_compr_folio(struct folio *folio)
{
bool do_free = false;
if (compr_pool.count > compr_pool.thresh) {
do_free = true;
} else {
- list_add(&page->lru, &compr_pool.list);
+ list_add(&folio->lru, &compr_pool.list);
compr_pool.count++;
}
spin_unlock(&compr_pool.lock);
if (!do_free)
return;
- ASSERT(page_ref_count(page) == 1);
- put_page(page);
+ ASSERT(folio_ref_count(folio) == 1);
+ folio_put(folio);
}
static void end_bbio_comprssed_read(struct btrfs_bio *bbio)
unsigned int btrfs_compress_str2level(unsigned int type, const char *str);
-struct page *btrfs_alloc_compr_page(void);
-void btrfs_free_compr_page(struct page *page);
+struct folio *btrfs_alloc_compr_folio(void);
+void btrfs_free_compr_folio(struct folio *folio);
enum btrfs_compression_type {
BTRFS_COMPRESS_NONE = 0,
if (pages) {
for (i = 0; i < nr_pages; i++) {
WARN_ON(pages[i]->mapping);
- btrfs_free_compr_page(pages[i]);
+ btrfs_free_compr_folio(page_folio(pages[i]));
}
kfree(pages);
}
for (i = 0; i < async_extent->nr_pages; i++) {
WARN_ON(async_extent->pages[i]->mapping);
- btrfs_free_compr_page(async_extent->pages[i]);
+ btrfs_free_compr_folio(page_folio(async_extent->pages[i]));
}
kfree(async_extent->pages);
async_extent->nr_pages = 0;
cur_page = out_pages[*cur_out / PAGE_SIZE];
/* Allocate a new page */
if (!cur_page) {
- cur_page = btrfs_alloc_compr_page();
+ cur_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (!cur_page)
return -ENOMEM;
out_pages[*cur_out / PAGE_SIZE] = cur_page;
cur_page = out_pages[*cur_out / PAGE_SIZE];
/* Allocate a new page */
if (!cur_page) {
- cur_page = btrfs_alloc_compr_page();
+ cur_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (!cur_page)
return -ENOMEM;
out_pages[*cur_out / PAGE_SIZE] = cur_page;
workspace->strm.total_in = 0;
workspace->strm.total_out = 0;
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;
ret = -E2BIG;
goto out;
}
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;
ret = -E2BIG;
goto out;
}
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;
workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE);
/* Allocate and map in the output buffer */
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;
ret = -E2BIG;
goto out;
}
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;
ret = -E2BIG;
goto out;
}
- out_page = btrfs_alloc_compr_page();
+ out_page = folio_page(btrfs_alloc_compr_folio(), 0);
if (out_page == NULL) {
ret = -ENOMEM;
goto out;