Currently affs discards preallocations in every ->put_inode but we
really want to do this in
a) ->release when a filedescriptor is closed and
b) in ->clear_inode to avoid leaking reservations for shared writeable
mappings
affs already does it in a) and a few other places, so adding it to
affs_clear_inode should make it behave fine. Also move the truncate
from affs_put_inode with the racy i_count check to affs_clear_inode.
This also avoids the need to take the inode semaphore as the inode can't
be accessed from other threads anymore.
--- 1.21/fs/affs/inode.c 2004-09-17 08:58:42 +02:00
+++ edited/fs/affs/inode.c 2004-12-10 20:21:40 +01:00
@@ -258,19 +258,6 @@
}
void
-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) {
- down(&inode->i_sem);
- if (inode->i_size != AFFS_I(inode)->mmu_private)
- affs_truncate(inode);
- up(&inode->i_sem);
- }
-}
-
-void
affs_delete_inode(struct inode *inode)
{
pr_debug("AFFS: delete_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
@@ -287,6 +274,12 @@
unsigned long cache_page = (unsigned long) AFFS_I(inode)->i_lc;
pr_debug("AFFS: clear_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
+
+ affs_free_prealloc(inode);
+
+ if (inode->i_size != AFFS_I(inode)->mmu_private)
+ affs_truncate(inode);
+
if (cache_page) {
pr_debug("AFFS: freeing ext cache\n");
AFFS_I(inode)->i_lc = NULL;
===== fs/affs/super.c 1.46 vs edited =====
--- 1.46/fs/affs/super.c 2004-09-04 05:11:01 +02:00
+++ edited/fs/affs/super.c 2004-12-10 20:19:18 +01:00
@@ -133,7 +133,6 @@
.destroy_inode = affs_destroy_inode,
.read_inode = affs_read_inode,
.write_inode = affs_write_inode,
- .put_inode = affs_put_inode,
.delete_inode = affs_delete_inode,
.clear_inode = affs_clear_inode,
.put_super = affs_put_super,
--- 1.9/include/linux/affs_fs.h 2004-09-17 08:58:43 +02:00
+++ edited/include/linux/affs_fs.h 2004-12-10 20:19:12 +01:00
@@ -58,7 +58,6 @@
extern unsigned long affs_parent_ino(struct inode *dir);
extern struct inode *affs_new_inode(struct inode *dir);
extern int affs_notify_change(struct dentry *dentry, struct iattr *attr);
-extern void affs_put_inode(struct inode *inode);
extern void affs_delete_inode(struct inode *inode);
extern void affs_clear_inode(struct inode *inode);
extern void affs_read_inode(struct inode *inode);
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html