nfsd: move some of fh_compose into helper functions
[safe/jmp/linux-2.6] / fs / autofs4 / expire.c
index e3bd507..aa39ae8 100644 (file)
@@ -48,19 +48,19 @@ static inline int autofs4_can_expire(struct dentry *dentry,
 static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
 {
        struct dentry *top = dentry;
+       struct path path = {.mnt = mnt, .dentry = dentry};
        int status = 1;
 
        DPRINTK("dentry %p %.*s",
                dentry, (int)dentry->d_name.len, dentry->d_name.name);
 
-       mntget(mnt);
-       dget(dentry);
+       path_get(&path);
 
-       if (!follow_down(&mnt, &dentry))
+       if (!follow_down(&path))
                goto done;
 
-       if (is_autofs4_dentry(dentry)) {
-               struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       if (is_autofs4_dentry(path.dentry)) {
+               struct autofs_sb_info *sbi = autofs4_sbi(path.dentry->d_sb);
 
                /* This is an autofs submount, we can't expire it */
                if (autofs_type_indirect(sbi->type))
@@ -70,8 +70,10 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
                 * Otherwise it's an offset mount and we need to check
                 * if we can umount its mount, if there is one.
                 */
-               if (!d_mountpoint(dentry))
+               if (!d_mountpoint(path.dentry)) {
+                       status = 0;
                        goto done;
+               }
        }
 
        /* Update the expiry counter if fs is busy */
@@ -84,8 +86,7 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
        status = 0;
 done:
        DPRINTK("returning = %d", status);
-       dput(dentry);
-       mntput(mnt);
+       path_put(&path);
        return status;
 }
 
@@ -478,22 +479,16 @@ int autofs4_expire_run(struct super_block *sb,
        return ret;
 }
 
-/* Call repeatedly until it returns -EAGAIN, meaning there's nothing
-   more to be done */
-int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
-                       struct autofs_sb_info *sbi, int __user *arg)
+int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
+                           struct autofs_sb_info *sbi, int when)
 {
        struct dentry *dentry;
        int ret = -EAGAIN;
-       int do_now = 0;
-
-       if (arg && get_user(do_now, arg))
-               return -EFAULT;
 
        if (autofs_type_trigger(sbi->type))
-               dentry = autofs4_expire_direct(sb, mnt, sbi, do_now);
+               dentry = autofs4_expire_direct(sb, mnt, sbi, when);
        else
-               dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now);
+               dentry = autofs4_expire_indirect(sb, mnt, sbi, when);
 
        if (dentry) {
                struct autofs_info *ino = autofs4_dentry_ino(dentry);
@@ -516,3 +511,16 @@ int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
        return ret;
 }
 
+/* Call repeatedly until it returns -EAGAIN, meaning there's nothing
+   more to be done */
+int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt,
+                       struct autofs_sb_info *sbi, int __user *arg)
+{
+       int do_now = 0;
+
+       if (arg && get_user(do_now, arg))
+               return -EFAULT;
+
+       return autofs4_do_expire_multi(sb, mnt, sbi, do_now);
+}
+