Skip to content

Commit 55fd97f

Browse files
author
Kent Overstreet
committed
bcachefs: Use sort_nonatomic() instead of sort()
Fixes "task out to lunch" warnings during recovery on large machines with lots of dirty data in the journal. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent c92896f commit 55fd97f

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

fs/bcachefs/btree_journal_iter.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
644644
*/
645645
static int journal_sort_key_cmp(const void *_l, const void *_r)
646646
{
647-
cond_resched();
648-
649647
const struct journal_key *l = _l;
650648
const struct journal_key *r = _r;
651649

@@ -689,7 +687,8 @@ void bch2_journal_keys_put(struct bch_fs *c)
689687

690688
static void __journal_keys_sort(struct journal_keys *keys)
691689
{
692-
sort(keys->data, keys->nr, sizeof(keys->data[0]), journal_sort_key_cmp, NULL);
690+
sort_nonatomic(keys->data, keys->nr, sizeof(keys->data[0]),
691+
journal_sort_key_cmp, NULL);
693692

694693
cond_resched();
695694

fs/bcachefs/btree_node_scan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ int bch2_scan_for_btree_nodes(struct bch_fs *c)
398398
bch2_print_string_as_lines(KERN_INFO, buf.buf);
399399
}
400400

401-
sort(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_cookie, NULL);
401+
sort_nonatomic(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_cookie, NULL);
402402

403403
dst = 0;
404404
darray_for_each(f->nodes, i) {
@@ -418,7 +418,7 @@ int bch2_scan_for_btree_nodes(struct bch_fs *c)
418418
}
419419
f->nodes.nr = dst;
420420

421-
sort(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_pos, NULL);
421+
sort_nonatomic(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_pos, NULL);
422422

423423
if (0 && c->opts.verbose) {
424424
printbuf_reset(&buf);

fs/bcachefs/btree_write_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
428428
*/
429429
trace_and_count(c, write_buffer_flush_slowpath, trans, slowpath, wb->flushing.keys.nr);
430430

431-
sort(wb->flushing.keys.data,
432-
wb->flushing.keys.nr,
433-
sizeof(wb->flushing.keys.data[0]),
434-
wb_key_seq_cmp, NULL);
431+
sort_nonatomic(wb->flushing.keys.data,
432+
wb->flushing.keys.nr,
433+
sizeof(wb->flushing.keys.data[0]),
434+
wb_key_seq_cmp, NULL);
435435

436436
darray_for_each(wb->flushing.keys, i) {
437437
if (!i->journal_seq)

fs/bcachefs/recovery.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ int bch2_journal_replay(struct bch_fs *c)
389389
* Now, replay any remaining keys in the order in which they appear in
390390
* the journal, unpinning those journal entries as we go:
391391
*/
392-
sort(keys_sorted.data, keys_sorted.nr,
393-
sizeof(keys_sorted.data[0]),
394-
journal_sort_seq_cmp, NULL);
392+
sort_nonatomic(keys_sorted.data, keys_sorted.nr,
393+
sizeof(keys_sorted.data[0]),
394+
journal_sort_seq_cmp, NULL);
395395

396396
darray_for_each(keys_sorted, kp) {
397397
cond_resched();

0 commit comments

Comments
 (0)