From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH][RFC] fix reservation discarding in affs Date: Thu, 10 Feb 2005 11:39:47 +0100 Message-ID: <20050210103947.GA2622@lst.de> References: <20041212134545.GA6612@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org Received: from verein.lst.de ([213.95.11.210]:6353 "EHLO mail.lst.de") by vger.kernel.org with ESMTP id S262092AbVBJKju (ORCPT ); Thu, 10 Feb 2005 05:39:50 -0500 To: zippel@linux-m68k.org Content-Disposition: inline In-Reply-To: <20041212134545.GA6612@lst.de> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Sun, Dec 12, 2004 at 02:45:45PM +0100, Christoph Hellwig wrote: > 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. ping? --- 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);