linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: zippel@linux-m68k.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] affs: implement ->drop_inode
Date: Sun, 11 Feb 2007 08:46:52 +0100	[thread overview]
Message-ID: <20070211074652.GA23605@lst.de> (raw)

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 <hch@lst.de>

Index: linux-2.6/fs/affs/affs.h
===================================================================
--- linux-2.6.orig/fs/affs/affs.h	2007-01-30 16:36:52.000000000 +0100
+++ linux-2.6/fs/affs/affs.h	2007-02-11 08:43:08.000000000 +0100
@@ -171,6 +171,7 @@
 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_drop_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);
Index: linux-2.6/fs/affs/inode.c
===================================================================
--- linux-2.6.orig/fs/affs/inode.c	2007-01-30 16:36:52.000000000 +0100
+++ linux-2.6/fs/affs/inode.c	2007-02-11 08:43:08.000000000 +0100
@@ -243,12 +243,17 @@
 {
 	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
Index: linux-2.6/fs/affs/super.c
===================================================================
--- linux-2.6.orig/fs/affs/super.c	2007-01-30 16:36:52.000000000 +0100
+++ linux-2.6/fs/affs/super.c	2007-02-11 08:43:08.000000000 +0100
@@ -118,6 +118,7 @@
 	.read_inode	= affs_read_inode,
 	.write_inode	= affs_write_inode,
 	.put_inode	= affs_put_inode,
+	.drop_inode	= affs_drop_inode,
 	.delete_inode	= affs_delete_inode,
 	.clear_inode	= affs_clear_inode,
 	.put_super	= affs_put_super,

                 reply	other threads:[~2007-02-11  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070211074652.GA23605@lst.de \
    --to=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).