From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Daniel Drake <dsd@gentoo.org>
Cc: "David Gómez" <david@pleyades.net>,
"Robert Love" <rml@novell.com>,
"John McCutchan" <ttb@tentacle.dhs.org>,
Linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: Problem with inotify
Date: Mon, 04 Jul 2005 15:27:21 +0100 [thread overview]
Message-ID: <1120487242.11399.5.camel@imp.csi.cam.ac.uk> (raw)
In-Reply-To: <42C7BF37.9010005@gentoo.org>
On Sun, 2005-07-03 at 11:34 +0100, Daniel Drake wrote:
> I reverted the patch you sent earlier
> (inotify_unmount_inodes-list-iteration-fix.diff) and applied the one you
> attached here (inotify_unmount_inodes-list-iteration-fix2.diff).
>
> The good news is that the hang is gone. The bad news is that you cured the
> hang by introducing an oops :(
)-: I have addressed the only things I can think off that could cause
the oops and below is the resulting patch. Could you please test it?
Thanks a lot!
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
--- linux-2.6.13-rc1-mm1-vanilla/fs/inotify.c 2005-07-01 14:51:09.000000000 +0100
+++ linux-2.6.13-rc1-mm1/fs/inotify.c 2005-07-04 15:18:14.000000000 +0100
@@ -560,22 +560,45 @@ EXPORT_SYMBOL_GPL(inotify_get_cookie);
*/
void inotify_unmount_inodes(struct list_head *list)
{
- struct inode *inode, *next_i;
+ struct inode *inode, *next_i, *need_iput = NULL;
list_for_each_entry_safe(inode, next_i, list, i_sb_list) {
+ struct inode *need_iput_tmp;
struct inotify_watch *watch, *next_w;
struct list_head *watches;
/*
+ * If i_count is zero, the inode cannot have any watches and
+ * doing an __iget/iput with MS_ACTIVE clear would actually
+ * evict all inodes from icache which is unnecessarily violent.
+ */
+ if (!atomic_read(&inode->i_count))
+ continue;
+ /*
* We cannot __iget() an inode in state I_CLEAR or I_FREEING,
* which is fine becayse by that point the inode cannot have
* any associated watches.
*/
- if (inode->i_state & (I_CLEAR | I_FREEING))
+ if (inode->i_state & (I_CLEAR | I_FREEING | I_WILL_FREE))
continue;
+ need_iput_tmp = need_iput;
+ need_iput = NULL;
+
/* In case the remove_watch() drops a reference */
- __iget(inode);
+ if (inode != need_iput_tmp)
+ __iget(inode);
+ else
+ need_iput_tmp = NULL;
+
+ /* In case the dropping of a reference would nuke next_i. */
+ if ((&next_i->i_sb_list != list) &&
+ atomic_read(&next_i->i_count) &&
+ !(next_i->i_state & (I_CLEAR | I_FREEING |
+ I_WILL_FREE))) {
+ __iget(next_i);
+ need_iput = next_i;
+ }
/*
* We can safely drop inode_lock here because the per-sb list
@@ -584,6 +607,9 @@ void inotify_unmount_inodes(struct list_
*/
spin_unlock(&inode_lock);
+ if (need_iput_tmp)
+ iput(need_iput_tmp);
+
/* for each watch, send IN_UNMOUNT and then remove it */
down(&inode->inotify_sem);
watches = &inode->inotify_watches;
next prev parent reply other threads:[~2005-07-04 14:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-30 18:18 David Gómez
2005-06-30 18:29 ` Robert Love
2005-06-30 18:38 ` David Gómez
2005-06-30 19:33 ` David Gómez
2005-06-30 20:39 ` Anton Altaparmakov
2005-06-30 20:48 ` David Gómez
2005-06-30 22:35 ` Anton Altaparmakov
2005-07-01 20:25 ` Robert Love
2005-07-02 12:54 ` David Gómez
2005-07-02 16:25 ` Robert Love
2005-07-02 9:12 ` Daniel Drake
2005-07-02 22:09 ` Anton Altaparmakov
2005-07-02 23:38 ` Daniel Drake
2005-07-03 0:08 ` Anton Altaparmakov
2005-07-03 10:34 ` Daniel Drake
2005-07-04 14:27 ` Anton Altaparmakov [this message]
2005-07-04 14:39 ` Anton Altaparmakov
2005-07-04 15:12 ` Anton Altaparmakov
2005-07-04 15:55 ` Gautam Singaraju
2005-07-04 16:00 ` Anton Altaparmakov
2005-07-04 17:57 ` Daniel Drake
2005-07-04 19:09 ` Anton Altaparmakov
2005-07-05 1:33 ` John McCutchan
2005-07-05 7:56 ` Anton Altaparmakov
2005-07-05 15:48 ` John McCutchan
2005-07-05 17:06 ` Anton Altaparmakov
2005-07-05 18:07 ` John McCutchan
2005-07-05 20:53 ` Anton Altaparmakov
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=1120487242.11399.5.camel@imp.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=david@pleyades.net \
--cc=dsd@gentoo.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rml@novell.com \
--cc=ttb@tentacle.dhs.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
all inboxes | Powered by JetHome®