From eced2e2f1e56b54753702da52a88fccbe73b3dcb Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 7 May 2024 14:21:31 -0600 Subject: [PATCH] libzfs: Fix mounting datasets under thread limit pressure During parallel zpool import, /sbin/zpool will create a separate thread pool for each pool, used to mount that pool's datasets. If the total thread count exceed's the system's limit on threads per process, then tpool_dispatch may fail. If it does, directly execute the mount operation instead. Sponsored by: Axcient Reviewed-by: Brian Behlendorf Reviewed-by: George Wilson Signed-off-by: Alan Somers Closes #16178 Fixes #16172 --- lib/libzfs/libzfs_mount.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index ec6ebad2f1..3084e05e4d 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -1098,7 +1098,10 @@ zfs_dispatch_mount(libzfs_handle_t *hdl, zfs_handle_t **handles, mnt_param->mnt_func = func; mnt_param->mnt_data = data; - (void) tpool_dispatch(tp, zfs_mount_task, (void*)mnt_param); + if (tpool_dispatch(tp, zfs_mount_task, (void*)mnt_param)) { + /* Could not dispatch to thread pool; execute directly */ + zfs_mount_task((void*)mnt_param); + } } /*