aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exportfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-07-17 07:04:29 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:06 -0400
commit5ca29607331fe37980dc3b488793ef8b1409b722 (patch)
treecf4e5ad786aeebc8d82d1b867ab3d91d0cb4b824 /fs/exportfs
parenta569425512253992cc64ebf8b6d00a62f986db3e (diff)
knfsd: exportfs: remove iget abuse
When the exportfs interface was added the expectation was that filesystems provide an operation to convert from a file handle to an inode/dentry, but it kept a backwards compat option that still calls into iget. Calling into iget from non-filesystem code is very bad, because it gives too little information to filesystem, and simply crashes if the filesystem doesn't implement the ->read_inode routine. Fortunately there are only two filesystems left using this fallback: efs and jfs. This patch moves a copy of export_iget to each of those to implement the get_dentry method. While this is a temporary increase of lines of code in the kernel it allows for a much cleaner interface and important code restructuring in later patches. [akpm@linux-foundation.org: add jfs_get_inode_flags() declaration] Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exportfs')
-rw-r--r--fs/exportfs/expfs.c56
1 files changed, 3 insertions, 53 deletions
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 16287af34859..dd132bb7b8f8 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -391,61 +391,11 @@ out:
391 return error; 391 return error;
392} 392}
393 393
394 394static struct dentry *get_dentry(struct super_block *sb, void *vobjp)
395static struct dentry *export_iget(struct super_block *sb, unsigned long ino, __u32 generation)
396{ 395{
397 396 return ERR_PTR(-ESTALE);
398 /* iget isn't really right if the inode is currently unallocated!!
399 * This should really all be done inside each filesystem
400 *
401 * ext2fs' read_inode has been strengthed to return a bad_inode if
402 * the inode had been deleted.
403 *
404 * Currently we don't know the generation for parent directory, so
405 * a generation of 0 means "accept any"
406 */
407 struct inode *inode;
408 struct dentry *result;
409 if (ino == 0)
410 return ERR_PTR(-ESTALE);
411 inode = iget(sb, ino);
412 if (inode == NULL)
413 return ERR_PTR(-ENOMEM);
414 if (is_bad_inode(inode)
415 || (generation && inode->i_generation != generation)
416 ) {
417 /* we didn't find the right inode.. */
418 dprintk("fh_verify: Inode %lu, Bad count: %d %d or version %u %u\n",
419 inode->i_ino,
420 inode->i_nlink, atomic_read(&inode->i_count),
421 inode->i_generation,
422 generation);
423
424 iput(inode);
425 return ERR_PTR(-ESTALE);
426 }
427 /* now to find a dentry.
428 * If possible, get a well-connected one
429 */
430 result = d_alloc_anon(inode);
431 if (!result) {
432 iput(inode);
433 return ERR_PTR(-ENOMEM);
434 }
435 return result;
436} 397}
437 398
438
439static struct dentry *get_object(struct super_block *sb, void *vobjp)
440{
441 __u32 *objp = vobjp;
442 unsigned long ino = objp[0];
443 __u32 generation = objp[1];
444
445 return export_iget(sb, ino, generation);
446}
447
448
449/** 399/**
450 * export_encode_fh - default export_operations->encode_fh function 400 * export_encode_fh - default export_operations->encode_fh function
451 * @dentry: the dentry to encode 401 * @dentry: the dentry to encode
@@ -524,7 +474,7 @@ struct export_operations export_op_default = {
524 474
525 .get_name = get_name, 475 .get_name = get_name,
526 .get_parent = get_parent, 476 .get_parent = get_parent,
527 .get_dentry = get_object, 477 .get_dentry = get_dentry,
528}; 478};
529 479
530EXPORT_SYMBOL(export_op_default); 480EXPORT_SYMBOL(export_op_default);