From: Eric Paris <eparis@redhat.com>
To: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/5] fsnotify: grab inode ref in add_inode_mark() instead of add_mark()
Date: Tue, 01 Mar 2011 16:07:32 -0500 [thread overview]
Message-ID: <1299013652.8918.16.camel@localhost.localdomain> (raw)
In-Reply-To: <20110301183006.GC3492@lsanfilippo.unix.rd.tt.avira.com>
On Tue, 2011-03-01 at 19:30 +0100, Lino Sanfilippo wrote:
> On Fri, Feb 25, 2011 at 01:36:35PM -0500, Eric Paris wrote:
> > I think your patch series is making a noticeable change which I don't
> > think I'm comfortable with. The current code does not pin inodes in
> > core if they only have ignored masks. Under memory pressure those
> > inodes can get eviced and the mark will get cleaned up. My glance at
> > this code leads me to believe that all inodes with any mark is going to
> > be pinned in core. I don't think that's a good idea for AV vendor use
> > where they might want to watch everything on the system with mount point
> > marks and put ignored marks on everything that comes along to cache
> > allows.
> >
> > The fact that inodes might not be pinned in core is the reason for some
> > of the stupid difficulty. There is probably some way to work it out but
> > I think it's something I'm going to need to think about.
>
> Youre right, the inode is now also pinned if there is no mask set. This is
> a change i did not on purpose. Whether the inode is pinned or not does not
> affect the original purpose of the patch series, which was the decoupling
> of the mark lock and the fsobject lock. I simply forgot to check the mask.
> I could replace that part with something like
>
> - mark->i.inode = igrab(inode);
> - mark->flags |= FSNOTIFY_MARK_FLAG_OBJECT_PINNED;
> + mark->i.inode = inode;
> + if (mark->mask) { /* only pin if mask is set */
> + igrab(inode);
> + mark->flags |= FSNOTIFY_MARK_FLAG_OBJECT_PINNED;
> + }
>
> Should i just fix it and resend the patches? Or do you have any other
> concerns?
No, but it's a rather serious concern to me. You need to make sure that
mark->i.inode is actually valid before you use it and cannot disappear
underneath you. I haven't relooked at your code (and clearly will after
you fix) but what I'm most concerned about is some place where we are
trying to delete a mark, either explicitly or by group, and then race
with the inode being evicted from cache. The inode being evicted from
cache is going to eventually hit the destroy_by_inode code. When that
function returns we cannot use mark->i.inode any more. In today's code
we prevent this situation by never dereferencing or using the
mark->i.inode outside of mark->lock. You're going to have to remember
that after a 'destroy_by_inode' call you can't ever use the inode
again....
-Eric
next prev parent reply other threads:[~2011-03-01 21:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-21 17:33 [PATCH 0/5] fsnotify: decouple mark lock and marks fsobject lock Lino Sanfilippo
2011-02-21 17:33 ` [PATCH 1/5] fsnotify: grab inode ref in add_inode_mark() instead of add_mark() Lino Sanfilippo
2011-02-25 18:36 ` Eric Paris
2011-03-01 18:30 ` Lino Sanfilippo
2011-03-01 21:07 ` Eric Paris [this message]
2011-02-21 17:33 ` [PATCH 2/5] fsnotify: pass inode/mount as a parameter to fsnotify_destroy_[inode|vfsmount]_mark() Lino Sanfilippo
2011-02-21 17:33 ` [PATCH 3/5] fsnotify: dont call fsnotify_add_[inode|vfsmount]_mark() with mark lock held Lino Sanfilippo
2011-02-21 17:33 ` [PATCH 4/5] fsnotify: dont call fsnotify_destroy_[inode|vfsmount]_mark() " Lino Sanfilippo
2011-02-21 17:33 ` [PATCH 5/5] fsnotify: dont lock fsobject " Lino Sanfilippo
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=1299013652.8918.16.camel@localhost.localdomain \
--to=eparis@redhat.com \
--cc=LinoSanfilippo@gmx.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).