Re: [PATCH 3/7] ecryptfs: use ZERO_PAGE instead of allocating zeroed memory in truncate_upper
Tyler Hicks <[email protected]> Mon, 6 Apr 2026 00:52:51 -0500
| Newsgroups | org.kernel.vger.ecryptfs,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <adNKM-8zHwrR6AbI@yaupon> |
On 2026-03-31 17:37:24, Christoph Hellwig wrote: > Use the existing pre-zeroed memory instead of allocating a new chunk. > > Signed-off-by: Christoph Hellwig <[email protected]> Nice improvement! Tyler > --- > fs/ecryptfs/inode.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c > index 46dc867a8860..57df35a22e9c 100644 > --- a/fs/ecryptfs/inode.c > +++ b/fs/ecryptfs/inode.c > @@ -771,15 +771,8 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia, > */ > num_zeros = PAGE_SIZE - (ia->ia_size & ~PAGE_MASK); > if (num_zeros) { > - char *zeros_virt; > - > - zeros_virt = kzalloc(num_zeros, GFP_KERNEL); > - if (!zeros_virt) { > - rc = -ENOMEM; > - goto out; > - } > - rc = ecryptfs_write(inode, zeros_virt, ia->ia_size, num_zeros); > - kfree(zeros_virt); > + rc = ecryptfs_write(inode, page_address(ZERO_PAGE(0)), > + ia->ia_size, num_zeros); > if (rc) { > pr_err("Error attempting to zero out the remainder of the end page on reducing truncate; rc = [%d]\n", > rc); > -- > 2.47.3 >