summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/tests.c
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-10-29 13:53:29 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-11-07 22:48:21 +0100
commit9bb33852f5cc145b17d96f3792ff69148a37e1fd (patch)
tree83b07d77213c487a8fed3223da63c3447bd1daff /fs/bcachefs/tests.c
parentbcachefs: add check NULL return of bio_kmalloc in journal_read_bucket (diff)
downloadlinux-9bb33852f5cc145b17d96f3792ff69148a37e1fd.tar.xz
linux-9bb33852f5cc145b17d96f3792ff69148a37e1fd.zip
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: 1c6fdbd8f246 ("bcachefs: Initial commit") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r--fs/bcachefs/tests.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/bcachefs/tests.c b/fs/bcachefs/tests.c
index 315038a0a92d..fb5c1543e52f 100644
--- a/fs/bcachefs/tests.c
+++ b/fs/bcachefs/tests.c
@@ -809,6 +809,11 @@ int bch2_btree_perf_test(struct bch_fs *c, const char *testname,
unsigned i;
u64 time;
+ if (nr == 0 || nr_threads == 0) {
+ pr_err("nr of iterations or threads is not allowed to be 0");
+ return -EINVAL;
+ }
+
atomic_set(&j.ready, nr_threads);
init_waitqueue_head(&j.ready_wait);