module/crypto: enhance recent session optimization

When we moved to shared session a limitation of one crypto
volume was accidnetally introduced. Add a limit to keep the
session pool size down and print debug message when its hit.

Signed-off-by: paul luse <paul.e.luse@intel.com>
Change-Id: Ic55efd554f37c4f44149edfbfe037420d8d61ce6
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474264
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
paul luse 2019-11-14 15:43:40 +00:00 committed by Tomasz Zawadzki
parent f209b343b6
commit 487eb66e24

View File

@ -106,8 +106,10 @@ static pthread_mutex_t g_device_qp_lock = PTHREAD_MUTEX_INITIALIZER;
*/ */
#define NUM_MBUFS 32768 #define NUM_MBUFS 32768
#define POOL_CACHE_SIZE 256 #define POOL_CACHE_SIZE 256
#define NUM_SESSIONS 2 #define MAX_CRYPTO_VOLUMES 128
#define NUM_SESSIONS (2 * MAX_CRYPTO_VOLUMES)
#define SESS_MEMPOOL_CACHE_SIZE 0 #define SESS_MEMPOOL_CACHE_SIZE 0
uint8_t g_number_of_claimed_volumes = 0;
/* This is the max number of IOs we can supply to any crypto device QP at one time. /* This is the max number of IOs we can supply to any crypto device QP at one time.
* It can vary between drivers. * It can vary between drivers.
@ -1161,6 +1163,8 @@ vbdev_crypto_destruct(void *ctx)
/* Unregister the io_device. */ /* Unregister the io_device. */
spdk_io_device_unregister(crypto_bdev, _device_unregister_cb); spdk_io_device_unregister(crypto_bdev, _device_unregister_cb);
g_number_of_claimed_volumes--;
return 0; return 0;
} }
@ -1584,6 +1588,13 @@ vbdev_crypto_claim(struct spdk_bdev *bdev)
bool found = false; bool found = false;
int rc = 0; int rc = 0;
if (g_number_of_claimed_volumes >= MAX_CRYPTO_VOLUMES) {
SPDK_DEBUGLOG(SPDK_LOG_CRYPTO, "Reached max number of claimed volumes\n");
rc = -EINVAL;
goto error_vbdev_alloc;
}
g_number_of_claimed_volumes++;
/* Check our list of names from config versus this bdev and if /* Check our list of names from config versus this bdev and if
* there's a match, create the crypto_bdev & bdev accordingly. * there's a match, create the crypto_bdev & bdev accordingly.
*/ */
@ -1760,6 +1771,7 @@ error_alloc_key:
error_bdev_name: error_bdev_name:
free(vbdev); free(vbdev);
error_vbdev_alloc: error_vbdev_alloc:
g_number_of_claimed_volumes--;
return rc; return rc;
} }