Skip to content

Commit e231dbd

Browse files
committed
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
2 parents 70ff1fe + 5197728 commit e231dbd

File tree

7 files changed

+25
-22
lines changed

7 files changed

+25
-22
lines changed

fs/bcachefs/backpointers.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ void bch2_backpointer_to_text(struct printbuf *out, const struct bch_backpointer
6868

6969
void bch2_backpointer_k_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c k)
7070
{
71-
prt_str(out, "bucket=");
72-
bch2_bpos_to_text(out, bp_pos_to_bucket(c, k.k->p));
73-
prt_str(out, " ");
71+
if (bch2_dev_exists2(c, k.k->p.inode)) {
72+
prt_str(out, "bucket=");
73+
bch2_bpos_to_text(out, bp_pos_to_bucket(c, k.k->p));
74+
prt_str(out, " ");
75+
}
7476

7577
bch2_backpointer_to_text(out, bkey_s_c_to_backpointer(k).v);
7678
}

fs/bcachefs/btree_iter.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,9 @@ struct bkey_s_c bch2_btree_iter_peek_upto(struct btree_iter *iter, struct bpos e
21562156
* isn't monotonically increasing before FILTER_SNAPSHOTS, and
21572157
* that's what we check against in extents mode:
21582158
*/
2159-
if (k.k->p.inode > end.inode)
2159+
if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS)
2160+
? bkey_gt(k.k->p, end)
2161+
: k.k->p.inode > end.inode))
21602162
goto end;
21612163

21622164
if (iter->update_path &&

fs/bcachefs/fs-io-buffered.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,6 @@ void bch2_readahead(struct readahead_control *ractl)
303303
darray_exit(&readpages_iter.folios);
304304
}
305305

306-
static void __bchfs_readfolio(struct bch_fs *c, struct bch_read_bio *rbio,
307-
subvol_inum inum, struct folio *folio)
308-
{
309-
bch2_folio_create(folio, __GFP_NOFAIL);
310-
311-
rbio->bio.bi_opf = REQ_OP_READ|REQ_SYNC;
312-
rbio->bio.bi_iter.bi_sector = folio_sector(folio);
313-
BUG_ON(!bio_add_folio(&rbio->bio, folio, folio_size(folio), 0));
314-
315-
bch2_trans_run(c, (bchfs_read(trans, rbio, inum, NULL), 0));
316-
}
317-
318306
static void bch2_read_single_folio_end_io(struct bio *bio)
319307
{
320308
complete(bio->bi_private);
@@ -329,14 +317,21 @@ int bch2_read_single_folio(struct folio *folio, struct address_space *mapping)
329317
int ret;
330318
DECLARE_COMPLETION_ONSTACK(done);
331319

320+
if (!bch2_folio_create(folio, GFP_KERNEL))
321+
return -ENOMEM;
322+
332323
bch2_inode_opts_get(&opts, c, &inode->ei_inode);
333324

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

339-
__bchfs_readfolio(c, rbio, inode_inum(inode), folio);
330+
rbio->bio.bi_opf = REQ_OP_READ|REQ_SYNC;
331+
rbio->bio.bi_iter.bi_sector = folio_sector(folio);
332+
BUG_ON(!bio_add_folio(&rbio->bio, folio, folio_size(folio), 0));
333+
334+
bch2_trans_run(c, (bchfs_read(trans, rbio, inode_inum(inode), NULL), 0));
340335
wait_for_completion(&done);
341336

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

fs/bcachefs/fs-io-direct.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter)
8888
return ret;
8989

9090
shorten = iov_iter_count(iter) - round_up(ret, block_bytes(c));
91+
if (shorten >= iter->count)
92+
shorten = 0;
9193
iter->count -= shorten;
9294

9395
bio = bio_alloc_bioset(NULL,

fs/bcachefs/journal_reclaim.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,11 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx)
892892
journal_seq_pin(j, seq)->devs);
893893
seq++;
894894

895-
spin_unlock(&j->lock);
896-
ret = bch2_mark_replicas(c, &replicas.e);
897-
spin_lock(&j->lock);
895+
if (replicas.e.nr_devs) {
896+
spin_unlock(&j->lock);
897+
ret = bch2_mark_replicas(c, &replicas.e);
898+
spin_lock(&j->lock);
899+
}
898900
}
899901
spin_unlock(&j->lock);
900902
err:

fs/bcachefs/snapshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ static int check_snapshot(struct btree_trans *trans,
728728
return 0;
729729

730730
memset(&s, 0, sizeof(s));
731-
memcpy(&s, k.v, bkey_val_bytes(k.k));
731+
memcpy(&s, k.v, min(sizeof(s), bkey_val_bytes(k.k)));
732732

733733
id = le32_to_cpu(s.parent);
734734
if (id) {

fs/bcachefs/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int bch2_save_backtrace(bch_stacktrace *stack, struct task_struct *task, unsigne
289289
do {
290290
nr_entries = stack_trace_save_tsk(task, stack->data, stack->size, skipnr + 1);
291291
} while (nr_entries == stack->size &&
292-
!(ret = darray_make_room(stack, stack->size * 2)));
292+
!(ret = darray_make_room_gfp(stack, stack->size * 2, gfp)));
293293

294294
stack->nr = nr_entries;
295295
up_read(&task->signal->exec_update_lock);

0 commit comments

Comments
 (0)