From: "Luck, Tony" <tony.luck@intel.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Xiaotian Feng <xtfeng@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: pstore: fix leaking ->i_private
Date: Fri, 18 Mar 2011 11:44:48 -0700 [thread overview]
Message-ID: <4d83a82032021e2997@agluck-desktop.sc.intel.com> (raw)
In-Reply-To: <20110317104434.GB22723@ZenIV.linux.org.uk>
From: Tony Luck <tony.luck@intel.com>
Move kfree() of i_private out of ->unlink() and into ->evict_inode()
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
> Incidentally, you are leaking ->i_private on umount. You want ->evict_inode()
> doing that kfree(), not ->unlink(). And possibly ->erase() as well, with
> check for zero i_nlink around it (in ->evict_inode()).
I think this does what I want.
I only want to ->erase() the persistant store if there has been an unlink(2)
on the file. It looks to be safe and right to do this in ->unlink()
I don't think I need any checks on i_nlink - pstore filesystem won't let you
make extra links to a file.
end_writeback(inode) looks to be somewhat overkill, all I need is to set I_CLEAR
bit in ->i_state. But nobody else does this by hand, and the extra actions in
end_writeback() look to be harmless.
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 0834223..e8b0c08 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -73,11 +73,16 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
struct pstore_private *p = dentry->d_inode->i_private;
p->erase(p->id);
- kfree(p);
return simple_unlink(dir, dentry);
}
+static void pstore_evict_inode(struct inode *inode)
+{
+ kfree(inode->i_private);
+ end_writeback(inode);
+}
+
static const struct inode_operations pstore_dir_inode_operations = {
.lookup = simple_lookup,
.unlink = pstore_unlink,
@@ -110,6 +115,7 @@ static struct inode *pstore_get_inode(struct super_block *sb,
static const struct super_operations pstore_ops = {
.statfs = simple_statfs,
.drop_inode = generic_delete_inode,
+ .evict_inode = pstore_evict_inode,
.show_options = generic_show_options,
};
next prev parent reply other threads:[~2011-03-18 18:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-16 23:56 [git pull] mnt_devname queue Al Viro
2011-03-17 5:45 ` Xiaotian Feng
2011-03-17 5:45 ` Xiaotian Feng
2011-03-17 7:23 ` Al Viro
2011-03-17 7:28 ` Xiaotian Feng
2011-03-17 10:44 ` Al Viro
2011-03-17 19:08 ` Tony Luck
2011-03-17 21:35 ` Some fixes for pstore (Was Re: [git pull] mnt_devname queue) Tony Luck
2011-03-17 22:42 ` Al Viro
2011-03-17 22:48 ` Tony Luck
2011-03-17 22:48 ` Tony Luck
2011-03-17 22:56 ` Al Viro
2011-03-18 18:44 ` Luck, Tony [this message]
2011-03-18 18:49 ` pstore: fix leaking ->i_private Christoph Hellwig
2011-03-18 18:55 ` Tony Luck
2011-03-18 18:55 ` Tony Luck
2011-03-18 22:33 ` pstore: use mount option instead sysfs to tweak kmsg_bytes Luck, Tony
2011-03-18 18:57 ` pstore: fix leaking ->i_private Al Viro
2011-03-17 23:29 ` Some fixes for pstore (Was Re: [git pull] mnt_devname queue) Tony Luck
2011-03-18 0:07 ` Al Viro
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=4d83a82032021e2997@agluck-desktop.sc.intel.com \
--to=tony.luck@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=xtfeng@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.