Commit 70dd062e authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Fix btree_trans leak in bch2_readahead()

parent 5fa42144
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -257,7 +257,6 @@ void bch2_readahead(struct readahead_control *ractl)
	struct bch_inode_info *inode = to_bch_ei(ractl->mapping->host);
	struct bch_fs *c = inode->v.i_sb->s_fs_info;
	struct bch_io_opts opts;
	struct btree_trans *trans = bch2_trans_get(c);
	struct folio *folio;
	struct readpages_iter readpages_iter;

@@ -269,6 +268,7 @@ void bch2_readahead(struct readahead_control *ractl)

	bch2_pagecache_add_get(inode);

	struct btree_trans *trans = bch2_trans_get(c);
	while ((folio = readpage_iter_peek(&readpages_iter))) {
		unsigned n = min_t(unsigned,
				   readpages_iter.folios.nr -
@@ -289,10 +289,10 @@ void bch2_readahead(struct readahead_control *ractl)
			   &readpages_iter);
		bch2_trans_unlock(trans);
	}
	bch2_trans_put(trans);

	bch2_pagecache_add_put(inode);

	bch2_trans_put(trans);
	darray_exit(&readpages_iter.folios);
}