mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Paris <eparis@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, hch@infradead.org,
	alan@lxorguk.ukuu.org.uk, sfr@canb.auug.org.au,
	john@johnmccutchan.com, rlove@rlove.org,
	akpm@linux-foundation.org
Subject: [PATCH 10/12] fsnotify: fsnotify marks on inodes pin them in core
Date: Mon, 27 Apr 2009 17:53:55 -0400	[thread overview]
Message-ID: <20090427215355.14161.66130.stgit@paris.rdu.redhat.com> (raw)
In-Reply-To: <20090427215305.14161.33354.stgit@paris.rdu.redhat.com>

This patch pins any inodes with an fsnotify mark in core.  The idea is that
as soon as the mark is removed from the inode->fsnotify_mark_entries list
the inode will be iput.  In reality is doesn't quite work exactly this way.
The igrab will happen when the mark is added to an inode, but the iput will
happen when the inode pointer is NULL'd inside the mark.

It's possible that 2 racing things will try to remove the mark from
different directions.  One may try to remove the mark because of an
explicit request and one might try to remove it because the inode was
deleted.  It's possible that the removal because of inode deletion will
remove the mark from the inode's list, but the removal by explicit request
will actually set entry->inode == NULL; and call the iput.  This is safe.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

 fs/notify/inode_mark.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index a395348..282150f 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -204,6 +204,8 @@ void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)
 	 */
 
 
+	iput(inode);
+
 	/*
 	 * it's possible that this group tried to destroy itself, but this
 	 * this mark was simultaneously being freed by inode.  If that's the
@@ -306,6 +308,10 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
 	struct fsnotify_mark_entry *lentry;
 	int ret = 0;
 
+	inode = igrab(inode);
+	if (unlikely(!inode))
+		return -EINVAL;
+
 	/*
 	 * LOCKING ORDER!!!!
 	 * entry->lock
@@ -337,6 +343,7 @@ int fsnotify_add_mark(struct fsnotify_mark_entry *entry,
 
 	if (lentry) {
 		ret = -EEXIST;
+		iput(inode);
 		fsnotify_put_mark(lentry);
 	} else {
 		__fsnotify_update_child_dentry_flags(inode);


  parent reply	other threads:[~2009-04-27 21:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-27 21:53 [PATCH 01/12] mutex: add atomic_dec_and_mutex_lock Eric Paris
2009-04-27 21:53 ` [PATCH 02/12] fsnotify: unified filesystem notification backend Eric Paris
2009-04-27 21:53 ` [PATCH 03/12] fsnotify: add marks to inodes so groups can interpret how to handle those inodes Eric Paris
2009-04-27 21:53 ` [PATCH 04/12] fsnotify: parent event notification Eric Paris
2009-04-27 21:53 ` [PATCH 05/12] dnotify: reimplement dnotify using fsnotify Eric Paris
2009-04-28  5:16   ` Stephen Rothwell
2009-04-27 21:53 ` [PATCH 06/12] fsnotify: generic notification queue and waitq Eric Paris
2009-04-27 21:53 ` [PATCH 07/12] fsnotify: include pathnames with entries when possible Eric Paris
2009-04-27 21:53 ` [PATCH 08/12] fsnotify: add correlations between events Eric Paris
2009-04-27 21:53 ` [PATCH 09/12] fsnotify: allow groups to add private data to events Eric Paris
2009-04-27 21:53 ` Eric Paris [this message]
2009-04-27 21:54 ` [PATCH 11/12] fsnotify: handle filesystem unmounts with fsnotify marks Eric Paris
2009-04-27 21:54 ` [PATCH 12/12] inotify: reimplement inotify using fsnotify Eric Paris
2009-04-28  9:59   ` Christoph Hellwig
2009-04-28 14:28     ` Eric Paris
2009-04-28 20:27 ` [PATCH 01/12] mutex: add atomic_dec_and_mutex_lock Andrew Morton
2009-04-28 22:46   ` Eric Paris
2009-04-29 11:59   ` Ingo Molnar
2009-04-29 14:47     ` Ingo Molnar

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=20090427215355.14161.66130.stgit@paris.rdu.redhat.com \
    --to=eparis@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hch@infradead.org \
    --cc=john@johnmccutchan.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rlove@rlove.org \
    --cc=sfr@canb.auug.org.au \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®