]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gfs2: avoid inefficient use of crc32_le_shift()
authorEric Biggers <ebiggers@google.com>
Sun, 11 May 2025 18:31:33 +0000 (11:31 -0700)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 22 May 2025 07:12:27 +0000 (09:12 +0200)
__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>
fs/gfs2/recovery.c

index f4fe7039f725b0e267b534ddf6ab4b563f41b4bb..9080f1b5f434d924d8e4508821b5c1066b10b433 100644 (file)
@@ -118,6 +118,7 @@ void gfs2_revoke_clean(struct gfs2_jdesc *jd)
 int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh,
                     unsigned int blkno, struct gfs2_log_header_host *head)
 {
+       const u32 zero = 0;
        u32 hash, crc;
 
        if (lh->lh_header.mh_magic != cpu_to_be32(GFS2_MAGIC) ||
@@ -126,7 +127,7 @@ int __get_log_header(struct gfs2_sbd *sdp, const struct gfs2_log_header *lh,
                return 1;
 
        hash = crc32(~0, lh, LH_V1_SIZE - 4);
-       hash = ~crc32_le_shift(hash, 4); /* assume lh_hash is zero */
+       hash = ~crc32(hash, &zero, 4); /* assume lh_hash is zero */
 
        if (be32_to_cpu(lh->lh_hash) != hash)
                return 1;