From: "J. Bruce Fields" <bfields@fieldses.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Bryan Schumaker <bjschuma@netapp.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: nfsd changes for 2.6.37
Date: Tue, 26 Oct 2010 18:11:56 -0400 [thread overview]
Message-ID: <20101026221156.GD1842@fieldses.org> (raw)
In-Reply-To: <20101026214441.GC1842@fieldses.org>
On Tue, Oct 26, 2010 at 05:44:41PM -0400, J. Bruce Fields wrote:
> On Tue, Oct 26, 2010 at 02:37:26PM -0700, Linus Torvalds wrote:
> > On Tue, Oct 26, 2010 at 2:24 PM, J. Bruce Fields <bfields@fieldses.org> wrote:
> > >
> > > I did a couple connectathon runs just now with no obvious ill effects
> > > except for some sleep-within-spinlock warnings in the lease code.
> >
> > Hmm. Those sleep-within-spinlock warnings are very likely serious
> > bugs.
>
> Yeah, didn't mean to belittle them.
>
> > Can you quote the whole warning with stack trace?
>
> It's just obvious allocations in setlease:
>
> BUG: sleeping function called from invalid context at mm/slab.c:3101
> in_atomic(): 1, irqs_disabled(): 0, pid: 4345, name: lease_tests
> 1 lock held by lease_tests/4345:
> #0: (file_lock_lock){+.+.+.}, at: [<ffffffff81128be5>] lock_flocks+0x15/0x20
> Pid: 4345, comm: lease_tests Not tainted 2.6.36-05858-gbd5e20b #1028
> Call Trace:
> [<ffffffff8103141d>] __might_sleep+0x10d/0x140
> [<ffffffff810e3ad3>] kmem_cache_alloc+0x1f3/0x230
> [<ffffffff8112a4d2>] generic_setlease+0x112/0x2c0
> [<ffffffff8112a6b5>] __vfs_setlease+0x35/0x40
> [<ffffffff8112acfe>] fcntl_setlease+0xce/0x180
> [<ffffffff810f7c2e>] sys_fcntl+0x2fe/0x630
> [<ffffffff81961999>] ? trace_hardirqs_on_thunk+0x3a/0x3f
> [<ffffffff81002658>] system_call_fastpath+0x16/0x1b
>
> I'm testing a patch.
This works for me.
I'm not saying it's correct, but it does at least pass my dumb tests
without complaining.
--b.
diff --git a/fs/locks.c b/fs/locks.c
index 02b6e0e..db3afa0 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1379,7 +1379,9 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
if (error)
return error;
+ lock_flocks();
time_out_leases(inode);
+ unlock_flocks();
BUG_ON(!(*flp)->fl_lmops->fl_break);
@@ -1400,6 +1402,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
goto out;
}
+ lock_flocks();
/*
* At this point, we know that if there is an exclusive
* lease on this file, then we hold it on this filp
@@ -1427,28 +1430,31 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
error = -EAGAIN;
if ((arg == F_RDLCK && (wrlease_count > 0)) ||
(arg == F_WRLCK && ((rdlease_count + wrlease_count) > 0)))
- goto out;
+ goto out_unlock;
if (my_before != NULL) {
*flp = *my_before;
error = lease->fl_lmops->fl_change(my_before, arg);
- goto out;
+ goto out_unlock;
}
error = 0;
if (arg == F_UNLCK)
- goto out;
+ goto out_unlock;
error = -EINVAL;
if (!leases_enable)
- goto out;
+ goto out_unlock;
locks_copy_lock(new_fl, lease);
locks_insert_lock(before, new_fl);
*flp = new_fl;
+ unlock_flocks();
return 0;
+out_unlock:
+ unlock_flocks();
out:
if (new_fl != NULL)
locks_free_lock(new_fl);
@@ -1495,9 +1501,7 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
{
int error;
- lock_flocks();
error = __vfs_setlease(filp, arg, lease);
- unlock_flocks();
return error;
}
@@ -1524,8 +1528,6 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
if (error)
return error;
- lock_flocks();
-
error = __vfs_setlease(filp, arg, &flp);
if (error || arg == F_UNLCK)
goto out_unlock;
@@ -1541,7 +1543,6 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
out_unlock:
- unlock_flocks();
return error;
}
next prev parent reply other threads:[~2010-10-26 22:12 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-26 16:45 nfsd changes for 2.6.37 J. Bruce Fields
2010-10-26 17:22 ` J. Bruce Fields
2010-10-26 17:39 ` Linus Torvalds
2010-10-26 17:46 ` J. Bruce Fields
2010-10-26 20:18 ` Arnd Bergmann
2010-10-26 20:35 ` Bryan Schumaker
2010-10-26 20:55 ` Arnd Bergmann
2010-10-26 21:02 ` Linus Torvalds
2010-10-26 21:24 ` J. Bruce Fields
2010-10-26 21:37 ` Linus Torvalds
2010-10-26 21:44 ` J. Bruce Fields
2010-10-26 22:11 ` J. Bruce Fields [this message]
2010-10-26 22:41 ` J. Bruce Fields
2010-10-27 7:21 ` Arnd Bergmann
2010-10-27 8:39 ` Christoph Hellwig
2010-10-27 13:39 ` J. Bruce Fields
2010-10-27 13:46 ` Arnd Bergmann
2010-10-27 14:55 ` J. Bruce Fields
2010-10-27 14:59 ` Christoph Hellwig
2010-10-27 15:16 ` J. Bruce Fields
2010-10-27 15:19 ` Christoph Hellwig
2010-10-27 15:23 ` Arnd Bergmann
2010-10-27 15:28 ` J. Bruce Fields
2010-10-27 15:31 ` Christoph Hellwig
2010-10-27 16:12 ` Linus Torvalds
2010-10-27 16:46 ` J. Bruce Fields
2010-10-27 17:32 ` Linus Torvalds
2010-10-27 17:40 ` J. Bruce Fields
2010-10-27 18:20 ` Arnd Bergmann
2010-10-27 18:42 ` Linus Torvalds
2010-10-27 18:43 ` Linus Torvalds
2010-10-27 19:48 ` Arnd Bergmann
2010-10-27 20:01 ` J. Bruce Fields
2010-10-27 20:20 ` Arnd Bergmann
2010-10-27 20:24 ` J. Bruce Fields
2010-10-30 21:25 ` J. Bruce Fields
2010-10-30 21:31 ` [PATCH 1/4] locks: prevent ENOMEM on lease unlock J. Bruce Fields
2010-10-30 21:31 ` [PATCH 2/4] locks: fix leaks on setlease errors J. Bruce Fields
2010-10-31 11:10 ` Christoph Hellwig
2010-11-01 17:24 ` J. Bruce Fields
2010-11-01 17:41 ` Christoph Hellwig
2010-11-01 18:34 ` J. Bruce Fields
2010-10-30 21:31 ` [PATCH 3/4] locks: fix setlease methods to free passed-in lock J. Bruce Fields
2010-10-30 21:31 ` [PATCH 4/4] nfsd4: initialize delegation pointer to lease J. Bruce Fields
2010-10-31 2:04 ` Christoph Hellwig
2010-10-31 3:04 ` J. Bruce Fields
2010-10-30 21:40 ` nfsd changes for 2.6.37 Arnd Bergmann
2010-10-31 2:07 ` Christoph Hellwig
2010-10-31 3:05 ` J. Bruce Fields
2010-10-31 12:34 ` Christoph Hellwig
2010-10-31 12:35 ` [PATCH 1/2] locks: let the caller free file_lock on ->setlease failure Christoph Hellwig
2010-11-03 20:41 ` J. Bruce Fields
2010-11-04 1:40 ` J. Bruce Fields
2010-11-04 1:41 ` J. Bruce Fields
2010-11-06 19:03 ` Christoph Hellwig
2010-11-06 19:03 ` Christoph Hellwig
2010-11-08 16:10 ` J. Bruce Fields
2010-10-31 12:35 ` [PATCH 2/2] locks: remove fl_copy_lock lock_manager operation Christoph Hellwig
2010-11-01 15:02 ` nfsd changes for 2.6.37 J. Bruce Fields
2010-11-06 19:04 ` Christoph Hellwig
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=20101026221156.GD1842@fieldses.org \
--to=bfields@fieldses.org \
--cc=arnd@arndb.de \
--cc=bjschuma@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=torvalds@linux-foundation.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