autofs4: keep symlink body in inode->i_private
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 17 Jan 2011 05:47:38 +0000 (00:47 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 18 Jan 2011 06:21:27 +0000 (01:21 -0500)
gets rid of all ->free()/->u.symlink machinery in autofs; we simply
keep symlink bodies in inode->i_private and free them in ->evict_inode().

Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/autofs4/autofs_i.h
fs/autofs4/inode.c
fs/autofs4/root.c
fs/autofs4/symlink.c

index 1f016bfb42d5ed3851762d133c7d1f11e7fed65b..99a4af8d9c83fdc129ac98ee7e8cb7c55b2c36b0 100644 (file)
@@ -91,11 +91,6 @@ struct autofs_info {
 
        mode_t  mode;
        size_t  size;
-
-       void (*free)(struct autofs_info *);
-       union {
-               const char *symlink;
-       } u;
 };
 
 #define AUTOFS_INF_EXPIRING    (1<<0) /* dentry is in the process of expiring */
index 9e1a9dad23e16663fc69937ebc47dd7f286529f2..cf8abc793d5051c4e8f0db5a3db2613c02b18377 100644 (file)
 #include "autofs_i.h"
 #include <linux/module.h>
 
-static void ino_lnkfree(struct autofs_info *ino)
-{
-       if (ino->u.symlink) {
-               kfree(ino->u.symlink);
-               ino->u.symlink = NULL;
-       }
-}
-
 struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
                                     struct autofs_sb_info *sbi, mode_t mode)
 {
@@ -60,16 +52,6 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
 
        ino->sbi = sbi;
 
-       if (reinit && ino->free)
-               (ino->free)(ino);
-
-       memset(&ino->u, 0, sizeof(ino->u));
-
-       ino->free = NULL;
-
-       if (S_ISLNK(mode))
-               ino->free = ino_lnkfree;
-
        return ino;
 }
 
@@ -79,8 +61,6 @@ void autofs4_free_ino(struct autofs_info *ino)
                ino->dentry->d_fsdata = NULL;
                ino->dentry = NULL;
        }
-       if (ino->free)
-               (ino->free)(ino);
        kfree(ino);
 }
 
@@ -136,9 +116,16 @@ static int autofs4_show_options(struct seq_file *m, struct vfsmount *mnt)
        return 0;
 }
 
+static void autofs4_evict_inode(struct inode *inode)
+{
+       end_writeback(inode);
+       kfree(inode->i_private);
+}
+
 static const struct super_operations autofs4_sops = {
        .statfs         = simple_statfs,
        .show_options   = autofs4_show_options,
+       .evict_inode    = autofs4_evict_inode,
 };
 
 enum {Opt_err, Opt_fd, Opt_uid, Opt_gid, Opt_pgrp, Opt_minproto, Opt_maxproto,
index 427129ab5292d777ec69855c96a8300007bf3010..f47aceabf58f919a6cd2bfead313dae60cb46c5f 100644 (file)
@@ -561,6 +561,7 @@ static int autofs4_dir_symlink(struct inode *dir,
                        kfree(ino);
                return -ENOMEM;
        }
+       inode->i_private = cp;
        d_add(dentry, inode);
 
        dentry->d_fsdata = ino;
@@ -570,7 +571,6 @@ static int autofs4_dir_symlink(struct inode *dir,
        if (p_ino && dentry->d_parent != dentry)
                atomic_inc(&p_ino->count);
 
-       ino->u.symlink = cp;
        dir->i_mtime = CURRENT_TIME;
 
        return 0;
index b4ea82934d2e3a7a8f2707cbac630b5627faca84..f27c094a1919c2af890df6b1f2ac3a9e6a523b4c 100644 (file)
@@ -14,8 +14,7 @@
 
 static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
-       struct autofs_info *ino = autofs4_dentry_ino(dentry);
-       nd_set_link(nd, (char *)ino->u.symlink);
+       nd_set_link(nd, dentry->d_inode->i_private);
        return NULL;
 }