Commit 55fd97fb authored by Kent Overstreet's avatar Kent Overstreet
Browse files

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c92896ff
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -644,8 +644,6 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
 */
static int journal_sort_key_cmp(const void *_l, const void *_r)
{
	cond_resched();

	const struct journal_key *l = _l;
	const struct journal_key *r = _r;

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

static void __journal_keys_sort(struct journal_keys *keys)
{
	sort(keys->data, keys->nr, sizeof(keys->data[0]), journal_sort_key_cmp, NULL);
	sort_nonatomic(keys->data, keys->nr, sizeof(keys->data[0]),
		       journal_sort_key_cmp, NULL);

	cond_resched();

+2 −2
Original line number Diff line number Diff line
@@ -398,7 +398,7 @@ int bch2_scan_for_btree_nodes(struct bch_fs *c)
		bch2_print_string_as_lines(KERN_INFO, buf.buf);
	}

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

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

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

	if (0 && c->opts.verbose) {
		printbuf_reset(&buf);
+4 −4
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
		 */
		trace_and_count(c, write_buffer_flush_slowpath, trans, slowpath, wb->flushing.keys.nr);

		sort(wb->flushing.keys.data,
		sort_nonatomic(wb->flushing.keys.data,
			       wb->flushing.keys.nr,
			       sizeof(wb->flushing.keys.data[0]),
			       wb_key_seq_cmp, NULL);
+3 −3
Original line number Diff line number Diff line
@@ -389,7 +389,7 @@ int bch2_journal_replay(struct bch_fs *c)
	 * Now, replay any remaining keys in the order in which they appear in
	 * the journal, unpinning those journal entries as we go:
	 */
	sort(keys_sorted.data, keys_sorted.nr,
	sort_nonatomic(keys_sorted.data, keys_sorted.nr,
		       sizeof(keys_sorted.data[0]),
		       journal_sort_seq_cmp, NULL);