Last active
April 29, 2025 19:59
-
-
Save arakashic/3de54ecf8f355f315e45632ea964fef0 to your computer and use it in GitHub Desktop.
qzfs-fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From d6f5b65362a5d2471c8b8fb7509fda85e43d20dd Mon Sep 17 00:00:00 2001 | |
From: Yanfei Guo <[email protected]> | |
Date: Fri, 18 Apr 2025 19:48:19 +0000 | |
Subject: [PATCH] qat: wait for in-flight req to complete before remove session | |
reqs in session may be still in-flight after callback returns. | |
This results in session remove fail with message "There are %lu | |
requests pending". Adding a small loop to wait for the completion | |
of in-flight requests. | |
--- | |
module/os/linux/zfs/qat_crypt.c | 30 ++++++++++++++++++++++++++++-- | |
1 file changed, 28 insertions(+), 2 deletions(-) | |
diff --git a/module/os/linux/zfs/qat_crypt.c b/module/os/linux/zfs/qat_crypt.c | |
index 27965a36d2d7..7d22362d0d6d 100644 | |
--- a/module/os/linux/zfs/qat_crypt.c | |
+++ b/module/os/linux/zfs/qat_crypt.c | |
@@ -38,6 +38,11 @@ | |
#include "lac/cpa_cy_common.h" | |
#include <sys/qat.h> | |
+#define CY_API_VERSION_AT_LEAST(major, minor) \ | |
+ (CPA_CY_API_VERSION_NUM_MAJOR > (major) || \ | |
+ (CPA_CY_API_VERSION_NUM_MAJOR == (major) && \ | |
+ CPA_CY_API_VERSION_NUM_MINOR >= (minor))) | |
+ | |
/* | |
* Max instances in a QAT device, each instance is a channel to submit | |
* jobs to QAT hardware, this is only for pre-allocating instances | |
@@ -73,6 +78,17 @@ symcallback(void *p_callback, CpaStatus status, const CpaCySymOp operation, | |
} | |
} | |
+static void sym_session_wait_inflight_req(CpaCySymSessionCtx pSessionCtx) | |
+{ | |
+#if CY_API_VERSION_AT_LEAST(2, 2) | |
+ CpaBoolean sessionInUse = CPA_FALSE; | |
+ | |
+ do { | |
+ cpaCySymSessionInUse(pSessionCtx, &sessionInUse); | |
+ } while (sessionInUse == CPA_TRUE); | |
+#endif | |
+} | |
+ | |
boolean_t | |
qat_crypt_use_accel(size_t s_len) | |
{ | |
@@ -446,12 +462,17 @@ fail: | |
if (status != CPA_STATUS_SUCCESS) | |
QAT_STAT_BUMP(crypt_fails); | |
+ sym_session_wait_inflight_req(cy_session_ctx); | |
+ | |
for (i = 0; i < in_page_num; i++) | |
kunmap(in_pages[i]); | |
for (i = 0; i < out_page_num; i++) | |
kunmap(out_pages[i]); | |
- cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ status = cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ while (status == CPA_STATUS_RETRY) { | |
+ status = cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ } | |
if (aad_len > 0) | |
QAT_PHYS_CONTIG_FREE(op_data.pAdditionalAuthData); | |
QAT_PHYS_CONTIG_FREE(op_data.pIv); | |
@@ -564,10 +585,15 @@ fail: | |
if (status != CPA_STATUS_SUCCESS) | |
QAT_STAT_BUMP(cksum_fails); | |
+ sym_session_wait_inflight_req(cy_session_ctx); | |
+ | |
for (i = 0; i < page_num; i++) | |
kunmap(in_pages[i]); | |
- cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ status = cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ while (status == CPA_STATUS_RETRY) { | |
+ status = cpaCySymRemoveSession(cy_inst_handle, cy_session_ctx); | |
+ } | |
QAT_PHYS_CONTIG_FREE(digest_buffer); | |
QAT_PHYS_CONTIG_FREE(src_buffer_list.pPrivateMetaData); | |
QAT_PHYS_CONTIG_FREE(cy_session_ctx); | |
-- | |
2.39.5 (Apple Git-154) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment