Commit e231dbd4 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'bcachefs-2024-02-25' of https://evilpiepirate.org/git/bcachefs

Pull bcachefs fixes from Kent Overstreet:
 "Some more mostly boring fixes, but some not

  User reported ones:

   - the BTREE_ITER_FILTER_SNAPSHOTS one fixes a really nasty
     performance bug; user reported an untar initially taking two
     seconds and then ~2 minutes

   - kill a __GFP_NOFAIL in the buffered read path; this was a leftover
     from the trickier fix to kill __GFP_NOFAIL in readahead, where we
     can't return errors (and have to silently truncate the read
     ourselves).

     bcachefs can't use GFP_NOFAIL for folio state unlike iomap based
     filesystems because our folio state is just barely too big, 2MB
     hugepages cause us to exceed the 2 page threshhold for GFP_NOFAIL.

     additionally, the flags argument was just buggy, we weren't
     supplying GFP_KERNEL previously (!)"

* tag 'bcachefs-2024-02-25' of https://evilpiepirate.org/git/bcachefs:
  bcachefs: fix bch2_save_backtrace()
  bcachefs: Fix check_snapshot() memcpy
  bcachefs: Fix bch2_journal_flush_device_pins()
  bcachefs: fix iov_iter count underflow on sub-block dio read
  bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree
  bcachefs: Kill __GFP_NOFAIL in buffered read path
  bcachefs: fix backpointer_to_text() when dev does not exist
parents 70ff1fe6 5197728f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -68,9 +68,11 @@ void bch2_backpointer_to_text(struct printbuf *out, const struct bch_backpointer

void bch2_backpointer_k_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c k)
{
	if (bch2_dev_exists2(c, k.k->p.inode)) {
		prt_str(out, "bucket=");
		bch2_bpos_to_text(out, bp_pos_to_bucket(c, k.k->p));
		prt_str(out, " ");
	}

	bch2_backpointer_to_text(out, bkey_s_c_to_backpointer(k).v);
}
+3 −1
Original line number Diff line number Diff line
@@ -2156,7 +2156,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
		 * isn't monotonically increasing before FILTER_SNAPSHOTS, and
		 * that's what we check against in extents mode:
		 */
		if (k.k->p.inode > end.inode)
		if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS)
			     ? bkey_gt(k.k->p, end)
			     : k.k->p.inode > end.inode))
			goto end;

		if (iter->update_path &&
+8 −13
Original line number Diff line number Diff line
@@ -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);
@@ -329,6 +317,9 @@ 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),
@@ -336,7 +327,11 @@ int bch2_read_single_folio(struct folio *folio, struct address_space *mapping)
	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);
+2 −0
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter)
		return ret;

	shorten = iov_iter_count(iter) - round_up(ret, block_bytes(c));
	if (shorten >= iter->count)
		shorten = 0;
	iter->count -= shorten;

	bio = bio_alloc_bioset(NULL,
+5 −3
Original line number Diff line number Diff line
@@ -892,10 +892,12 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx)
					 journal_seq_pin(j, seq)->devs);
		seq++;

		if (replicas.e.nr_devs) {
			spin_unlock(&j->lock);
			ret = bch2_mark_replicas(c, &replicas.e);
			spin_lock(&j->lock);
		}
	}
	spin_unlock(&j->lock);
err:
	ret = bch2_replicas_gc_end(c, ret);
Loading