mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 11:21:26 -04:00
fscrypt: pass a byte length to fscrypt_zeroout_range
Range lengths are usually expressed as bytes in the VFS, switch fscrypt_zeroout_range to this convention. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20260302141922.370070-13-hch@lst.de Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
committed by
Eric Biggers
parent
cd7db2e7df
commit
fb87ab4ad3
@@ -115,12 +115,13 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
|
||||
* @inode: the file's inode
|
||||
* @pos: the first file position (in bytes) to zero out
|
||||
* @pblk: the first filesystem physical block to zero out
|
||||
* @len: number of blocks to zero out
|
||||
* @len: bytes to zero out
|
||||
*
|
||||
* Zero out filesystem blocks in an encrypted regular file on-disk, i.e. write
|
||||
* ciphertext blocks which decrypt to the all-zeroes block. The blocks must be
|
||||
* both logically and physically contiguous. It's also assumed that the
|
||||
* filesystem only uses a single block device, ->s_bdev.
|
||||
* filesystem only uses a single block device, ->s_bdev. @len must be a
|
||||
* multiple of the file system logical block size.
|
||||
*
|
||||
* Note that since each block uses a different IV, this involves writing a
|
||||
* different ciphertext to each block; we can't simply reuse the same one.
|
||||
@@ -128,7 +129,7 @@ static int fscrypt_zeroout_range_inline_crypt(const struct inode *inode,
|
||||
* Return: 0 on success; -errno on failure.
|
||||
*/
|
||||
int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
sector_t pblk, unsigned int len)
|
||||
sector_t pblk, u64 len)
|
||||
{
|
||||
const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode);
|
||||
const unsigned int du_bits = ci->ci_data_unit_bits;
|
||||
@@ -136,7 +137,7 @@ int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
const unsigned int du_per_page_bits = PAGE_SHIFT - du_bits;
|
||||
const unsigned int du_per_page = 1U << du_per_page_bits;
|
||||
u64 du_index = pos >> du_bits;
|
||||
u64 du_remaining = (u64)len << (inode->i_blkbits - du_bits);
|
||||
u64 du_remaining = len >> du_bits;
|
||||
sector_t sector = pblk << (inode->i_blkbits - SECTOR_SHIFT);
|
||||
struct page *pages[16]; /* write up to 16 pages at a time */
|
||||
unsigned int nr_pages;
|
||||
@@ -150,7 +151,7 @@ int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
|
||||
if (fscrypt_inode_uses_inline_crypto(inode))
|
||||
return fscrypt_zeroout_range_inline_crypt(inode, pos, sector,
|
||||
(u64)len << inode->i_blkbits);
|
||||
len);
|
||||
|
||||
BUILD_BUG_ON(ARRAY_SIZE(pages) > BIO_MAX_VECS);
|
||||
nr_pages = min_t(u64, ARRAY_SIZE(pages),
|
||||
|
||||
@@ -406,7 +406,8 @@ int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
|
||||
|
||||
if (IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode))
|
||||
return fscrypt_zeroout_range(inode,
|
||||
(loff_t)lblk << inode->i_blkbits, pblk, len);
|
||||
(loff_t)lblk << inode->i_blkbits, pblk,
|
||||
(u64)len << inode->i_blkbits);
|
||||
|
||||
ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS);
|
||||
if (ret > 0)
|
||||
|
||||
@@ -4164,7 +4164,7 @@ static int f2fs_secure_erase(struct block_device *bdev, struct inode *inode,
|
||||
if (IS_ENCRYPTED(inode))
|
||||
ret = fscrypt_zeroout_range(inode,
|
||||
(loff_t)off << inode->i_blkbits, block,
|
||||
len);
|
||||
(u64)len << inode->i_blkbits);
|
||||
else
|
||||
ret = blkdev_issue_zeroout(bdev, sector, nr_sects,
|
||||
GFP_NOFS, 0);
|
||||
|
||||
@@ -450,8 +450,8 @@ u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name);
|
||||
|
||||
/* bio.c */
|
||||
bool fscrypt_decrypt_bio(struct bio *bio);
|
||||
int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
sector_t pblk, unsigned int len);
|
||||
int fscrypt_zeroout_range(const struct inode *inode, loff_t pos, sector_t pblk,
|
||||
u64 len);
|
||||
|
||||
/* hooks.c */
|
||||
int fscrypt_file_open(struct inode *inode, struct file *filp);
|
||||
@@ -756,7 +756,7 @@ static inline bool fscrypt_decrypt_bio(struct bio *bio)
|
||||
}
|
||||
|
||||
static inline int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
sector_t pblk, unsigned int len)
|
||||
sector_t pblk, u64 len)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user