mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
cifs: Use iterate_and_advance*() routines directly for hashing
Replace the bespoke cifs iterators of ITER_BVEC and ITER_KVEC to do hashing with iterate_and_advance_kernel() - a variant on iterate_and_advance() that only supports kernel-internal ITER_* types and not UBUF/IOVEC types. The bespoke ITER_XARRAY is left because we don't really want to be calling crypto_shash_update() under the RCU read lock for large amounts of data; besides, ITER_XARRAY is going to be phased out. Signed-off-by: David Howells <dhowells@redhat.com> cc: Steve French <sfrench@samba.org> cc: Paulo Alcantara <pc@manguebit.com> cc: Tom Talpey <tom@talpey.com> cc: Enzo Matsumiya <ematsumiya@suse.de> cc: linux-cifs@vger.kernel.org Link: https://lore.kernel.org/r/20240814203850.2240469-24-dhowells@redhat.com/ # v2 Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
8f246b7c0a
commit
2982c8c19b
@@ -328,4 +328,51 @@ size_t iterate_and_advance(struct iov_iter *iter, size_t len, void *priv,
|
||||
return iterate_and_advance2(iter, len, priv, NULL, ustep, step);
|
||||
}
|
||||
|
||||
/**
|
||||
* iterate_and_advance_kernel - Iterate over a kernel-internal iterator
|
||||
* @iter: The iterator to iterate over.
|
||||
* @len: The amount to iterate over.
|
||||
* @priv: Data for the step functions.
|
||||
* @priv2: More data for the step functions.
|
||||
* @step: Function for other iterators; given kernel addresses.
|
||||
*
|
||||
* Iterate over the next part of an iterator, up to the specified length. The
|
||||
* buffer is presented in segments, which for kernel iteration are broken up by
|
||||
* physical pages and mapped, with the mapped address being presented.
|
||||
*
|
||||
* [!] Note This will only handle BVEC, KVEC, FOLIOQ, XARRAY and DISCARD-type
|
||||
* iterators; it will not handle UBUF or IOVEC-type iterators.
|
||||
*
|
||||
* A step functions, @step, must be provided, one for handling mapped kernel
|
||||
* addresses and the other is given user addresses which have the potential to
|
||||
* fault since no pinning is performed.
|
||||
*
|
||||
* The step functions are passed the address and length of the segment, @priv,
|
||||
* @priv2 and the amount of data so far iterated over (which can, for example,
|
||||
* be added to @priv to point to the right part of a second buffer). The step
|
||||
* functions should return the amount of the segment they didn't process (ie. 0
|
||||
* indicates complete processsing).
|
||||
*
|
||||
* This function returns the amount of data processed (ie. 0 means nothing was
|
||||
* processed and the value of @len means processes to completion).
|
||||
*/
|
||||
static __always_inline
|
||||
size_t iterate_and_advance_kernel(struct iov_iter *iter, size_t len, void *priv,
|
||||
void *priv2, iov_step_f step)
|
||||
{
|
||||
if (unlikely(iter->count < len))
|
||||
len = iter->count;
|
||||
if (unlikely(!len))
|
||||
return 0;
|
||||
if (iov_iter_is_bvec(iter))
|
||||
return iterate_bvec(iter, len, priv, priv2, step);
|
||||
if (iov_iter_is_kvec(iter))
|
||||
return iterate_kvec(iter, len, priv, priv2, step);
|
||||
if (iov_iter_is_folioq(iter))
|
||||
return iterate_folioq(iter, len, priv, priv2, step);
|
||||
if (iov_iter_is_xarray(iter))
|
||||
return iterate_xarray(iter, len, priv, priv2, step);
|
||||
return iterate_discard(iter, len, priv, priv2, step);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_IOV_ITER_H */
|
||||
|
||||
Reference in New Issue
Block a user