Commit 4753bdeb authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Kill GFP_NOFAIL usage in readahead path

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 806ebf2a
...@@ -52,23 +52,20 @@ struct readpages_iter { ...@@ -52,23 +52,20 @@ struct readpages_iter {
static int readpages_iter_init(struct readpages_iter *iter, static int readpages_iter_init(struct readpages_iter *iter,
struct readahead_control *ractl) struct readahead_control *ractl)
{ {
memset(iter, 0, sizeof(*iter)); struct folio *folio;
iter->mapping = ractl->mapping; *iter = (struct readpages_iter) { ractl->mapping };
int ret = bch2_filemap_get_contig_folios_d(iter->mapping, while ((folio = __readahead_folio(ractl))) {
ractl->_index << PAGE_SHIFT, if (!bch2_folio_create(folio, GFP_KERNEL) ||
(ractl->_index + ractl->_nr_pages) << PAGE_SHIFT, darray_push(&iter->folios, folio)) {
0, mapping_gfp_mask(iter->mapping), bch2_folio_release(folio);
&iter->folios); ractl->_nr_pages += folio_nr_pages(folio);
if (ret) ractl->_index -= folio_nr_pages(folio);
return ret; return iter->folios.nr ? 0 : -ENOMEM;
}
darray_for_each(iter->folios, fi) { folio_put(folio);
ractl->_nr_pages -= 1U << folio_order(*fi);
__bch2_folio_create(*fi, __GFP_NOFAIL|GFP_KERNEL);
folio_put(*fi);
folio_put(*fi);
} }
return 0; return 0;
...@@ -270,12 +267,12 @@ void bch2_readahead(struct readahead_control *ractl) ...@@ -270,12 +267,12 @@ void bch2_readahead(struct readahead_control *ractl)
struct btree_trans *trans = bch2_trans_get(c); struct btree_trans *trans = bch2_trans_get(c);
struct folio *folio; struct folio *folio;
struct readpages_iter readpages_iter; struct readpages_iter readpages_iter;
int ret;
bch2_inode_opts_get(&opts, c, &inode->ei_inode); bch2_inode_opts_get(&opts, c, &inode->ei_inode);
ret = readpages_iter_init(&readpages_iter, ractl); int ret = readpages_iter_init(&readpages_iter, ractl);
BUG_ON(ret); if (ret)
return;
bch2_pagecache_add_get(inode); bch2_pagecache_add_get(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