Commit cf904c8d authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: bch_err_(fn|msg) check if should print

parent e06af207
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1470,7 +1470,6 @@ int bch2_check_alloc_info(struct bch_fs *c)
		bch2_check_bucket_gens_key(trans, &iter, k));
err:
	bch2_trans_put(trans);
	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
+4 −8
Original line number Diff line number Diff line
@@ -393,14 +393,12 @@ int bch2_check_btree_backpointers(struct bch_fs *c)
{
	struct btree_iter iter;
	struct bkey_s_c k;
	int ret;

	ret = bch2_trans_run(c,
	int ret = bch2_trans_run(c,
		for_each_btree_key_commit(trans, iter,
			BTREE_ID_backpointers, POS_MIN, 0, k,
			NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
		  bch2_check_btree_backpointer(trans, &iter, k)));
	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
@@ -769,7 +767,6 @@ int bch2_check_extents_to_backpointers(struct bch_fs *c)
	}
	bch2_trans_put(trans);

	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
@@ -877,7 +874,6 @@ int bch2_check_backpointers_to_extents(struct bch_fs *c)
	}
	bch2_trans_put(trans);

	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
+7 −2
Original line number Diff line number Diff line
@@ -315,15 +315,20 @@ do { \
#define bch_err_inum_offset_ratelimited(c, _inum, _offset, fmt, ...) \
	bch2_print_ratelimited(c, KERN_ERR bch2_fmt_inum_offset(c, _inum, _offset, fmt), ##__VA_ARGS__)

static inline bool should_print_err(int err)
{
	return err && !bch2_err_matches(err, BCH_ERR_transaction_restart);
}

#define bch_err_fn(_c, _ret)						\
do {									\
	if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\
	if (should_print_err(_ret))					\
		bch_err(_c, "%s(): error %s", __func__, bch2_err_str(_ret));\
} while (0)

#define bch_err_msg(_c, _ret, _msg, ...)				\
do {									\
	if (_ret && !bch2_err_matches(_ret, BCH_ERR_transaction_restart))\
	if (should_print_err(_ret))					\
		bch_err(_c, "%s(): error " _msg " %s", __func__,	\
			##__VA_ARGS__, bch2_err_str(_ret));		\
} while (0)
+15 −28
Original line number Diff line number Diff line
@@ -414,10 +414,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
			continue;
		}

		if (ret) {
		bch_err_msg(c, ret, "getting btree node");
		if (ret)
			break;
		}

		ret = btree_repair_node_boundaries(c, b, prev, cur);

@@ -482,10 +481,9 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct
					false);
		ret = PTR_ERR_OR_ZERO(cur);

		if (ret) {
		bch_err_msg(c, ret, "getting btree node");
		if (ret)
			goto err;
		}

		ret = bch2_btree_repair_topology_recurse(trans, cur);
		six_unlock_read(&cur->c.lock);
@@ -707,8 +705,8 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id

		new = kmalloc(bkey_bytes(k->k), GFP_KERNEL);
		if (!new) {
			bch_err_msg(c, ret, "allocating new key");
			ret = -BCH_ERR_ENOMEM_gc_repair_key;
			bch_err_msg(c, ret, "allocating new key");
			goto err;
		}

@@ -834,7 +832,6 @@ static int bch2_gc_mark_key(struct btree_trans *trans, enum btree_id btree_id,
			bch2_mark_key(trans, btree_id, level, old, *k, flags));
fsck_err:
err:
	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
@@ -1068,7 +1065,6 @@ static int bch2_gc_btree_init(struct btree_trans *trans,
fsck_err:
	six_unlock_read(&b->c.lock);

	if (ret < 0)
	bch_err_fn(c, ret);
	printbuf_exit(&buf);
	return ret;
@@ -1105,10 +1101,8 @@ static int bch2_gc_btrees(struct bch_fs *c, bool initial, bool metadata_only)
			: bch2_gc_btree(trans, i, initial, metadata_only);
	}

	if (ret < 0)
		bch_err_fn(c, ret);

	bch2_trans_put(trans);
	bch_err_fn(c, ret);
	return ret;
}

@@ -1304,7 +1298,6 @@ static int bch2_gc_done(struct bch_fs *c,
fsck_err:
	if (ca)
		percpu_ref_put(&ca->ref);
	if (ret)
	bch_err_fn(c, ret);

	percpu_up_write(&c->mark_lock);
@@ -1563,7 +1556,6 @@ static int bch2_gc_alloc_start(struct bch_fs *c, bool metadata_only)
	}));
err:
	bch2_trans_put(trans);
	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
@@ -1659,6 +1651,7 @@ static int bch2_gc_reflink_done(struct bch_fs *c, bool metadata_only)

	c->reflink_gc_nr = 0;
	bch2_trans_put(trans);
	bch_err_fn(c, ret);
	return ret;
}

@@ -1896,8 +1889,6 @@ int bch2_gc(struct bch_fs *c, bool initial, bool metadata_only)
	 * allocator thread - issue wakeup in case they blocked on gc_lock:
	 */
	closure_wake_up(&c->freelist_wait);

	if (ret)
	bch_err_fn(c, ret);
	return ret;
}
@@ -2015,7 +2006,7 @@ int bch2_gc_gens(struct bch_fs *c)
					NULL, NULL,
					BCH_TRANS_COMMIT_no_enospc,
				gc_btree_gens_key(trans, &iter, k));
			if (ret && !bch2_err_matches(ret, EROFS))
			if (!bch2_err_matches(ret, EROFS))
				bch_err_fn(c, ret);
			if (ret)
				goto err;
@@ -2028,7 +2019,7 @@ int bch2_gc_gens(struct bch_fs *c)
			NULL, NULL,
			BCH_TRANS_COMMIT_no_enospc,
		bch2_alloc_write_oldest_gen(trans, &iter, k));
	if (ret && !bch2_err_matches(ret, EROFS))
	if (!bch2_err_matches(ret, EROFS))
		bch_err_fn(c, ret);
	if (ret)
		goto err;
@@ -2058,7 +2049,6 @@ static int bch2_gc_thread(void *arg)
	struct io_clock *clock = &c->io_clock[WRITE];
	unsigned long last = atomic64_read(&clock->now);
	unsigned last_kick = atomic_read(&c->kick_gc);
	int ret;

	set_freezable();

@@ -2098,11 +2088,8 @@ static int bch2_gc_thread(void *arg)
#if 0
		ret = bch2_gc(c, false, false);
#else
		ret = bch2_gc_gens(c);
		bch2_gc_gens(c);
#endif
		if (ret < 0)
			bch_err_fn(c, ret);

		debug_check_no_locks_held();
	}

+2 −3
Original line number Diff line number Diff line
@@ -2054,7 +2054,6 @@ static void async_btree_node_rewrite_work(struct work_struct *work)

	ret = bch2_trans_do(c, NULL, NULL, 0,
		      async_btree_node_rewrite_trans(trans, a));
	if (ret)
	bch_err_fn(c, ret);
	bch2_write_ref_put(c, BCH_WRITE_REF_node_rewrite);
	kfree(a);
@@ -2093,8 +2092,8 @@ void bch2_btree_node_rewrite_async(struct bch_fs *c, struct btree *b)
		}

		ret = bch2_fs_read_write_early(c);
		if (ret) {
		bch_err_msg(c, ret, "going read-write");
		if (ret) {
			kfree(a);
			return;
		}
Loading