lkml.org 
[lkml]   [2019]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 19/62] gfs2: switch to ->free_inode()
    Date
    From: Al Viro <viro@zeniv.linux.org.uk>

    ... and use GFS2_I() to get the containing gfs2_inode by inode;
    yes, we can feed the address of the first member of structure
    to kmem_cache_free(), but let's do it in an obviously safe way.

    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    ---
    fs/gfs2/super.c | 12 +++---------
    1 file changed, 3 insertions(+), 9 deletions(-)

    diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
    index ca71163ff7cf..7b8d2306b3d3 100644
    --- a/fs/gfs2/super.c
    +++ b/fs/gfs2/super.c
    @@ -1736,20 +1736,14 @@ static struct inode *gfs2_alloc_inode(struct super_block *sb)
    return &ip->i_inode;
    }

    -static void gfs2_i_callback(struct rcu_head *head)
    +static void gfs2_free_inode(struct inode *inode)
    {
    - struct inode *inode = container_of(head, struct inode, i_rcu);
    - kmem_cache_free(gfs2_inode_cachep, inode);
    -}
    -
    -static void gfs2_destroy_inode(struct inode *inode)
    -{
    - call_rcu(&inode->i_rcu, gfs2_i_callback);
    + kmem_cache_free(gfs2_inode_cachep, GFS2_I(inode));
    }

    const struct super_operations gfs2_super_ops = {
    .alloc_inode = gfs2_alloc_inode,
    - .destroy_inode = gfs2_destroy_inode,
    + .free_inode = gfs2_free_inode,
    .write_inode = gfs2_write_inode,
    .dirty_inode = gfs2_dirty_inode,
    .evict_inode = gfs2_evict_inode,
    --
    2.11.0
    \
     
     \ /
      Last update: 2019-04-16 19:59    [W:4.144 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site