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.

fscrypt: pass a real sector_t to fscrypt_zeroout_range_inline_crypt

While the pblk argument to fscrypt_zeroout_range_inline_crypt is
declared as a sector_t it actually is interpreted as a logical block
size unit, which is highly unusual. Switch to passing the 512 byte
units that sector_t is defined for.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
c22756a9 f7ba87df

+4 -5
+4 -5
fs/crypto/bio.c
··· 48 48 EXPORT_SYMBOL(fscrypt_decrypt_bio); 49 49 50 50 static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode, 51 - pgoff_t lblk, sector_t pblk, 51 + pgoff_t lblk, sector_t sector, 52 52 unsigned int len) 53 53 { 54 54 const unsigned int blockbits = inode->i_blkbits; ··· 67 67 68 68 if (num_pages == 0) { 69 69 fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOFS); 70 - bio->bi_iter.bi_sector = 71 - pblk << (blockbits - SECTOR_SHIFT); 70 + bio->bi_iter.bi_sector = sector; 72 71 } 73 72 ret = bio_add_page(bio, ZERO_PAGE(0), bytes_this_page, 0); 74 73 if (WARN_ON_ONCE(ret != bytes_this_page)) { ··· 77 78 num_pages++; 78 79 len -= blocks_this_page; 79 80 lblk += blocks_this_page; 80 - pblk += blocks_this_page; 81 + sector += (bytes_this_page >> SECTOR_SHIFT); 81 82 if (num_pages == BIO_MAX_VECS || !len || 82 83 !fscrypt_mergeable_bio(bio, inode, lblk)) { 83 84 err = submit_bio_wait(bio); ··· 131 132 return 0; 132 133 133 134 if (fscrypt_inode_uses_inline_crypto(inode)) 134 - return fscrypt_zeroout_range_inline_crypt(inode, lblk, pblk, 135 + return fscrypt_zeroout_range_inline_crypt(inode, lblk, sector, 135 136 len); 136 137 137 138 BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS);