From 2be3c79046cf90d75d436708a4e0898c7a1f9d51 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 20 Feb 2007 13:58:11 -0800 Subject: [PATCH] affs: implement ->drop_inode affs wants to truncate the inode when the last user goes away, currently it does that through a potentially racy i_count check in ->put_inode. But we already have a method that's called just after the we dropped the last reference, ->drop_inode. This patch implements affs_drop_inode to take advantage of this. Signed-off-by: Christoph Hellwig Cc: Roman Zippel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/affs/inode.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'fs/affs/inode.c') diff --git a/fs/affs/inode.c b/fs/affs/inode.c index fce6848a4641..c5b9d73c084a 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -243,12 +243,17 @@ affs_put_inode(struct inode *inode) { pr_debug("AFFS: put_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); affs_free_prealloc(inode); - if (atomic_read(&inode->i_count) == 1) { - mutex_lock(&inode->i_mutex); - if (inode->i_size != AFFS_I(inode)->mmu_private) - affs_truncate(inode); - mutex_unlock(&inode->i_mutex); - } +} + +void +affs_drop_inode(struct inode *inode) +{ + mutex_lock(&inode->i_mutex); + if (inode->i_size != AFFS_I(inode)->mmu_private) + affs_truncate(inode); + mutex_unlock(&inode->i_mutex); + + generic_drop_inode(inode); } void -- cgit v1.2.3