From: John McCutchan <ttb@tentacle.dhs.org>
To: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
Cc: Robert Love <rml@novell.com>,
linux-kernel@vger.kernel.org, Mr Morton <akpm@osdl.org>
Subject: Re: [patch] updated inotify for 2.6.12-rc3.
Date: Fri, 22 Apr 2005 11:04:33 -0400 [thread overview]
Message-ID: <1114182273.13886.17.camel@vertex> (raw)
In-Reply-To: <20050422085614.GE13052@parcelfarce.linux.theplanet.co.uk>
On Fri, 2005-04-22 at 09:56 +0100, Al Viro wrote:
> > +static int inotify_ignore(struct inotify_device *dev, s32 wd)
> > +{
> > + struct inotify_watch *watch;
> > + struct inode *inode;
> > +
> > + down(&dev->sem);
> > + watch = idr_find(&dev->idr, wd);
> > + if (unlikely(!watch)) {
> > + up(&dev->sem);
> > + return -EINVAL;
> > + }
> > + get_inotify_watch(watch);
> > + up(&dev->sem);
> > +
> > + inode = watch->inode;
> > + down(&inode->inotify_sem);
> > + down(&dev->sem);
> > + remove_watch(watch, dev);
> > + up(&dev->sem);
> > + up(&inode->inotify_sem);
> > + put_inotify_watch(watch);
> > +
> > + return 0;
> > +}
>
> So what happens if
> * something is holding inotify_sem right now
> * ten threads call that on the same watch
> * all of them get to down(&inode->inotify_sem); and block there,
> having acquired ten references to the watch
> * after whatever had been holding ->inotify_sem in the first place
> releases it, they will one by one go through the rest of function. And
> drop _20_ references to the watch. 9 of those - after we kfree() the
> watch...
In create_watch () we call get_inotify_watch (), which maps to the
put_inotify_watch() in remove_watch(). As far as I can tell the ref
counting is 1 for 1.
--
John McCutchan <ttb@tentacle.dhs.org>
next prev parent reply other threads:[~2005-04-22 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-21 5:13 [patch] inotify for 2.6.12-rc3 Robert Love
2005-04-21 5:31 ` Robert Love
2005-04-21 23:47 ` [patch] oneshot for inotify Robert Love
2005-04-22 4:57 ` [patch] inotify for 2.6.12-rc3 Robert Love
2005-04-22 5:01 ` [patch] updated " Robert Love
2005-04-22 8:56 ` Al Viro
2005-04-22 15:04 ` John McCutchan [this message]
2005-04-22 21:13 ` Al Viro
2005-04-22 23:27 ` Robert Love
2005-04-28 20:38 ` [patch] latest inotify Robert Love
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=1114182273.13886.17.camel@vertex \
--to=ttb@tentacle.dhs.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rml@novell.com \
--cc=viro@parcelfarce.linux.theplanet.co.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