* [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd
@ 2008-04-28 2:10 Dave Young
2008-04-28 2:13 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2008-04-28 2:10 UTC (permalink / raw)
To: linux-kernel; +Cc: jens.axboe
[Fixing bug 10504]
If the bakingfile is a block device file, losetuo -d will trigger lockdep
warning of "circular locking dependency".
open/release lock order : bdev->bd_mutex ---> lo->lo_ctl_mutex
loop_clr_fd lock order : lo->lo_ctl_mutex ---> bdev->bd_mutex (fput)
Don't hold the lo_ctl_mutex while fput in loop_clr_fd to fix it. It's safe
because all loop device state will be consistent here.
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
---
drivers/block/loop.c | 5 +++++
1 file changed, 5 insertions(+)
diff -upr linux/drivers/block/loop.c linux.new/drivers/block/loop.c
--- linux/drivers/block/loop.c 2008-04-25 10:10:25.000000000 +0800
+++ linux.new/drivers/block/loop.c 2008-04-25 10:10:35.000000000 +0800
@@ -923,7 +923,12 @@ static int loop_clr_fd(struct loop_devic
bd_set_size(bdev, 0);
mapping_set_gfp_mask(filp->f_mapping, gfp);
lo->lo_state = Lo_unbound;
+
+ /* unlock the lo_ctl_mutex to silence lockdep in case
+ the backingfile is a block device */
+ mutex_unlock(&lo->lo_ctl_mutex);
fput(filp);
+ mutex_lock(&lo->lo_ctl_mutex);
/* This is safe: open() is still holding a reference. */
module_put(THIS_MODULE);
if (max_part > 0)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd
2008-04-28 2:10 [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd Dave Young
@ 2008-04-28 2:13 ` Al Viro
2008-04-28 2:15 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2008-04-28 2:13 UTC (permalink / raw)
To: Dave Young; +Cc: linux-kernel, jens.axboe
On Mon, Apr 28, 2008 at 10:10:22AM +0800, Dave Young wrote:
> [Fixing bug 10504]
>
> If the bakingfile is a block device file, losetuo -d will trigger lockdep
> warning of "circular locking dependency".
>
> open/release lock order : bdev->bd_mutex ---> lo->lo_ctl_mutex
> loop_clr_fd lock order : lo->lo_ctl_mutex ---> bdev->bd_mutex (fput)
>
> Don't hold the lo_ctl_mutex while fput in loop_clr_fd to fix it. It's safe
> because all loop device state will be consistent here.
Explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd
2008-04-28 2:13 ` Al Viro
@ 2008-04-28 2:15 ` Al Viro
2008-04-28 2:33 ` Dave Young
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2008-04-28 2:15 UTC (permalink / raw)
To: Dave Young; +Cc: linux-kernel, jens.axboe
On Mon, Apr 28, 2008 at 03:13:09AM +0100, Al Viro wrote:
> On Mon, Apr 28, 2008 at 10:10:22AM +0800, Dave Young wrote:
> > [Fixing bug 10504]
> >
> > If the bakingfile is a block device file, losetuo -d will trigger lockdep
> > warning of "circular locking dependency".
> >
> > open/release lock order : bdev->bd_mutex ---> lo->lo_ctl_mutex
> > loop_clr_fd lock order : lo->lo_ctl_mutex ---> bdev->bd_mutex (fput)
> >
> > Don't hold the lo_ctl_mutex while fput in loop_clr_fd to fix it. It's safe
> > because all loop device state will be consistent here.
>
> Explain.
BTW, explain also why open() at that spot will not do interesting things
wrt BLKRRPART done a bit below, please.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd
2008-04-28 2:15 ` Al Viro
@ 2008-04-28 2:33 ` Dave Young
2009-03-01 9:47 ` Jiri Slaby
0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2008-04-28 2:33 UTC (permalink / raw)
To: Al Viro; +Cc: linux-kernel, jens.axboe
On Mon, Apr 28, 2008 at 10:15 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> On Mon, Apr 28, 2008 at 03:13:09AM +0100, Al Viro wrote:
> > On Mon, Apr 28, 2008 at 10:10:22AM +0800, Dave Young wrote:
> > > [Fixing bug 10504]
> > >
> > > If the bakingfile is a block device file, losetuo -d will trigger lockdep
> > > warning of "circular locking dependency".
> > >
> > > open/release lock order : bdev->bd_mutex ---> lo->lo_ctl_mutex
> > > loop_clr_fd lock order : lo->lo_ctl_mutex ---> bdev->bd_mutex (fput)
> > >
> > > Don't hold the lo_ctl_mutex while fput in loop_clr_fd to fix it. It's safe
> > > because all loop device state will be consistent here.
> >
> > Explain.
Hi, Maybe I have some mis-understood, thanks for pointing out in advance.
IMO the lo_ctl_mutex is for the lo->* state locking, they are all set
to proper values before fput(filp), so I think it's safe to do that.
>
> BTW, explain also why open() at that spot will not do interesting things
> wrt BLKRRPART done a bit below, please.
>
open with a loop device unbound? Sorry, I don't understand. Could you
explain a bit? Thanks
Regards
dave
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd
2008-04-28 2:33 ` Dave Young
@ 2009-03-01 9:47 ` Jiri Slaby
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2009-03-01 9:47 UTC (permalink / raw)
To: Dave Young; +Cc: Al Viro, linux-kernel, jens.axboe
On 28.4.2008 04:33, Dave Young wrote:
> On Mon, Apr 28, 2008 at 10:15 AM, Al Viro<viro@zeniv.linux.org.uk> wrote:
>> On Mon, Apr 28, 2008 at 03:13:09AM +0100, Al Viro wrote:
>> > On Mon, Apr 28, 2008 at 10:10:22AM +0800, Dave Young wrote:
>> > > [Fixing bug 10504]
>> > >
>> > > If the bakingfile is a block device file, losetuo -d will trigger lockdep
>> > > warning of "circular locking dependency".
>> > >
>> > > open/release lock order : bdev->bd_mutex ---> lo->lo_ctl_mutex
>> > > loop_clr_fd lock order : lo->lo_ctl_mutex ---> bdev->bd_mutex (fput)
>> > >
>> > > Don't hold the lo_ctl_mutex while fput in loop_clr_fd to fix it. It's safe
>> > > because all loop device state will be consistent here.
>> >
>> > Explain.
>
> Hi, Maybe I have some mis-understood, thanks for pointing out in advance.
>
> IMO the lo_ctl_mutex is for the lo->* state locking, they are all set
> to proper values before fput(filp), so I think it's safe to do that.
>
>> BTW, explain also why open() at that spot will not do interesting things
>> wrt BLKRRPART done a bit below, please.
>>
>
> open with a loop device unbound? Sorry, I don't understand. Could you
> explain a bit? Thanks
Any ideas here? Al? The bug survived almost a year...
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-01 9:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 2:10 [PATCH 2/2] loop : Don't hold the lo_ctl_mutex while fput in loop_clr_fd Dave Young
2008-04-28 2:13 ` Al Viro
2008-04-28 2:15 ` Al Viro
2008-04-28 2:33 ` Dave Young
2009-03-01 9:47 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox