aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs/inode.c
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/autofs/inode.c
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/autofs/inode.c')
-rw-r--r--fs/autofs/inode.c27
1 files changed, 18 insertions, 9 deletions
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}