diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-06-22 23:25:17 -0400 |
---|---|---|
committer | Niv Sardi <xaiki@debian.org> | 2008-07-28 02:58:58 -0400 |
commit | 8f112e3bc3508afc8d1612868d178359446c08fd (patch) | |
tree | 64a03e036369ab3819f6675698454a8a250097d1 /fs/xfs/linux-2.6/xfs_iops.c | |
parent | 61f10fad1947116055c694321d9d8f21152c0582 (diff) |
[XFS] Merge xfs_rmdir into xfs_remove
xfs_remove and xfs_rmdir are almost the same with a little more work
performed in xfs_rmdir due to the . and .. entries. This patch merges
xfs_rmdir into xfs_remove and performs these actions conditionally.
Also clean up the error handling which was a nightmare in both versions
before.
SGI-PV: 981498
SGI-Modid: xfs-linux-melb:xfs-kern:31335a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Barry Naujok <bnaujok@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_iops.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 3ae80155de3a..1f89c19cd4c4 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -245,8 +245,7 @@ STATIC void | |||
245 | xfs_cleanup_inode( | 245 | xfs_cleanup_inode( |
246 | struct inode *dir, | 246 | struct inode *dir, |
247 | struct inode *inode, | 247 | struct inode *inode, |
248 | struct dentry *dentry, | 248 | struct dentry *dentry) |
249 | int mode) | ||
250 | { | 249 | { |
251 | struct xfs_name teardown; | 250 | struct xfs_name teardown; |
252 | 251 | ||
@@ -257,10 +256,7 @@ xfs_cleanup_inode( | |||
257 | */ | 256 | */ |
258 | xfs_dentry_to_name(&teardown, dentry); | 257 | xfs_dentry_to_name(&teardown, dentry); |
259 | 258 | ||
260 | if (S_ISDIR(mode)) | 259 | xfs_remove(XFS_I(dir), &teardown, XFS_I(inode)); |
261 | xfs_rmdir(XFS_I(dir), &teardown, XFS_I(inode)); | ||
262 | else | ||
263 | xfs_remove(XFS_I(dir), &teardown, XFS_I(inode)); | ||
264 | iput(inode); | 260 | iput(inode); |
265 | } | 261 | } |
266 | 262 | ||
@@ -342,7 +338,7 @@ xfs_vn_mknod( | |||
342 | return -error; | 338 | return -error; |
343 | 339 | ||
344 | out_cleanup_inode: | 340 | out_cleanup_inode: |
345 | xfs_cleanup_inode(dir, inode, dentry, mode); | 341 | xfs_cleanup_inode(dir, inode, dentry); |
346 | out_free_acl: | 342 | out_free_acl: |
347 | if (default_acl) | 343 | if (default_acl) |
348 | _ACL_FREE(default_acl); | 344 | _ACL_FREE(default_acl); |
@@ -518,38 +514,12 @@ xfs_vn_symlink( | |||
518 | return 0; | 514 | return 0; |
519 | 515 | ||
520 | out_cleanup_inode: | 516 | out_cleanup_inode: |
521 | xfs_cleanup_inode(dir, inode, dentry, 0); | 517 | xfs_cleanup_inode(dir, inode, dentry); |
522 | out: | 518 | out: |
523 | return -error; | 519 | return -error; |
524 | } | 520 | } |
525 | 521 | ||
526 | STATIC int | 522 | STATIC int |
527 | xfs_vn_rmdir( | ||
528 | struct inode *dir, | ||
529 | struct dentry *dentry) | ||
530 | { | ||
531 | struct inode *inode = dentry->d_inode; | ||
532 | struct xfs_name name; | ||
533 | int error; | ||
534 | |||
535 | xfs_dentry_to_name(&name, dentry); | ||
536 | |||
537 | error = xfs_rmdir(XFS_I(dir), &name, XFS_I(inode)); | ||
538 | if (likely(!error)) { | ||
539 | xfs_validate_fields(inode); | ||
540 | xfs_validate_fields(dir); | ||
541 | /* | ||
542 | * With rmdir, the VFS makes the dentry "negative": no inode, | ||
543 | * but still hashed. This is incompatible with case-insensitive | ||
544 | * mode, so invalidate (unhash) the dentry in CI-mode. | ||
545 | */ | ||
546 | if (xfs_sb_version_hasasciici(&XFS_M(dir->i_sb)->m_sb)) | ||
547 | d_invalidate(dentry); | ||
548 | } | ||
549 | return -error; | ||
550 | } | ||
551 | |||
552 | STATIC int | ||
553 | xfs_vn_rename( | 523 | xfs_vn_rename( |
554 | struct inode *odir, | 524 | struct inode *odir, |
555 | struct dentry *odentry, | 525 | struct dentry *odentry, |
@@ -842,7 +812,13 @@ const struct inode_operations xfs_dir_inode_operations = { | |||
842 | .unlink = xfs_vn_unlink, | 812 | .unlink = xfs_vn_unlink, |
843 | .symlink = xfs_vn_symlink, | 813 | .symlink = xfs_vn_symlink, |
844 | .mkdir = xfs_vn_mkdir, | 814 | .mkdir = xfs_vn_mkdir, |
845 | .rmdir = xfs_vn_rmdir, | 815 | /* |
816 | * Yes, XFS uses the same method for rmdir and unlink. | ||
817 | * | ||
818 | * There are some subtile differences deeper in the code, | ||
819 | * but we use S_ISDIR to check for those. | ||
820 | */ | ||
821 | .rmdir = xfs_vn_unlink, | ||
846 | .mknod = xfs_vn_mknod, | 822 | .mknod = xfs_vn_mknod, |
847 | .rename = xfs_vn_rename, | 823 | .rename = xfs_vn_rename, |
848 | .permission = xfs_vn_permission, | 824 | .permission = xfs_vn_permission, |
@@ -861,7 +837,13 @@ const struct inode_operations xfs_dir_ci_inode_operations = { | |||
861 | .unlink = xfs_vn_unlink, | 837 | .unlink = xfs_vn_unlink, |
862 | .symlink = xfs_vn_symlink, | 838 | .symlink = xfs_vn_symlink, |
863 | .mkdir = xfs_vn_mkdir, | 839 | .mkdir = xfs_vn_mkdir, |
864 | .rmdir = xfs_vn_rmdir, | 840 | /* |
841 | * Yes, XFS uses the same method for rmdir and unlink. | ||
842 | * | ||
843 | * There are some subtile differences deeper in the code, | ||
844 | * but we use S_ISDIR to check for those. | ||
845 | */ | ||
846 | .rmdir = xfs_vn_unlink, | ||
865 | .mknod = xfs_vn_mknod, | 847 | .mknod = xfs_vn_mknod, |
866 | .rename = xfs_vn_rename, | 848 | .rename = xfs_vn_rename, |
867 | .permission = xfs_vn_permission, | 849 | .permission = xfs_vn_permission, |