diff options
author | Sukadev Bhattiprolu <sukadev@us.ibm.com> | 2007-05-11 01:23:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-11 11:29:36 -0400 |
commit | fa0334f19f0e1a1e570fc2a160dfe53536599ade (patch) | |
tree | d223dcb53af7b5dd80958a1710c335ca942e1bcc /fs | |
parent | d78e53c89a820471837e0cb91fe36b7be1a7c9de (diff) |
Replace pid_t in autofs with struct pid reference
Make autofs container-friendly by caching struct pid reference rather than
pid_t and using pid_nr() to retreive a task's pid_t.
ChangeLog:
- Fix Eric Biederman's comments - Use find_get_pid() to hold a
reference to oz_pgrp and release while unmounting; separate out
changes to autofs and autofs4.
- Fix Cedric's comments: retain old prototype of parse_options()
and move necessary change to its caller.
Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: containers@lists.osdl.org
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/autofs/autofs_i.h | 4 | ||||
-rw-r--r-- | fs/autofs/inode.c | 20 | ||||
-rw-r--r-- | fs/autofs/root.c | 6 |
3 files changed, 22 insertions, 8 deletions
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h index 4ef544434b51..8b4cca3c4705 100644 --- a/fs/autofs/autofs_i.h +++ b/fs/autofs/autofs_i.h | |||
@@ -101,7 +101,7 @@ struct autofs_symlink { | |||
101 | struct autofs_sb_info { | 101 | struct autofs_sb_info { |
102 | u32 magic; | 102 | u32 magic; |
103 | struct file *pipe; | 103 | struct file *pipe; |
104 | pid_t oz_pgrp; | 104 | struct pid *oz_pgrp; |
105 | int catatonic; | 105 | int catatonic; |
106 | struct super_block *sb; | 106 | struct super_block *sb; |
107 | unsigned long exp_timeout; | 107 | unsigned long exp_timeout; |
@@ -122,7 +122,7 @@ static inline struct autofs_sb_info *autofs_sbi(struct super_block *sb) | |||
122 | filesystem without "magic".) */ | 122 | filesystem without "magic".) */ |
123 | 123 | ||
124 | static inline int autofs_oz_mode(struct autofs_sb_info *sbi) { | 124 | static inline int autofs_oz_mode(struct autofs_sb_info *sbi) { |
125 | return sbi->catatonic || process_group(current) == sbi->oz_pgrp; | 125 | return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp; |
126 | } | 126 | } |
127 | 127 | ||
128 | /* Hash operations */ | 128 | /* Hash operations */ |
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index d8315e61731e..e7204d71acc9 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c | |||
@@ -37,6 +37,8 @@ void autofs_kill_sb(struct super_block *sb) | |||
37 | if (!sbi->catatonic) | 37 | if (!sbi->catatonic) |
38 | autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ | 38 | autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ |
39 | 39 | ||
40 | put_pid(sbi->oz_pgrp); | ||
41 | |||
40 | autofs_hash_nuke(sbi); | 42 | autofs_hash_nuke(sbi); |
41 | for (n = 0; n < AUTOFS_MAX_SYMLINKS; n++) { | 43 | for (n = 0; n < AUTOFS_MAX_SYMLINKS; n++) { |
42 | if (test_bit(n, sbi->symlink_bitmap)) | 44 | if (test_bit(n, sbi->symlink_bitmap)) |
@@ -139,6 +141,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
139 | int pipefd; | 141 | int pipefd; |
140 | struct autofs_sb_info *sbi; | 142 | struct autofs_sb_info *sbi; |
141 | int minproto, maxproto; | 143 | int minproto, maxproto; |
144 | pid_t pgid; | ||
142 | 145 | ||
143 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 146 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
144 | if (!sbi) | 147 | if (!sbi) |
@@ -150,7 +153,6 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
150 | sbi->pipe = NULL; | 153 | sbi->pipe = NULL; |
151 | sbi->catatonic = 1; | 154 | sbi->catatonic = 1; |
152 | sbi->exp_timeout = 0; | 155 | sbi->exp_timeout = 0; |
153 | sbi->oz_pgrp = process_group(current); | ||
154 | autofs_initialize_hash(&sbi->dirhash); | 156 | autofs_initialize_hash(&sbi->dirhash); |
155 | sbi->queues = NULL; | 157 | sbi->queues = NULL; |
156 | memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN); | 158 | memset(sbi->symlink_bitmap, 0, sizeof(long)*AUTOFS_SYMLINK_BITMAP_LEN); |
@@ -171,7 +173,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
171 | 173 | ||
172 | /* Can this call block? - WTF cares? s is locked. */ | 174 | /* Can this call block? - WTF cares? s is locked. */ |
173 | if (parse_options(data, &pipefd, &root_inode->i_uid, | 175 | if (parse_options(data, &pipefd, &root_inode->i_uid, |
174 | &root_inode->i_gid, &sbi->oz_pgrp, &minproto, | 176 | &root_inode->i_gid, &pgid, &minproto, |
175 | &maxproto)) { | 177 | &maxproto)) { |
176 | printk("autofs: called with bogus options\n"); | 178 | printk("autofs: called with bogus options\n"); |
177 | goto fail_dput; | 179 | goto fail_dput; |
@@ -184,13 +186,21 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
184 | goto fail_dput; | 186 | goto fail_dput; |
185 | } | 187 | } |
186 | 188 | ||
187 | DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, sbi->oz_pgrp)); | 189 | DPRINTK(("autofs: pipe fd = %d, pgrp = %u\n", pipefd, pgid)); |
190 | sbi->oz_pgrp = find_get_pid(pgid); | ||
191 | |||
192 | if (!sbi->oz_pgrp) { | ||
193 | printk("autofs: could not find process group %d\n", pgid); | ||
194 | goto fail_dput; | ||
195 | } | ||
196 | |||
188 | pipe = fget(pipefd); | 197 | pipe = fget(pipefd); |
189 | 198 | ||
190 | if (!pipe) { | 199 | if (!pipe) { |
191 | printk("autofs: could not open pipe file descriptor\n"); | 200 | printk("autofs: could not open pipe file descriptor\n"); |
192 | goto fail_dput; | 201 | goto fail_put_pid; |
193 | } | 202 | } |
203 | |||
194 | if (!pipe->f_op || !pipe->f_op->write) | 204 | if (!pipe->f_op || !pipe->f_op->write) |
195 | goto fail_fput; | 205 | goto fail_fput; |
196 | sbi->pipe = pipe; | 206 | sbi->pipe = pipe; |
@@ -205,6 +215,8 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) | |||
205 | fail_fput: | 215 | fail_fput: |
206 | printk("autofs: pipe file descriptor does not contain proper ops\n"); | 216 | printk("autofs: pipe file descriptor does not contain proper ops\n"); |
207 | fput(pipe); | 217 | fput(pipe); |
218 | fail_put_pid: | ||
219 | put_pid(sbi->oz_pgrp); | ||
208 | fail_dput: | 220 | fail_dput: |
209 | dput(root); | 221 | dput(root); |
210 | goto fail_free; | 222 | goto fail_free; |
diff --git a/fs/autofs/root.c b/fs/autofs/root.c index 6fa04dd6d167..c1489533277a 100644 --- a/fs/autofs/root.c +++ b/fs/autofs/root.c | |||
@@ -213,8 +213,10 @@ static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentr | |||
213 | sbi = autofs_sbi(dir->i_sb); | 213 | sbi = autofs_sbi(dir->i_sb); |
214 | 214 | ||
215 | oz_mode = autofs_oz_mode(sbi); | 215 | oz_mode = autofs_oz_mode(sbi); |
216 | DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n", | 216 | DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, " |
217 | current->pid, process_group(current), sbi->catatonic, oz_mode)); | 217 | "oz_mode = %d\n", pid_nr(task_pid(current)), |
218 | process_group(current), sbi->catatonic, | ||
219 | oz_mode)); | ||
218 | 220 | ||
219 | /* | 221 | /* |
220 | * Mark the dentry incomplete, but add it. This is needed so | 222 | * Mark the dentry incomplete, but add it. This is needed so |