Better control the thread pool size when mounting datasets
commitb64afa41d56e98b5817aaf14c7deb0fa7e2142fb
authorAlan Somers <asomers@FreeBSD.org>
Wed, 8 May 2024 16:01:22 +0000 (8 10:01 -0600)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 14 May 2024 16:36:21 +0000 (14 09:36 -0700)
tree20c4f5913850f9d4122cac7f05d07af214527a65
parenteced2e2f1e56b54753702da52a88fccbe73b3dcb
Better control the thread pool size when mounting datasets

Ever since a10d50f999, ZFS has mounted file systems in parallel when
importing a pool.  It uses a fixed size of 512 for the thread pool.  But
since c183d164aa1, it has also imported pools in parallel.  So the total
number of threads at one time is 513 * npools + 1.  That can easily
exceed the system's limit on the number of threads per process, which
will cause one or more pools to be unable to allocate any worker
threads, forcing them to fallback to slow serial mounting .  To
forestall that, manage the threadpool size in /sbin/zpool, not libzfs.
Use the same size (512), but divided by the number of pools.

This is a backwards-incompatible change to the libzfs abi.

Sponsored by: Axcient
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Wilson <gwilson@delphix.com>
Signed-off-by: Alan Somers <asomers@FreeBSD.org>
Closes #16178
cmd/zed/agents/zfs_mod.c
cmd/zfs/zfs_main.c
cmd/zpool/zpool_main.c
include/libzfs.h
lib/libzfs/libzfs.abi
lib/libzfs/libzfs_mount.c