Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/os/freebsd/zfs/crypto_os.c
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | zfs_crypto_dispatch(freebsd_crypt_session_t *session, struct cryptop *crp) | ||||
crp->crp_opaque = session; | crp->crp_opaque = session; | ||||
crp->crp_callback = freebsd_zfs_crypt_done; | crp->crp_callback = freebsd_zfs_crypt_done; | ||||
for (;;) { | for (;;) { | ||||
error = crypto_dispatch(crp); | error = crypto_dispatch(crp); | ||||
if (error) | if (error) | ||||
break; | break; | ||||
mtx_lock(&session->fs_lock); | mtx_lock(&session->fs_lock); | ||||
while (session->fs_done == false) | while (session->fs_done == false) | ||||
msleep(crp, &session->fs_lock, PRIBIO, | msleep(crp, &session->fs_lock, 0, | ||||
"zfs_crypto", hz/5); | "zfs_crypto", 0); | ||||
mtx_unlock(&session->fs_lock); | mtx_unlock(&session->fs_lock); | ||||
markj: BTW, the locking here and freebsd_zfs_crypt_done() is unnecessary for synchronous drivers like… | |||||
mavAuthorUnsubmitted Done Inline ActionsI haven't profiled this code very much, but I have suspect it won't be visible, comparing to cryptography. mav: I haven't profiled this code very much, but I have suspect it won't be visible, comparing to… | |||||
if (crp->crp_etype != EAGAIN) { | if (crp->crp_etype == ENOMEM) { | ||||
pause("zcrnomem", 1); | |||||
asomersUnsubmitted Not Done Inline ActionsYou should probably continue after the pause, don't you think? asomers: You should probably `continue` after the `pause`, don't you think? | |||||
mavAuthorUnsubmitted Done Inline ActionsNo, I meant "else" there. mav: No, I meant "else" there. | |||||
} if (crp->crp_etype != EAGAIN) { | |||||
markjUnsubmitted Not Done Inline ActionsPresumably it should be else if. markj: Presumably it should be `else if`. | |||||
mavAuthorUnsubmitted Done Inline ActionsYes. Thanks. mav: Yes. Thanks. | |||||
error = crp->crp_etype; | error = crp->crp_etype; | ||||
break; | break; | ||||
} | } | ||||
crp->crp_etype = 0; | crp->crp_etype = 0; | ||||
crp->crp_flags &= ~CRYPTO_F_DONE; | crp->crp_flags &= ~CRYPTO_F_DONE; | ||||
session->fs_done = false; | session->fs_done = false; | ||||
#if __FreeBSD_version < 1300087 | #if __FreeBSD_version < 1300087 | ||||
/* | /* | ||||
* Session ID changed, so we should record that, | * Session ID changed, so we should record that, | ||||
* and try again | * and try again | ||||
*/ | */ | ||||
session->fs_sid = crp->crp_session; | session->fs_sid = crp->crp_session; | ||||
markjUnsubmitted Not Done Inline ActionsThis does not apply to the ENOMEM case, but I think it's harmless. markj: This does not apply to the ENOMEM case, but I think it's harmless. | |||||
#endif | #endif | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
static void | static void | ||||
freebsd_crypt_uio_debug_log(boolean_t encrypt, | freebsd_crypt_uio_debug_log(boolean_t encrypt, | ||||
freebsd_crypt_session_t *input_sessionp, | freebsd_crypt_session_t *input_sessionp, | ||||
struct zio_crypt_info *c_info, | struct zio_crypt_info *c_info, | ||||
▲ Show 20 Lines • Show All 423 Lines • Show Last 20 Lines |
BTW, the locking here and freebsd_zfs_crypt_done() is unnecessary for synchronous drivers like aesni. Same for the wakeup() call. You can check CRYPTO_SESS_SYNC(session->fs_sid) to determine if this is the case, if profiles suggest it is worth doing.