Whamcloud - gitweb
LU-12299 libcfs: fix panic for too large cpu partions 32/37332/3
authorWang Shilong <wshilong@ddn.com>
Wed, 15 May 2019 01:52:37 +0000 (09:52 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 6 Apr 2020 21:16:53 +0000 (21:16 +0000)
commit77620a096ce75578069af666278a831ad5d0c446
treeb949af629998f67f312a74596e5c14b8d4b4c6e6
parentc0a877ab3b049266042299a438d8d010ce3ce605
LU-12299 libcfs: fix panic for too large cpu partions

If cpu partions larger than online cpus, following calcuation
will be 0:

num = num_online_cpus() / ncpt;

And it will trigger following panic in cfs_cpt_choose_ncpus()

LASSERT(number > 0);

We actually did not support this, instead of panic
it, return failure is better.

Also fix a invalid pointer access if we failed to init @cfs_cpt_table,
as it will be converted to ERR_PTR() if error happen.

Lustre-change: https://review.whamcloud.com/34864
Lustre-commit: 77771ff24c03a59fc96a7f41199a6b73530a418a

Change-Id: I49daadd8f0c7d22aa78d08248d8c085781740768
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/37332
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/libcfs/libcfs_cpu.c