mirror of https://gitee.com/openkylin/linux.git
ext4: provide ext4_issue_zeroout()
Create new function ext4_issue_zeroout() to zeroout contiguous (both logically and physically) part of inode data. We will need to issue zeroout when extent structure is not readily available and this function will allow us to do it without making up fake extent structures. Signed-off-by: Jan Kara <jack@suse.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
2dcba4781f
commit
53085fac02
|
@ -384,14 +384,12 @@ int ext4_decrypt(struct page *page)
|
||||||
EXT4_DECRYPT, page->index, page, page);
|
EXT4_DECRYPT, page->index, page, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex)
|
int ext4_encrypted_zeroout(struct inode *inode, ext4_lblk_t lblk,
|
||||||
|
ext4_fsblk_t pblk, ext4_lblk_t len)
|
||||||
{
|
{
|
||||||
struct ext4_crypto_ctx *ctx;
|
struct ext4_crypto_ctx *ctx;
|
||||||
struct page *ciphertext_page = NULL;
|
struct page *ciphertext_page = NULL;
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
ext4_lblk_t lblk = le32_to_cpu(ex->ee_block);
|
|
||||||
ext4_fsblk_t pblk = ext4_ext_pblock(ex);
|
|
||||||
unsigned int len = ext4_ext_get_actual_len(ex);
|
|
||||||
int ret, err = 0;
|
int ret, err = 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -2241,7 +2241,8 @@ void ext4_restore_control_page(struct page *data_page);
|
||||||
struct page *ext4_encrypt(struct inode *inode,
|
struct page *ext4_encrypt(struct inode *inode,
|
||||||
struct page *plaintext_page);
|
struct page *plaintext_page);
|
||||||
int ext4_decrypt(struct page *page);
|
int ext4_decrypt(struct page *page);
|
||||||
int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex);
|
int ext4_encrypted_zeroout(struct inode *inode, ext4_lblk_t lblk,
|
||||||
|
ext4_fsblk_t pblk, ext4_lblk_t len);
|
||||||
|
|
||||||
#ifdef CONFIG_EXT4_FS_ENCRYPTION
|
#ifdef CONFIG_EXT4_FS_ENCRYPTION
|
||||||
int ext4_init_crypto(void);
|
int ext4_init_crypto(void);
|
||||||
|
@ -2495,6 +2496,8 @@ extern int ext4_filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
|
||||||
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
|
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
|
||||||
extern void ext4_da_update_reserve_space(struct inode *inode,
|
extern void ext4_da_update_reserve_space(struct inode *inode,
|
||||||
int used, int quota_claim);
|
int used, int quota_claim);
|
||||||
|
extern int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk,
|
||||||
|
ext4_fsblk_t pblk, ext4_lblk_t len);
|
||||||
|
|
||||||
/* indirect.c */
|
/* indirect.c */
|
||||||
extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
|
extern int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
|
||||||
|
|
|
@ -3119,19 +3119,11 @@ static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
|
||||||
{
|
{
|
||||||
ext4_fsblk_t ee_pblock;
|
ext4_fsblk_t ee_pblock;
|
||||||
unsigned int ee_len;
|
unsigned int ee_len;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ee_len = ext4_ext_get_actual_len(ex);
|
ee_len = ext4_ext_get_actual_len(ex);
|
||||||
ee_pblock = ext4_ext_pblock(ex);
|
ee_pblock = ext4_ext_pblock(ex);
|
||||||
|
return ext4_issue_zeroout(inode, le32_to_cpu(ex->ee_block), ee_pblock,
|
||||||
if (ext4_encrypted_inode(inode))
|
ee_len);
|
||||||
return ext4_encrypted_zeroout(inode, ex);
|
|
||||||
|
|
||||||
ret = sb_issue_zeroout(inode->i_sb, ee_pblock, ee_len, GFP_NOFS);
|
|
||||||
if (ret > 0)
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -383,6 +383,21 @@ static int __check_block_validity(struct inode *inode, const char *func,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ext4_issue_zeroout(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
|
||||||
|
ext4_lblk_t len)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (ext4_encrypted_inode(inode))
|
||||||
|
return ext4_encrypted_zeroout(inode, lblk, pblk, len);
|
||||||
|
|
||||||
|
ret = sb_issue_zeroout(inode->i_sb, pblk, len, GFP_NOFS);
|
||||||
|
if (ret > 0)
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#define check_block_validity(inode, map) \
|
#define check_block_validity(inode, map) \
|
||||||
__check_block_validity((inode), __func__, __LINE__, (map))
|
__check_block_validity((inode), __func__, __LINE__, (map))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue