Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gfs2: avoid inefficient use of crc32_le_shift()

__get_log_header() was using crc32_le_shift() to update a CRC with four
zero bytes. However, this is about 5x slower than just CRC'ing four
zero bytes in the normal way. Just do that instead.

(We could instead make crc32_le_shift() faster on short lengths. But
all its callers do just fine without it, so I'd like to just remove it.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

authored by

Eric Biggers and committed by
Andreas Gruenbacher
b6ccde39 87faee38

+2 -1
+2 -1
fs/gfs2/recovery.c
··· 118 118 int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh, 119 119 unsigned int blkno, struct gfs2_log_header_host *head) 120 120 { 121 + const u32 zero = 0; 121 122 u32 hash, crc; 122 123 123 124 if (lh->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) || ··· 127 126 return 1; 128 127 129 128 hash = crc32(~0, lh, LH_V1_SIZE - 4); 130 - hash = ~crc32_le_shift(hash, 4); /* assume lh_hash is zero */ 129 + hash = ~crc32(hash, &zero, 4); /* assume lh_hash is zero */ 131 130 132 131 if (be32_to_cpu(lh->lh_hash) != hash) 133 132 return 1;