| 1 |
--- linux-2.6.29.orig/fs/autofs4/autofs_i.h |
| 2 |
+++ linux-2.6.29/fs/autofs4/autofs_i.h |
| 3 |
@@ -186,6 +186,8 @@ int autofs4_expire_wait(struct dentry *d |
| 4 |
int autofs4_expire_run(struct super_block *, struct vfsmount *, |
| 5 |
struct autofs_sb_info *, |
| 6 |
struct autofs_packet_expire __user *); |
| 7 |
+int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 8 |
+ struct autofs_sb_info *sbi, int when); |
| 9 |
int autofs4_expire_multi(struct super_block *, struct vfsmount *, |
| 10 |
struct autofs_sb_info *, int __user *); |
| 11 |
struct dentry *autofs4_expire_direct(struct super_block *sb, |
| 12 |
--- linux-2.6.29.orig/fs/autofs4/dev-ioctl.c |
| 13 |
+++ linux-2.6.29/fs/autofs4/dev-ioctl.c |
| 14 |
@@ -525,40 +525,13 @@ static int autofs_dev_ioctl_expire(struc |
| 15 |
struct autofs_sb_info *sbi, |
| 16 |
struct autofs_dev_ioctl *param) |
| 17 |
{ |
| 18 |
- struct dentry *dentry; |
| 19 |
struct vfsmount *mnt; |
| 20 |
- int err = -EAGAIN; |
| 21 |
int how; |
| 22 |
|
| 23 |
how = param->expire.how; |
| 24 |
mnt = fp->f_path.mnt; |
| 25 |
|
| 26 |
- if (autofs_type_trigger(sbi->type)) |
| 27 |
- dentry = autofs4_expire_direct(sbi->sb, mnt, sbi, how); |
| 28 |
- else |
| 29 |
- dentry = autofs4_expire_indirect(sbi->sb, mnt, sbi, how); |
| 30 |
- |
| 31 |
- if (dentry) { |
| 32 |
- struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 33 |
- |
| 34 |
- /* |
| 35 |
- * This is synchronous because it makes the daemon a |
| 36 |
- * little easier |
| 37 |
- */ |
| 38 |
- err = autofs4_wait(sbi, dentry, NFY_EXPIRE); |
| 39 |
- |
| 40 |
- spin_lock(&sbi->fs_lock); |
| 41 |
- if (ino->flags & AUTOFS_INF_MOUNTPOINT) { |
| 42 |
- ino->flags &= ~AUTOFS_INF_MOUNTPOINT; |
| 43 |
- sbi->sb->s_root->d_mounted++; |
| 44 |
- } |
| 45 |
- ino->flags &= ~AUTOFS_INF_EXPIRING; |
| 46 |
- complete_all(&ino->expire_complete); |
| 47 |
- spin_unlock(&sbi->fs_lock); |
| 48 |
- dput(dentry); |
| 49 |
- } |
| 50 |
- |
| 51 |
- return err; |
| 52 |
+ return autofs4_do_expire_multi(sbi->sb, mnt, sbi, how); |
| 53 |
} |
| 54 |
|
| 55 |
/* Check if autofs mount point is in use */ |
| 56 |
--- linux-2.6.29.orig/fs/autofs4/expire.c |
| 57 |
+++ linux-2.6.29/fs/autofs4/expire.c |
| 58 |
@@ -70,8 +70,10 @@ static int autofs4_mount_busy(struct vfs |
| 59 |
* Otherwise it's an offset mount and we need to check |
| 60 |
* if we can umount its mount, if there is one. |
| 61 |
*/ |
| 62 |
- if (!d_mountpoint(dentry)) |
| 63 |
+ if (!d_mountpoint(dentry)) { |
| 64 |
+ status = 0; |
| 65 |
goto done; |
| 66 |
+ } |
| 67 |
} |
| 68 |
|
| 69 |
/* Update the expiry counter if fs is busy */ |
| 70 |
@@ -478,22 +480,16 @@ int autofs4_expire_run(struct super_bloc |
| 71 |
return ret; |
| 72 |
} |
| 73 |
|
| 74 |
-/* Call repeatedly until it returns -EAGAIN, meaning there's nothing |
| 75 |
- more to be done */ |
| 76 |
-int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 77 |
- struct autofs_sb_info *sbi, int __user *arg) |
| 78 |
+int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 79 |
+ struct autofs_sb_info *sbi, int when) |
| 80 |
{ |
| 81 |
struct dentry *dentry; |
| 82 |
int ret = -EAGAIN; |
| 83 |
- int do_now = 0; |
| 84 |
- |
| 85 |
- if (arg && get_user(do_now, arg)) |
| 86 |
- return -EFAULT; |
| 87 |
|
| 88 |
if (autofs_type_trigger(sbi->type)) |
| 89 |
- dentry = autofs4_expire_direct(sb, mnt, sbi, do_now); |
| 90 |
+ dentry = autofs4_expire_direct(sb, mnt, sbi, when); |
| 91 |
else |
| 92 |
- dentry = autofs4_expire_indirect(sb, mnt, sbi, do_now); |
| 93 |
+ dentry = autofs4_expire_indirect(sb, mnt, sbi, when); |
| 94 |
|
| 95 |
if (dentry) { |
| 96 |
struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 97 |
@@ -516,3 +512,16 @@ int autofs4_expire_multi(struct super_bl |
| 98 |
return ret; |
| 99 |
} |
| 100 |
|
| 101 |
+/* Call repeatedly until it returns -EAGAIN, meaning there's nothing |
| 102 |
+ more to be done */ |
| 103 |
+int autofs4_expire_multi(struct super_block *sb, struct vfsmount *mnt, |
| 104 |
+ struct autofs_sb_info *sbi, int __user *arg) |
| 105 |
+{ |
| 106 |
+ int do_now = 0; |
| 107 |
+ |
| 108 |
+ if (arg && get_user(do_now, arg)) |
| 109 |
+ return -EFAULT; |
| 110 |
+ |
| 111 |
+ return autofs4_do_expire_multi(sb, mnt, sbi, do_now); |
| 112 |
+} |
| 113 |
+ |
| 114 |
--- linux-2.6.29.orig/fs/autofs4/root.c |
| 115 |
+++ linux-2.6.29/fs/autofs4/root.c |
| 116 |
@@ -485,22 +485,6 @@ static struct dentry *autofs4_lookup(str |
| 117 |
DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", |
| 118 |
current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); |
| 119 |
|
| 120 |
- expiring = autofs4_lookup_expiring(sbi, dentry->d_parent, &dentry->d_name); |
| 121 |
- if (expiring) { |
| 122 |
- /* |
| 123 |
- * If we are racing with expire the request might not |
| 124 |
- * be quite complete but the directory has been removed |
| 125 |
- * so it must have been successful, so just wait for it. |
| 126 |
- */ |
| 127 |
- ino = autofs4_dentry_ino(expiring); |
| 128 |
- autofs4_expire_wait(expiring); |
| 129 |
- spin_lock(&sbi->lookup_lock); |
| 130 |
- if (!list_empty(&ino->expiring)) |
| 131 |
- list_del_init(&ino->expiring); |
| 132 |
- spin_unlock(&sbi->lookup_lock); |
| 133 |
- dput(expiring); |
| 134 |
- } |
| 135 |
- |
| 136 |
unhashed = autofs4_lookup_active(sbi, dentry->d_parent, &dentry->d_name); |
| 137 |
if (unhashed) |
| 138 |
dentry = unhashed; |
| 139 |
@@ -538,14 +522,31 @@ static struct dentry *autofs4_lookup(str |
| 140 |
} |
| 141 |
|
| 142 |
if (!oz_mode) { |
| 143 |
+ mutex_unlock(&dir->i_mutex); |
| 144 |
+ expiring = autofs4_lookup_expiring(sbi, |
| 145 |
+ dentry->d_parent, |
| 146 |
+ &dentry->d_name); |
| 147 |
+ if (expiring) { |
| 148 |
+ /* |
| 149 |
+ * If we are racing with expire the request might not |
| 150 |
+ * be quite complete but the directory has been removed |
| 151 |
+ * so it must have been successful, so just wait for it. |
| 152 |
+ */ |
| 153 |
+ ino = autofs4_dentry_ino(expiring); |
| 154 |
+ autofs4_expire_wait(expiring); |
| 155 |
+ spin_lock(&sbi->lookup_lock); |
| 156 |
+ if (!list_empty(&ino->expiring)) |
| 157 |
+ list_del_init(&ino->expiring); |
| 158 |
+ spin_unlock(&sbi->lookup_lock); |
| 159 |
+ dput(expiring); |
| 160 |
+ } |
| 161 |
+ |
| 162 |
spin_lock(&dentry->d_lock); |
| 163 |
dentry->d_flags |= DCACHE_AUTOFS_PENDING; |
| 164 |
spin_unlock(&dentry->d_lock); |
| 165 |
- if (dentry->d_op && dentry->d_op->d_revalidate) { |
| 166 |
- mutex_unlock(&dir->i_mutex); |
| 167 |
+ if (dentry->d_op && dentry->d_op->d_revalidate) |
| 168 |
(dentry->d_op->d_revalidate)(dentry, nd); |
| 169 |
- mutex_lock(&dir->i_mutex); |
| 170 |
- } |
| 171 |
+ mutex_lock(&dir->i_mutex); |
| 172 |
} |
| 173 |
|
| 174 |
/* |
| 175 |
--- linux-2.6.29.orig/include/linux/auto_dev-ioctl.h |
| 176 |
+++ linux-2.6.29/include/linux/auto_dev-ioctl.h |
| 177 |
@@ -10,8 +10,13 @@ |
| 178 |
#ifndef _LINUX_AUTO_DEV_IOCTL_H |
| 179 |
#define _LINUX_AUTO_DEV_IOCTL_H |
| 180 |
|
| 181 |
+#include <linux/auto_fs.h> |
| 182 |
+ |
| 183 |
+#ifdef __KERNEL__ |
| 184 |
#include <linux/string.h> |
| 185 |
-#include <linux/types.h> |
| 186 |
+#else |
| 187 |
+#include <string.h> |
| 188 |
+#endif /* __KERNEL__ */ |
| 189 |
|
| 190 |
#define AUTOFS_DEVICE_NAME "autofs" |
| 191 |
|
| 192 |
--- linux-2.6.29.orig/include/linux/auto_fs.h |
| 193 |
+++ linux-2.6.29/include/linux/auto_fs.h |
| 194 |
@@ -17,11 +17,13 @@ |
| 195 |
#ifdef __KERNEL__ |
| 196 |
#include <linux/fs.h> |
| 197 |
#include <linux/limits.h> |
| 198 |
+#include <linux/types.h> |
| 199 |
+#include <linux/ioctl.h> |
| 200 |
+#else |
| 201 |
#include <asm/types.h> |
| 202 |
+#include <sys/ioctl.h> |
| 203 |
#endif /* __KERNEL__ */ |
| 204 |
|
| 205 |
-#include <linux/ioctl.h> |
| 206 |
- |
| 207 |
/* This file describes autofs v3 */ |
| 208 |
#define AUTOFS_PROTO_VERSION 3 |
| 209 |
|
| 210 |
--- linux-2.6.29.orig/fs/autofs4/waitq.c |
| 211 |
+++ linux-2.6.29/fs/autofs4/waitq.c |
| 212 |
@@ -297,20 +297,14 @@ static int validate_request(struct autof |
| 213 |
*/ |
| 214 |
if (notify == NFY_MOUNT) { |
| 215 |
/* |
| 216 |
- * If the dentry isn't hashed just go ahead and try the |
| 217 |
- * mount again with a new wait (not much else we can do). |
| 218 |
- */ |
| 219 |
- if (!d_unhashed(dentry)) { |
| 220 |
- /* |
| 221 |
- * But if the dentry is hashed, that means that we |
| 222 |
- * got here through the revalidate path. Thus, we |
| 223 |
- * need to check if the dentry has been mounted |
| 224 |
- * while we waited on the wq_mutex. If it has, |
| 225 |
- * simply return success. |
| 226 |
- */ |
| 227 |
- if (d_mountpoint(dentry)) |
| 228 |
- return 0; |
| 229 |
- } |
| 230 |
+ * If the dentry was successfully mounted while we slept |
| 231 |
+ * on the wait queue mutex we can return success. If it |
| 232 |
+ * isn't mounted (doesn't have submounts for the case of |
| 233 |
+ * a multi-mount with no mount at it's base) we can |
| 234 |
+ * continue on and create a new request. |
| 235 |
+ */ |
| 236 |
+ if (have_submounts(dentry)) |
| 237 |
+ return 0; |
| 238 |
} |
| 239 |
|
| 240 |
return 1; |