Commit 2be3c790 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[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: default avatarChristoph Hellwig <hch@lst.de>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c9ffec48
...@@ -171,6 +171,7 @@ extern unsigned long affs_parent_ino(struct inode *dir); ...@@ -171,6 +171,7 @@ extern unsigned long affs_parent_ino(struct inode *dir);
extern struct inode *affs_new_inode(struct inode *dir); extern struct inode *affs_new_inode(struct inode *dir);
extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); extern int affs_notify_change(struct dentry *dentry, struct iattr *attr);
extern void affs_put_inode(struct inode *inode); extern void affs_put_inode(struct inode *inode);
extern void affs_drop_inode(struct inode *inode);
extern void affs_delete_inode(struct inode *inode); extern void affs_delete_inode(struct inode *inode);
extern void affs_clear_inode(struct inode *inode); extern void affs_clear_inode(struct inode *inode);
extern void affs_read_inode(struct inode *inode); extern void affs_read_inode(struct inode *inode);
......
...@@ -243,12 +243,17 @@ affs_put_inode(struct inode *inode) ...@@ -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); pr_debug("AFFS: put_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
affs_free_prealloc(inode); affs_free_prealloc(inode);
if (atomic_read(&inode->i_count) == 1) { }
void
affs_drop_inode(struct inode *inode)
{
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
if (inode->i_size != AFFS_I(inode)->mmu_private) if (inode->i_size != AFFS_I(inode)->mmu_private)
affs_truncate(inode); affs_truncate(inode);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
}
generic_drop_inode(inode);
} }
void void
......
...@@ -118,6 +118,7 @@ static const struct super_operations affs_sops = { ...@@ -118,6 +118,7 @@ static const struct super_operations affs_sops = {
.read_inode = affs_read_inode, .read_inode = affs_read_inode,
.write_inode = affs_write_inode, .write_inode = affs_write_inode,
.put_inode = affs_put_inode, .put_inode = affs_put_inode,
.drop_inode = affs_drop_inode,
.delete_inode = affs_delete_inode, .delete_inode = affs_delete_inode,
.clear_inode = affs_clear_inode, .clear_inode = affs_clear_inode,
.put_super = affs_put_super, .put_super = affs_put_super,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment