Skip to content

Commit 9bb3385

Browse files
Hongbo LiKent Overstreet
authored andcommitted
bcachefs: check the invalid parameter for perf test
The perf_test does not check the number of iterations and threads when it is zero. If nr_thread is 0, the perf test will keep waiting for wakekup. If iteration is 0, it will cause exception of division by zero. This can be reproduced by: echo "rand_insert 0 1" > /sys/fs/bcachefs/${uuid}/perf_test or echo "rand_insert 1 0" > /sys/fs/bcachefs/${uuid}/perf_test Fixes: 1c6fdbd ("bcachefs: Initial commit") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 93d53f1 commit 9bb3385

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/bcachefs/tests.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ int bch2_btree_perf_test(struct bch_fs *c, const char *testname,
809809
unsigned i;
810810
u64 time;
811811

812+
if (nr == 0 || nr_threads == 0) {
813+
pr_err("nr of iterations or threads is not allowed to be 0");
814+
return -EINVAL;
815+
}
816+
812817
atomic_set(&j.ready, nr_threads);
813818
init_waitqueue_head(&j.ready_wait);
814819

0 commit comments

Comments
 (0)