From: NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org>
To: Jeff Layton <jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"J. Bruce Fields"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"L. A. Walsh" <suse-gT3AUAsYRbTYtjvyW6yDsg@public.gmane.org>,
Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org>
Subject: Re: [PATCH v2 05/17] locks: generic_delete_lease doesn't need a file_lock at all
Date: Tue, 13 Jan 2015 15:14:40 +1300 [thread overview]
Message-ID: <20150113151440.372733ed@notabene.brown> (raw)
In-Reply-To: <20150112182500.33bebf6c-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3698 bytes --]
On Mon, 12 Jan 2015 18:25:00 -0500 Jeff Layton <jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
wrote:
> On Tue, 13 Jan 2015 12:03:43 +1300
> NeilBrown <neilb-l3A5Bk7waGM@public.gmane.org> wrote:
>
> > On Thu, 4 Sep 2014 08:38:31 -0400 Jeff Layton <jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
> > wrote:
> >
> > > Ensure that it's OK to pass in a NULL file_lock double pointer on
> > > a F_UNLCK request and convert the vfs_setlease F_UNLCK callers to
> > > do just that.
> > >
> > > Finally, turn the BUG_ON in generic_setlease into a WARN_ON_ONCE
> > > with an error return. That's a problem we can handle without
> > > crashing the box if it occurs.
> > >
> > > Signed-off-by: Jeff Layton <jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
> > > Reviewed-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> > > ---
> > > fs/locks.c | 34 ++++++++++++++--------------------
> > > fs/nfsd/nfs4state.c | 2 +-
> > > include/trace/events/filelock.h | 14 +++++++-------
> > > 3 files changed, 22 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/fs/locks.c b/fs/locks.c
> > > index 4031324e6cca..1289b74fffbf 100644
> > > --- a/fs/locks.c
> > > +++ b/fs/locks.c
> > > @@ -1637,22 +1637,23 @@ out:
> > > return error;
> > > }
> > >
> > > -static int generic_delete_lease(struct file *filp, struct file_lock **flp)
> > > +static int generic_delete_lease(struct file *filp)
> > > {
> > > + int error = -EAGAIN;
> > > struct file_lock *fl, **before;
> > > struct dentry *dentry = filp->f_path.dentry;
> > > struct inode *inode = dentry->d_inode;
> > >
> > > - trace_generic_delete_lease(inode, *flp);
> > > -
> > > for (before = &inode->i_flock;
> > > ((fl = *before) != NULL) && IS_LEASE(fl);
> > > before = &fl->fl_next) {
> > > - if (fl->fl_file != filp)
> > > - continue;
> > > - return (*flp)->fl_lmops->lm_change(before, F_UNLCK);
> > > + if (fl->fl_file == filp)
> > > + break;
> > > }
> > > - return -EAGAIN;
> > > + trace_generic_delete_lease(inode, fl);
> > > + if (fl)
> > > + error = fl->fl_lmops->lm_change(before, F_UNLCK);
> > > + return error;
> > > }
> >
> > Hi Jeff,
> > I have a report of a crash in 3.18 because fl->fl_lmops is NULL in the above.
> > https://bugzilla.suse.com/show_bug.cgi?id=912569
> >
> > I assume this happens because a file_lock is found which is not IS_LEASE.
> > When that happens, the loop will abort, but fl will not be NULL.
> > As non-LEASE locks have a NULL fl_lmops, we crash.
> >
> > I would be inclined to put the code back the way it was, and just move the
> > trace_generic_delete_lease call.
> >
> > Alternately we could make it
> >
> > if (fl && IS_LEASE(fl))
> > error = fl->fl_lmops-> .....
> >
> > What do you think?
> >
> > NeilBrown
>
> Doh! Well spotted...
>
> Either fix sounds fine as long as we don't make generic_delete_lease
> require a "flp" arg again. IOW, if you do make the code work similarly
> to how it did before, then we should do:
>
> return fl->fl_lmops->lm_change(before, F_UNLCK);
>
> ...rather than trying to use the ops from a completely different struct
> file_lock argument that's passed in.
>
> FWIW, I have an overhaul of the locking code that is queued for v3.20
> that will also fix this (as we'll be moving all of the different locks
> to separate lists), but we'll obviously need to queue up a patch for
> stable for this in the interim.
>
> Thanks!
As you are going to re-write it all I won't try to make it elegant, just a
simple fix. I'll post shortly.
Thanks,
NeilBrown
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2015-01-13 2:14 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-04 12:38 [PATCH v2 00/17] locks: internal lease API overhaul Jeff Layton
2014-09-04 12:38 ` [PATCH v2 01/17] locks: consolidate "nolease" routines Jeff Layton
2014-09-04 12:41 ` Trond Myklebust
[not found] ` <CAHQdGtTqG8aW-cte2PW6pVw+OeCXATgr1BZwdhponuWMjzNg8g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-09-04 12:49 ` Jeff Layton
2014-09-04 18:25 ` Trond Myklebust
2014-09-04 20:12 ` Christoph Hellwig
[not found] ` <20140904201200.GA26054-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-05 11:48 ` Jeff Layton
[not found] ` <1409834323-7171-2-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:46 ` Christoph Hellwig
2014-09-04 12:38 ` [PATCH v2 02/17] security: make security_file_set_fowner, f_setown and __f_setown void return Jeff Layton
2014-09-04 17:47 ` Christoph Hellwig
2014-10-07 17:11 ` Dmitry Kasatkin
2014-10-07 17:17 ` Christoph Hellwig
[not found] ` <20141007171703.GA30274-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-10-07 17:34 ` Dmitry Kasatkin
2014-10-07 18:02 ` Jeff Layton
2014-09-04 12:38 ` [PATCH v2 03/17] locks: close potential race in lease_get_mtime Jeff Layton
2014-09-04 12:38 ` [PATCH v2 04/17] nfsd: fix potential lease memory leak in nfs4_setlease Jeff Layton
2014-09-04 12:38 ` [PATCH v2 05/17] locks: generic_delete_lease doesn't need a file_lock at all Jeff Layton
[not found] ` <1409834323-7171-6-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 20:14 ` Christoph Hellwig
[not found] ` <20140904201424.GB26054-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-05 0:29 ` Jeff Layton
2015-01-12 23:03 ` NeilBrown
2015-01-12 23:25 ` Jeff Layton
[not found] ` <20150112182500.33bebf6c-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2015-01-13 2:14 ` NeilBrown [this message]
2014-09-04 12:38 ` [PATCH v2 06/17] locks: clean up vfs_setlease kerneldoc comments Jeff Layton
2014-09-04 12:38 ` [PATCH v2 07/17] nfsd: don't keep a pointer to the lease in nfs4_file Jeff Layton
[not found] ` <1409834323-7171-8-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-05 21:40 ` J. Bruce Fields
[not found] ` <20140905214058.GA5443-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2014-09-06 12:33 ` Jeff Layton
2014-09-04 12:38 ` [PATCH v2 08/17] locks: plumb a "priv" pointer into the setlease routines Jeff Layton
2014-09-04 17:48 ` Christoph Hellwig
2014-09-04 12:38 ` [PATCH v2 10/17] locks: move i_lock acquisition into generic_*_lease handlers Jeff Layton
2014-09-04 12:38 ` [PATCH v2 11/17] locks: move freeing of leases outside of i_lock Jeff Layton
[not found] ` <1409834323-7171-12-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:50 ` Christoph Hellwig
2014-09-05 14:03 ` Jeff Layton
2014-09-04 12:38 ` [PATCH v2 12/17] locks: update Documentation/filesystems with new setlease semantics Jeff Layton
[not found] ` <1409834323-7171-13-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:50 ` Christoph Hellwig
[not found] ` <20140904175043.GF16935-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-05 14:02 ` Jeff Layton
2014-09-04 12:38 ` [PATCH v2 14/17] locks: __break_lease cleanup in preparation of allowing direct removal of leases Jeff Layton
[not found] ` <1409834323-7171-15-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 18:07 ` Christoph Hellwig
[not found] ` <20140904180725.GA11232-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-05 13:35 ` Jeff Layton
[not found] ` <1409834323-7171-1-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 12:38 ` [PATCH v2 09/17] locks: define a lm_setup handler for leases Jeff Layton
[not found] ` <1409834323-7171-10-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:49 ` Christoph Hellwig
2014-09-04 12:38 ` [PATCH v2 13/17] locks: remove i_have_this_lease check from __break_lease Jeff Layton
[not found] ` <1409834323-7171-14-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:51 ` Christoph Hellwig
[not found] ` <20140904175132.GG16935-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-04 18:03 ` Jeff Layton
2014-09-04 12:38 ` [PATCH v2 15/17] locks: give lm_break a return value Jeff Layton
[not found] ` <1409834323-7171-16-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 18:08 ` Christoph Hellwig
2014-09-04 12:38 ` [PATCH v2 16/17] locks: set fl_owner for leases to filp instead of current->files Jeff Layton
2014-09-04 12:38 ` [PATCH v2 17/17] locks: clean up comments over fl_owner_t definition Jeff Layton
[not found] ` <1409834323-7171-18-git-send-email-jlayton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
2014-09-04 17:53 ` Christoph Hellwig
[not found] ` <20140904175334.GH16935-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-09-05 13:36 ` Jeff Layton
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=20150113151440.372733ed@notabene.brown \
--to=neilb-l3a5bk7wagm@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=jeff.layton-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org \
--cc=jslaby-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=suse-gT3AUAsYRbTYtjvyW6yDsg@public.gmane.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).