aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2005-05-17 18:53:14 -0400
committerTony Luck <tony.luck@intel.com>2005-05-17 18:53:14 -0400
commit325a479c4c110db278ef3361460a48c4093252cc (patch)
treebcfbf4d0647d9442045639a5c19da59d55190e81 /fs/autofs4
parentebcc80c1b6629a445f7471cc1ddb48faf8a84e70 (diff)
parent7f9eaedf894dbaa08c157832e9a6c9c03ffed1ed (diff)
Merge with temp tree to get David's gdb inferior calls patch
Diffstat (limited to 'fs/autofs4')
-rw-r--r--fs/autofs4/autofs_i.h15
-rw-r--r--fs/autofs4/expire.c16
-rw-r--r--fs/autofs4/inode.c1
-rw-r--r--fs/autofs4/waitq.c22
4 files changed, 40 insertions, 14 deletions
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index f5a52c871726..c7b2b8890188 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -84,6 +84,7 @@ struct autofs_wait_queue {
84 char *name; 84 char *name;
85 /* This is for status reporting upon return */ 85 /* This is for status reporting upon return */
86 int status; 86 int status;
87 atomic_t notified;
87 atomic_t wait_ctr; 88 atomic_t wait_ctr;
88}; 89};
89 90
@@ -101,6 +102,7 @@ struct autofs_sb_info {
101 int needs_reghost; 102 int needs_reghost;
102 struct super_block *sb; 103 struct super_block *sb;
103 struct semaphore wq_sem; 104 struct semaphore wq_sem;
105 spinlock_t fs_lock;
104 struct autofs_wait_queue *queues; /* Wait queue pointer */ 106 struct autofs_wait_queue *queues; /* Wait queue pointer */
105}; 107};
106 108
@@ -126,9 +128,18 @@ static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
126static inline int autofs4_ispending(struct dentry *dentry) 128static inline int autofs4_ispending(struct dentry *dentry)
127{ 129{
128 struct autofs_info *inf = autofs4_dentry_ino(dentry); 130 struct autofs_info *inf = autofs4_dentry_ino(dentry);
131 int pending = 0;
129 132
130 return (dentry->d_flags & DCACHE_AUTOFS_PENDING) || 133 if (dentry->d_flags & DCACHE_AUTOFS_PENDING)
131 (inf != NULL && inf->flags & AUTOFS_INF_EXPIRING); 134 return 1;
135
136 if (inf) {
137 spin_lock(&inf->sbi->fs_lock);
138 pending = inf->flags & AUTOFS_INF_EXPIRING;
139 spin_unlock(&inf->sbi->fs_lock);
140 }
141
142 return pending;
132} 143}
133 144
134static inline void autofs4_copy_atime(struct file *src, struct file *dst) 145static inline void autofs4_copy_atime(struct file *src, struct file *dst)
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index 31540a6404d9..500425e24fba 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -99,6 +99,10 @@ static int autofs4_check_tree(struct vfsmount *mnt,
99 if (!autofs4_can_expire(top, timeout, do_now)) 99 if (!autofs4_can_expire(top, timeout, do_now))
100 return 0; 100 return 0;
101 101
102 /* Is someone visiting anywhere in the tree ? */
103 if (may_umount_tree(mnt))
104 return 0;
105
102 spin_lock(&dcache_lock); 106 spin_lock(&dcache_lock);
103repeat: 107repeat:
104 next = this_parent->d_subdirs.next; 108 next = this_parent->d_subdirs.next;
@@ -270,10 +274,18 @@ static struct dentry *autofs4_expire(struct super_block *sb,
270 274
271 /* Case 2: tree mount, expire iff entire tree is not busy */ 275 /* Case 2: tree mount, expire iff entire tree is not busy */
272 if (!exp_leaves) { 276 if (!exp_leaves) {
277 /* Lock the tree as we must expire as a whole */
278 spin_lock(&sbi->fs_lock);
273 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) { 279 if (autofs4_check_tree(mnt, dentry, timeout, do_now)) {
274 expired = dentry; 280 struct autofs_info *inf = autofs4_dentry_ino(dentry);
275 break; 281
282 /* Set this flag early to catch sys_chdir and the like */
283 inf->flags |= AUTOFS_INF_EXPIRING;
284 spin_unlock(&sbi->fs_lock);
285 expired = dentry;
286 break;
276 } 287 }
288 spin_unlock(&sbi->fs_lock);
277 /* Case 3: direct mount, expire individual leaves */ 289 /* Case 3: direct mount, expire individual leaves */
278 } else { 290 } else {
279 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now); 291 expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index a52560746628..4bb14cc68040 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -206,6 +206,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
206 sbi->version = 0; 206 sbi->version = 0;
207 sbi->sub_version = 0; 207 sbi->sub_version = 0;
208 init_MUTEX(&sbi->wq_sem); 208 init_MUTEX(&sbi->wq_sem);
209 spin_lock_init(&sbi->fs_lock);
209 sbi->queues = NULL; 210 sbi->queues = NULL;
210 s->s_blocksize = 1024; 211 s->s_blocksize = 1024;
211 s->s_blocksize_bits = 10; 212 s->s_blocksize_bits = 10;
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 1ab24a662e09..5a40d36e5a51 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -210,17 +210,8 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
210 wq->len = len; 210 wq->len = len;
211 wq->status = -EINTR; /* Status return if interrupted */ 211 wq->status = -EINTR; /* Status return if interrupted */
212 atomic_set(&wq->wait_ctr, 2); 212 atomic_set(&wq->wait_ctr, 2);
213 atomic_set(&wq->notified, 1);
213 up(&sbi->wq_sem); 214 up(&sbi->wq_sem);
214
215 DPRINTK("new wait id = 0x%08lx, name = %.*s, nfy=%d",
216 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
217 /* autofs4_notify_daemon() may block */
218 if (notify != NFY_NONE) {
219 autofs4_notify_daemon(sbi,wq,
220 notify == NFY_MOUNT ?
221 autofs_ptype_missing :
222 autofs_ptype_expire_multi);
223 }
224 } else { 215 } else {
225 atomic_inc(&wq->wait_ctr); 216 atomic_inc(&wq->wait_ctr);
226 up(&sbi->wq_sem); 217 up(&sbi->wq_sem);
@@ -229,6 +220,17 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
229 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify); 220 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
230 } 221 }
231 222
223 if (notify != NFY_NONE && atomic_dec_and_test(&wq->notified)) {
224 int type = (notify == NFY_MOUNT ?
225 autofs_ptype_missing : autofs_ptype_expire_multi);
226
227 DPRINTK(("new wait id = 0x%08lx, name = %.*s, nfy=%d\n",
228 (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify));
229
230 /* autofs4_notify_daemon() may block */
231 autofs4_notify_daemon(sbi, wq, type);
232 }
233
232 /* wq->name is NULL if and only if the lock is already released */ 234 /* wq->name is NULL if and only if the lock is already released */
233 235
234 if ( sbi->catatonic ) { 236 if ( sbi->catatonic ) {