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.

ext4: simplify fast-commit CRC calculation

Instead of checksumming each field as it is added to the block, just
checksum each block before it is written. This is simpler, and also
much more efficient.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20221106224841.279231-8-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Eric Biggers and committed by
Theodore Ts'o
8805dbcb 48a6a66d

+16 -38
+16 -38
fs/ext4/fast_commit.c
··· 675 675 676 676 /* Ext4 commit path routines */ 677 677 678 - /* memcpy to fc reserved space and update CRC */ 679 - static void *ext4_fc_memcpy(struct super_block *sb, void *dst, const void *src, 680 - int len, u32 *crc) 681 - { 682 - if (crc) 683 - *crc = ext4_chksum(EXT4_SB(sb), *crc, src, len); 684 - return memcpy(dst, src, len); 685 - } 686 - 687 - /* memzero and update CRC */ 688 - static void *ext4_fc_memzero(struct super_block *sb, void *dst, int len, 689 - u32 *crc) 690 - { 691 - void *ret; 692 - 693 - ret = memset(dst, 0, len); 694 - if (crc) 695 - *crc = ext4_chksum(EXT4_SB(sb), *crc, dst, len); 696 - return ret; 697 - } 698 - 699 678 /* 700 679 * Allocate len bytes on a fast commit buffer. 701 680 * ··· 728 749 729 750 tl.fc_tag = cpu_to_le16(EXT4_FC_TAG_PAD); 730 751 tl.fc_len = cpu_to_le16(remaining); 731 - ext4_fc_memcpy(sb, dst, &tl, EXT4_FC_TAG_BASE_LEN, crc); 732 - ext4_fc_memzero(sb, dst + EXT4_FC_TAG_BASE_LEN, remaining, crc); 752 + memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN); 753 + memset(dst + EXT4_FC_TAG_BASE_LEN, 0, remaining); 754 + *crc = ext4_chksum(sbi, *crc, sbi->s_fc_bh->b_data, bsize); 733 755 734 756 ext4_fc_submit_bh(sb, false); 735 757 ··· 772 792 tl.fc_len = cpu_to_le16(bsize - off + sizeof(struct ext4_fc_tail)); 773 793 sbi->s_fc_bytes = round_up(sbi->s_fc_bytes, bsize); 774 794 775 - ext4_fc_memcpy(sb, dst, &tl, EXT4_FC_TAG_BASE_LEN, &crc); 795 + memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN); 776 796 dst += EXT4_FC_TAG_BASE_LEN; 777 797 tail.fc_tid = cpu_to_le32(sbi->s_journal->j_running_transaction->t_tid); 778 - ext4_fc_memcpy(sb, dst, &tail.fc_tid, sizeof(tail.fc_tid), &crc); 798 + memcpy(dst, &tail.fc_tid, sizeof(tail.fc_tid)); 779 799 dst += sizeof(tail.fc_tid); 800 + crc = ext4_chksum(sbi, crc, sbi->s_fc_bh->b_data, 801 + dst - (u8 *)sbi->s_fc_bh->b_data); 780 802 tail.fc_crc = cpu_to_le32(crc); 781 - ext4_fc_memcpy(sb, dst, &tail.fc_crc, sizeof(tail.fc_crc), NULL); 803 + memcpy(dst, &tail.fc_crc, sizeof(tail.fc_crc)); 782 804 dst += sizeof(tail.fc_crc); 783 805 memset(dst, 0, bsize - off); /* Don't leak uninitialized memory. */ 784 806 ··· 806 824 tl.fc_tag = cpu_to_le16(tag); 807 825 tl.fc_len = cpu_to_le16(len); 808 826 809 - ext4_fc_memcpy(sb, dst, &tl, EXT4_FC_TAG_BASE_LEN, crc); 810 - ext4_fc_memcpy(sb, dst + EXT4_FC_TAG_BASE_LEN, val, len, crc); 827 + memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN); 828 + memcpy(dst + EXT4_FC_TAG_BASE_LEN, val, len); 811 829 812 830 return true; 813 831 } ··· 829 847 fcd.fc_ino = cpu_to_le32(fc_dentry->fcd_ino); 830 848 tl.fc_tag = cpu_to_le16(fc_dentry->fcd_op); 831 849 tl.fc_len = cpu_to_le16(sizeof(fcd) + dlen); 832 - ext4_fc_memcpy(sb, dst, &tl, EXT4_FC_TAG_BASE_LEN, crc); 850 + memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN); 833 851 dst += EXT4_FC_TAG_BASE_LEN; 834 - ext4_fc_memcpy(sb, dst, &fcd, sizeof(fcd), crc); 852 + memcpy(dst, &fcd, sizeof(fcd)); 835 853 dst += sizeof(fcd); 836 - ext4_fc_memcpy(sb, dst, fc_dentry->fcd_name.name, dlen, crc); 854 + memcpy(dst, fc_dentry->fcd_name.name, dlen); 837 855 838 856 return true; 839 857 } ··· 871 889 if (!dst) 872 890 goto err; 873 891 874 - if (!ext4_fc_memcpy(inode->i_sb, dst, &tl, EXT4_FC_TAG_BASE_LEN, crc)) 875 - goto err; 892 + memcpy(dst, &tl, EXT4_FC_TAG_BASE_LEN); 876 893 dst += EXT4_FC_TAG_BASE_LEN; 877 - if (!ext4_fc_memcpy(inode->i_sb, dst, &fc_inode, sizeof(fc_inode), crc)) 878 - goto err; 894 + memcpy(dst, &fc_inode, sizeof(fc_inode)); 879 895 dst += sizeof(fc_inode); 880 - if (!ext4_fc_memcpy(inode->i_sb, dst, (u8 *)ext4_raw_inode(&iloc), 881 - inode_len, crc)) 882 - goto err; 896 + memcpy(dst, (u8 *)ext4_raw_inode(&iloc), inode_len); 883 897 ret = 0; 884 898 err: 885 899 brelse(iloc.bh);