aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2008-02-07 03:15:30 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:27 -0500
commit62328a02399ea7f1b26b06d757abe67b9cf48193 (patch)
tree11ac645b65d8735db96c962c814b80adf6e8f195 /fs
parent210f855963ba5edc4c7150754a79709a7c8a0d3c (diff)
iget: stop autofs from using iget() and read_inode()
Stop the autofs filesystem from using iget() and read_inode(). Replace autofs_read_inode() with autofs_iget(), and call that instead of iget(). autofs_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. Signed-off-by: David Howells <dhowells@redhat.com> Cc: Ian Kent <raven@themaw.net> Acked-by: Christoph Hellwig <hch@lst.de> 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.h1
-rw-r--r--fs/autofs/inode.c27
-rw-r--r--fs/autofs/root.c22
3 files changed, 37 insertions, 13 deletions
diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h
index 8b4cca3c4705..901a3e67ec45 100644
--- a/fs/autofs/autofs_i.h
+++ b/fs/autofs/autofs_i.h
@@ -150,6 +150,7 @@ extern const struct file_operations autofs_root_operations;
150 150
151int autofs_fill_super(struct super_block *, void *, int); 151int autofs_fill_super(struct super_block *, void *, int);
152void autofs_kill_sb(struct super_block *sb); 152void autofs_kill_sb(struct super_block *sb);
153struct inode *autofs_iget(struct super_block *, unsigned long);
153 154
154/* Queue management functions */ 155/* Queue management functions */
155 156
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 45f5992a0957..708bdb89fea1 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -52,10 +52,7 @@ out_kill_sb:
52 kill_anon_super(sb); 52 kill_anon_super(sb);
53} 53}
54 54
55static void autofs_read_inode(struct inode *inode);
56
57static const struct super_operations autofs_sops = { 55static const struct super_operations autofs_sops = {
58 .read_inode = autofs_read_inode,
59 .statfs = simple_statfs, 56 .statfs = simple_statfs,
60}; 57};
61 58
@@ -164,7 +161,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
164 s->s_time_gran = 1; 161 s->s_time_gran = 1;
165 sbi->sb = s; 162 sbi->sb = s;
166 163
167 root_inode = iget(s, AUTOFS_ROOT_INO); 164 root_inode = autofs_iget(s, AUTOFS_ROOT_INO);
165 if (IS_ERR(root_inode))
166 goto fail_free;
168 root = d_alloc_root(root_inode); 167 root = d_alloc_root(root_inode);
169 pipe = NULL; 168 pipe = NULL;
170 169
@@ -230,11 +229,17 @@ fail_unlock:
230 return -EINVAL; 229 return -EINVAL;
231} 230}
232 231
233static void autofs_read_inode(struct inode *inode) 232struct inode *autofs_iget(struct super_block *sb, unsigned long ino)
234{ 233{
235 ino_t ino = inode->i_ino;
236 unsigned int n; 234 unsigned int n;
237 struct autofs_sb_info *sbi = autofs_sbi(inode->i_sb); 235 struct autofs_sb_info *sbi = autofs_sbi(sb);
236 struct inode *inode;
237
238 inode = iget_locked(sb, ino);
239 if (!inode)
240 return ERR_PTR(-ENOMEM);
241 if (!(inode->i_state & I_NEW))
242 return inode;
238 243
239 /* Initialize to the default case (stub directory) */ 244 /* Initialize to the default case (stub directory) */
240 245
@@ -250,7 +255,7 @@ static void autofs_read_inode(struct inode *inode)
250 inode->i_op = &autofs_root_inode_operations; 255 inode->i_op = &autofs_root_inode_operations;
251 inode->i_fop = &autofs_root_operations; 256 inode->i_fop = &autofs_root_operations;
252 inode->i_uid = inode->i_gid = 0; /* Changed in read_super */ 257 inode->i_uid = inode->i_gid = 0; /* Changed in read_super */
253 return; 258 goto done;
254 } 259 }
255 260
256 inode->i_uid = inode->i_sb->s_root->d_inode->i_uid; 261 inode->i_uid = inode->i_sb->s_root->d_inode->i_uid;
@@ -263,7 +268,7 @@ static void autofs_read_inode(struct inode *inode)
263 n = ino - AUTOFS_FIRST_SYMLINK; 268 n = ino - AUTOFS_FIRST_SYMLINK;
264 if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) { 269 if (n >= AUTOFS_MAX_SYMLINKS || !test_bit(n,sbi->symlink_bitmap)) {
265 printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino); 270 printk("autofs: Looking for bad symlink inode %u\n", (unsigned int) ino);
266 return; 271 goto done;
267 } 272 }
268 273
269 inode->i_op = &autofs_symlink_inode_operations; 274 inode->i_op = &autofs_symlink_inode_operations;
@@ -275,4 +280,8 @@ static void autofs_read_inode(struct inode *inode)
275 inode->i_size = sl->len; 280 inode->i_size = sl->len;
276 inode->i_nlink = 1; 281 inode->i_nlink = 1;
277 } 282 }
283
284done:
285 unlock_new_inode(inode);
286 return inode;
278} 287}
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 5efff3c0d886..8aacade56956 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -114,8 +114,8 @@ static int try_to_fill_dentry(struct dentry *dentry, struct super_block *sb, str
114 dentry->d_time = (unsigned long) ent; 114 dentry->d_time = (unsigned long) ent;
115 115
116 if (!dentry->d_inode) { 116 if (!dentry->d_inode) {
117 inode = iget(sb, ent->ino); 117 inode = autofs_iget(sb, ent->ino);
118 if (!inode) { 118 if (IS_ERR(inode)) {
119 /* Failed, but leave pending for next time */ 119 /* Failed, but leave pending for next time */
120 return 1; 120 return 1;
121 } 121 }
@@ -274,6 +274,7 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
274 unsigned int n; 274 unsigned int n;
275 int slsize; 275 int slsize;
276 struct autofs_symlink *sl; 276 struct autofs_symlink *sl;
277 struct inode *inode;
277 278
278 DPRINTK(("autofs_root_symlink: %s <- ", symname)); 279 DPRINTK(("autofs_root_symlink: %s <- ", symname));
279 autofs_say(dentry->d_name.name,dentry->d_name.len); 280 autofs_say(dentry->d_name.name,dentry->d_name.len);
@@ -331,7 +332,12 @@ static int autofs_root_symlink(struct inode *dir, struct dentry *dentry, const c
331 ent->dentry = NULL; /* We don't keep the dentry for symlinks */ 332 ent->dentry = NULL; /* We don't keep the dentry for symlinks */
332 333
333 autofs_hash_insert(dh,ent); 334 autofs_hash_insert(dh,ent);
334 d_instantiate(dentry, iget(dir->i_sb,ent->ino)); 335
336 inode = autofs_iget(dir->i_sb, ent->ino);
337 if (IS_ERR(inode))
338 return PTR_ERR(inode);
339
340 d_instantiate(dentry, inode);
335 unlock_kernel(); 341 unlock_kernel();
336 return 0; 342 return 0;
337} 343}
@@ -428,6 +434,7 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
428 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb); 434 struct autofs_sb_info *sbi = autofs_sbi(dir->i_sb);
429 struct autofs_dirhash *dh = &sbi->dirhash; 435 struct autofs_dirhash *dh = &sbi->dirhash;
430 struct autofs_dir_ent *ent; 436 struct autofs_dir_ent *ent;
437 struct inode *inode;
431 ino_t ino; 438 ino_t ino;
432 439
433 lock_kernel(); 440 lock_kernel();
@@ -469,7 +476,14 @@ static int autofs_root_mkdir(struct inode *dir, struct dentry *dentry, int mode)
469 autofs_hash_insert(dh,ent); 476 autofs_hash_insert(dh,ent);
470 477
471 inc_nlink(dir); 478 inc_nlink(dir);
472 d_instantiate(dentry, iget(dir->i_sb,ino)); 479
480 inode = autofs_iget(dir->i_sb, ino);
481 if (IS_ERR(inode)) {
482 drop_nlink(dir);
483 return PTR_ERR(inode);
484 }
485
486 d_instantiate(dentry, inode);
473 unlock_kernel(); 487 unlock_kernel();
474 488
475 return 0; 489 return 0;