Skip to content

Commit

Permalink
bcachefs: Kill __GFP_NOFAIL in buffered read path
Browse files Browse the repository at this point in the history
Recently, we fixed our __GFP_NOFAIL usage in the readahead path, but the
easy one in read_single_folio() (where wa can return an error) was
missed - oops.

Fixes:
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Feb 25, 2024
1 parent 1f62622 commit 04fee68
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions fs/bcachefs/fs-io-buffered.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,6 @@ void bch2_readahead(struct readahead_control *ractl)
darray_exit(&readpages_iter.folios);
}

static void __bchfs_readfolio(struct bch_fs *c, struct bch_read_bio *rbio,
subvol_inum inum, struct folio *folio)
{
bch2_folio_create(folio, __GFP_NOFAIL);

rbio->bio.bi_opf = REQ_OP_READ|REQ_SYNC;
rbio->bio.bi_iter.bi_sector = folio_sector(folio);
BUG_ON(!bio_add_folio(&rbio->bio, folio, folio_size(folio), 0));

bch2_trans_run(c, (bchfs_read(trans, rbio, inum, NULL), 0));
}

static void bch2_read_single_folio_end_io(struct bio *bio)
{
complete(bio->bi_private);
Expand All @@ -329,14 +317,21 @@ int bch2_read_single_folio(struct folio *folio, struct address_space *mapping)
int ret;
DECLARE_COMPLETION_ONSTACK(done);

if (!bch2_folio_create(folio, GFP_KERNEL))
return -ENOMEM;

bch2_inode_opts_get(&opts, c, &inode->ei_inode);

rbio = rbio_init(bio_alloc_bioset(NULL, 1, REQ_OP_READ, GFP_KERNEL, &c->bio_read),
opts);
rbio->bio.bi_private = &done;
rbio->bio.bi_end_io = bch2_read_single_folio_end_io;

__bchfs_readfolio(c, rbio, inode_inum(inode), folio);
rbio->bio.bi_opf = REQ_OP_READ|REQ_SYNC;
rbio->bio.bi_iter.bi_sector = folio_sector(folio);
BUG_ON(!bio_add_folio(&rbio->bio, folio, folio_size(folio), 0));

bch2_trans_run(c, (bchfs_read(trans, rbio, inode_inum(inode), NULL), 0));
wait_for_completion(&done);

ret = blk_status_to_errno(rbio->bio.bi_status);
Expand Down

0 comments on commit 04fee68

Please sign in to comment.