2014-02-20 21:59:17

by Fabian Frederick

[permalink] [raw]
Subject: [PATCH v2] afs: afs_alloc_inode: use kmem_cache_zalloc

This patch calls zalloc for explicit zero fill and removes all memset 0.

Signed-off-by: Fabian Frederick <[email protected]>
---
fs/afs/super.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/afs/super.c b/fs/afs/super.c
index c486155..aff91ee 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -460,7 +460,6 @@ static void afs_i_init_once(void *_vnode)
{
struct afs_vnode *vnode = _vnode;

- memset(vnode, 0, sizeof(*vnode));
inode_init_once(&vnode->vfs_inode);
init_waitqueue_head(&vnode->update_waitq);
mutex_init(&vnode->permits_lock);
@@ -481,17 +480,12 @@ static struct inode *afs_alloc_inode(struct super_block *sb)
{
struct afs_vnode *vnode;

- vnode = kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
+ vnode = kmem_cache_zalloc(afs_inode_cachep, GFP_KERNEL);
if (!vnode)
return NULL;

atomic_inc(&afs_count_active_inodes);

- memset(&vnode->fid, 0, sizeof(vnode->fid));
- memset(&vnode->status, 0, sizeof(vnode->status));
-
- vnode->volume = NULL;
- vnode->update_cnt = 0;
vnode->flags = 1 << AFS_VNODE_UNSET;
vnode->cb_promised = false;

--
1.8.1.4


2014-02-21 21:47:18

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v2] afs: afs_alloc_inode: use kmem_cache_zalloc

On Thu, 20 Feb 2014 22:00:39 +0800 Fabian Frederick <[email protected]> wrote:

> This patch calls zalloc for explicit zero fill and removes all memset 0.
>

May as well fix the deceitful comment while we're in there.

--- a/fs/afs/super.c~afs-afs_alloc_inode-use-kmem_cache_zalloc-fix
+++ a/fs/afs/super.c
@@ -474,7 +474,7 @@ static void afs_i_init_once(void *_vnode
}

/*
- * allocate an AFS inode struct from our slab cache
+ * allocate an AFS inode struct
*/
static struct inode *afs_alloc_inode(struct super_block *sb)
{

This isn't the most useful comment in the kernel..

2014-02-21 21:52:09

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v2] afs: afs_alloc_inode: use kmem_cache_zalloc

On Fri, 21 Feb 2014 13:47:16 -0800 Andrew Morton <[email protected]> wrote:

> --- a/fs/afs/super.c~afs-afs_alloc_inode-use-kmem_cache_zalloc-fix
> +++ a/fs/afs/super.c
> @@ -474,7 +474,7 @@ static void afs_i_init_once(void *_vnode
> }
>
> /*
> - * allocate an AFS inode struct from our slab cache
> + * allocate an AFS inode struct
> */
> static struct inode *afs_alloc_inode(struct super_block *sb)
> {

err, this was obviously a product of senility.

2014-02-21 22:48:25

by David Howells

[permalink] [raw]
Subject: Re: [PATCH v2] afs: afs_alloc_inode: use kmem_cache_zalloc

Andrew Morton <[email protected]> wrote:

> > - * allocate an AFS inode struct from our slab cache
> > + * allocate an AFS inode struct
> > */
> > static struct inode *afs_alloc_inode(struct super_block *sb)
> > {
>
> err, this was obviously a product of senility.

My comment, or your comment on my comment?

David