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

Configure Feed

Select the types of activity you want to include in your feed.

f2fs: switch to using the crc32 library

Now that the crc32() library function takes advantage of
architecture-specific optimizations, it is unnecessary to go through the
crypto API. Just use crc32(). This is much simpler, and it improves
performance due to eliminating the crypto API overhead.

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20241202010844.144356-19-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>

+2 -36
+1 -2
fs/f2fs/Kconfig
··· 4 4 depends on BLOCK 5 5 select BUFFER_HEAD 6 6 select NLS 7 - select CRYPTO 8 - select CRYPTO_CRC32 7 + select CRC32 9 8 select F2FS_FS_XATTR if FS_ENCRYPTION 10 9 select FS_ENCRYPTION_ALGS if FS_ENCRYPTION 11 10 select FS_IOMAP
+1 -19
fs/f2fs/f2fs.h
··· 24 24 #include <linux/quotaops.h> 25 25 #include <linux/part_stat.h> 26 26 #include <linux/rw_hint.h> 27 - #include <crypto/hash.h> 28 27 29 28 #include <linux/fscrypt.h> 30 29 #include <linux/fsverity.h> ··· 1767 1768 u64 sectors_written_start; 1768 1769 u64 kbytes_written; 1769 1770 1770 - /* Reference to checksum algorithm driver via cryptoapi */ 1771 - struct crypto_shash *s_chksum_driver; 1772 - 1773 1771 /* Precomputed FS UUID checksum for seeding other checksums */ 1774 1772 __u32 s_chksum_seed; 1775 1773 ··· 1944 1948 static inline u32 __f2fs_crc32(struct f2fs_sb_info *sbi, u32 crc, 1945 1949 const void *address, unsigned int length) 1946 1950 { 1947 - struct { 1948 - struct shash_desc shash; 1949 - char ctx[4]; 1950 - } desc; 1951 - int err; 1952 - 1953 - BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver) != sizeof(desc.ctx)); 1954 - 1955 - desc.shash.tfm = sbi->s_chksum_driver; 1956 - *(u32 *)desc.ctx = crc; 1957 - 1958 - err = crypto_shash_update(&desc.shash, address, length); 1959 - BUG_ON(err); 1960 - 1961 - return *(u32 *)desc.ctx; 1951 + return crc32(crc, address, length); 1962 1952 } 1963 1953 1964 1954 static inline u32 f2fs_crc32(struct f2fs_sb_info *sbi, const void *address,
-15
fs/f2fs/super.c
··· 1694 1694 1695 1695 kvfree(sbi->ckpt); 1696 1696 1697 - if (sbi->s_chksum_driver) 1698 - crypto_free_shash(sbi->s_chksum_driver); 1699 1697 kfree(sbi->raw_super); 1700 1698 1701 1699 f2fs_destroy_page_array_cache(sbi); ··· 4464 4466 } 4465 4467 mutex_init(&sbi->flush_lock); 4466 4468 4467 - /* Load the checksum driver */ 4468 - sbi->s_chksum_driver = crypto_alloc_shash("crc32", 0, 0); 4469 - if (IS_ERR(sbi->s_chksum_driver)) { 4470 - f2fs_err(sbi, "Cannot load crc32 driver."); 4471 - err = PTR_ERR(sbi->s_chksum_driver); 4472 - sbi->s_chksum_driver = NULL; 4473 - goto free_sbi; 4474 - } 4475 - 4476 4469 /* set a block size */ 4477 4470 if (unlikely(!sb_set_blocksize(sb, F2FS_BLKSIZE))) { 4478 4471 f2fs_err(sbi, "unable to set blocksize"); ··· 4908 4919 free_sb_buf: 4909 4920 kfree(raw_super); 4910 4921 free_sbi: 4911 - if (sbi->s_chksum_driver) 4912 - crypto_free_shash(sbi->s_chksum_driver); 4913 4922 kfree(sbi); 4914 4923 sb->s_fs_info = NULL; 4915 4924 ··· 5114 5127 MODULE_AUTHOR("Samsung Electronics's Praesto Team"); 5115 5128 MODULE_DESCRIPTION("Flash Friendly File System"); 5116 5129 MODULE_LICENSE("GPL"); 5117 - MODULE_SOFTDEP("pre: crc32"); 5118 -