From: Andrey Albershteyn <aalbersh@xxxxxxxxxx> Calculate CRC of the buffer which will not be placed in this same buffer (common case for all other xfs_cksum.h uses). Signed-off-by: Andrey Albershteyn <aalbersh@xxxxxxxxxx> --- fs/xfs/libxfs/xfs_cksum.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h index 999a290cfd72..90884ed0ef23 100644 --- a/fs/xfs/libxfs/xfs_cksum.h +++ b/fs/xfs/libxfs/xfs_cksum.h @@ -79,4 +79,16 @@ xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset) return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc); } +/* + * Helper to calculate the checksum of a buffer which is outside of the buffer + */ +static inline uint32_t +xfs_calc_cksum(char *buffer, size_t length, uint32_t *dst) +{ + uint32_t crc = crc32c(XFS_CRC_SEED, buffer, length); + if (dst) + *dst = crc; + return crc; +} + #endif /* _XFS_CKSUM_H */ -- 2.47.0