mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode()
Subsystems (2)
PATCH 1/1 mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode()
in shmem_get_inode():new_inode();
new_inode_pseudo();
alloc_inode();
ops->alloc_inode(); -> shmem_alloc_inode()
kmem_cache_alloc();memset(info, 0, (char *)inode - (char *)info);
So use kmem_cache_zalloc() in shmem_alloc_inode(), and remove the memset in shmem_get_inode().
Signed-off-by Hui Su <[email protected]>
--- mm/shmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/shmem.c +1 -2
@@ -2308,7 +2308,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode inode->i_atime = inode->i_mtime = inode->i_ctime =current_time (inode); inode->i_generation =prandom_u32 (); info =SHMEM_I (inode); -memset (info,0 , (char *)inode - (char *)info);spin_lock_init (&info->lock);atomic_set (&info->stop_eviction,0 ); info->seals =F_SEAL_SEAL ;
@@ -3828,7 +3827,7 @@ static struct kmem_cache *shmem_inode_cachep;static struct inode *shmem_alloc_inode (struct super_block *sb) {struct shmem_inode_info *info; - info =kmem_cache_alloc (shmem_inode_cachep,GFP_KERNEL ); + info =kmem_cache_zalloc (shmem_inode_cachep,GFP_KERNEL );if (!info)return NULL ;return &info->vfs_inode;
Signature · 1 line
2.29.0
Quoted 7 lines · Hui Su
in
shmem_get_inode():new_inode(); new_inode_pseudo(); alloc_inode(); ops->alloc_inode(); -> shmem_alloc_inode() kmem_cache_alloc();
Quoted 6 lines
memset(info, 0, (char *)inode - (char *)info);So use
kmem_cache_zalloc()inshmem_alloc_inode(), and remove the memset inshmem_get_inode().Signed-off-by Hui Su <[email protected]>
Looks correct, but now we clear also the inode part which seems to be handled by alloc_inode() well enough. So, unsure. btrfs and ext4 variants don't use kzalloc neither. It's also more obvious with the current way that the info is cleared. Hmm?
Quoted 26 lines
--- mm/shmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/shmem.c +1
-2@@ -2308,7 +2308,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode inode->i_atime = inode->i_mtime = inode->i_ctime =current_time (inode); inode->i_generation =prandom_u32 (); info =SHMEM_I (inode); -memset (info,0 , (char *)inode - (char *)info);spin_lock_init (&info->lock);atomic_set (&info->stop_eviction,0 ); info->seals =F_SEAL_SEAL ;@@ -3828,7 +3827,7 @@ static struct kmem_cache *shmem_inode_cachep;static struct inode *shmem_alloc_inode (struct super_block *sb) {struct shmem_inode_info *info; - info =kmem_cache_alloc (shmem_inode_cachep,GFP_KERNEL ); + info =kmem_cache_zalloc (shmem_inode_cachep,GFP_KERNEL );if (!info)return NULL ;return &info->vfs_inode;