* Re: VFS locking & HFS problems (2.4.6pre6)
[not found] <E15G08g-0000UO-00@the-village.bc.nu>
@ 2001-06-29 16:10 ` Benjamin Herrenschmidt
2001-06-29 16:29 ` Alan Cox
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2001-06-29 16:10 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
Alan Cox wrote:
>Holding a spinlock while sleeping is an offence punishable by deadlock..
Right, and it's indeed the problem. But I'm still concerned about
locking since by using that spinlock, the guy who wrote it did
not expect beeing re-entered at this point, and just "cleaning" it
may not be enough.
>You might also look for memory allocations that are not GFP_ATOMIC made with
>the lock held
Yup. It's the problem. It locks, then calls some alloc routines, which
fills a cache and uses kmalloc with GFP_KERNEL.
Turning it into GFP_ATOMIC might not be the best idea as the HFS
filesystem currently shares a single hfs_malloc() for everybody and
turning it into GFP_ATOMIC would cause all of HFS allocs to be atomic.
I can change this single routine (and any other doing the same thing),
but I'd rather fix it by making sure HFS can safely sleep at this
point and still use GFP_KERNEL.
I just found Documentations/filesystems/Locking document, I bet I'll
find all the infos I need there. It's amazing how long it took me
to look for the info where it logically should be ;)
Ben.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: VFS locking & HFS problems (2.4.6pre6)
2001-06-29 16:10 ` VFS locking & HFS problems (2.4.6pre6) Benjamin Herrenschmidt
@ 2001-06-29 16:29 ` Alan Cox
0 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2001-06-29 16:29 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Alan Cox, linux-kernel
> Yup. It's the problem. It locks, then calls some alloc routines, which
> fills a cache and uses kmalloc with GFP_KERNEL.
Thats quite common. If it can safely sleep there without other deadlocks a
semaphore may be better
> Turning it into GFP_ATOMIC might not be the best idea as the HFS
> filesystem currently shares a single hfs_malloc() for everybody and
> turning it into GFP_ATOMIC would cause all of HFS allocs to be atomic.
Another approach is to prealloc the object and pass it in, then free it
if not needed
^ permalink raw reply [flat|nested] 5+ messages in thread
* VFS locking & HFS problems (2.4.6pre6)
@ 2001-06-29 15:09 Benjamin Herrenschmidt
2001-06-29 15:52 ` Andrew Morton
2001-06-29 19:53 ` Alexander Viro
0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2001-06-29 15:09 UTC (permalink / raw)
To: linux-kernel
I've had a deadlock twice with 2.4.6pre6 today. It's an SMP kernel
running on an UP box (a PowerBook Pismo).
The deadlock happen in the HFS filesystem in hfs_cat_put(), apparently
(quickly looking at addresses) in spin_lock().
I don't have the complete backtrace at hand right now, but it basically
went up to kswapd without anything evidently getting that spinlock,
I'll try to gather more details.
So my question: Is there any document explaining the various locking
requirements & re-entrency possibilities in a filesystem.
What I think might happen after a quick look is that HFS may be causing
schedule() to be called while holding the spinlock, and gets then
re-entered from another process context. I have to look at it in more
detail (is there an HFS maintainer ?) but some background informations
on VFS locking & reentrancy issues would be helpful.
Ben.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: VFS locking & HFS problems (2.4.6pre6)
2001-06-29 15:09 Benjamin Herrenschmidt
@ 2001-06-29 15:52 ` Andrew Morton
2001-06-29 19:53 ` Alexander Viro
1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2001-06-29 15:52 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linux-kernel
Benjamin Herrenschmidt wrote:
>
> I've had a deadlock twice with 2.4.6pre6 today. It's an SMP kernel
> running on an UP box (a PowerBook Pismo).
>
> The deadlock happen in the HFS filesystem in hfs_cat_put(), apparently
> (quickly looking at addresses) in spin_lock().
>
Please test this:
Index: fs/hfs/catalog.c
===================================================================
RCS file: /opt/cvs/lk/fs/hfs/catalog.c,v
retrieving revision 1.2
diff -u -r1.2 catalog.c
--- fs/hfs/catalog.c 2001/02/17 01:44:39 1.2
+++ fs/hfs/catalog.c 2001/06/29 15:54:17
@@ -549,7 +549,7 @@
entry->state &= ~HFS_LOCK;
hfs_wake_up(&entry->wait);
}
-
+ spin_lock(&entry_lock);
return entry;
}
@@ -559,7 +559,6 @@
if (grow_entries())
goto add_new_entry;
- spin_unlock(&entry_lock);
return NULL;
read_fail:
@@ -570,7 +569,6 @@
init_entry(entry);
list_add(&entry->list, &entry_unused);
entries_stat.nr_free_entries++;
- spin_unlock(&entry_lock);
return NULL;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: VFS locking & HFS problems (2.4.6pre6)
2001-06-29 15:09 Benjamin Herrenschmidt
2001-06-29 15:52 ` Andrew Morton
@ 2001-06-29 19:53 ` Alexander Viro
1 sibling, 0 replies; 5+ messages in thread
From: Alexander Viro @ 2001-06-29 19:53 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linux-kernel
On Fri, 29 Jun 2001, Benjamin Herrenschmidt wrote:
> The deadlock happen in the HFS filesystem in hfs_cat_put(), apparently
> (quickly looking at addresses) in spin_lock().
<looks>
Uh-oh. Looks like hfs_cat_put() grabs some internal spinlock and calls
write_entry(). If it really is what its name implies, you are calling
a blocking function under the spinlock.
> So my question: Is there any document explaining the various locking
> requirements & re-entrency possibilities in a filesystem.
There is, but this bug has nothing fs-specific in it. You should never
block while holding a spinlock.
BTW, looks like 2.2 has the same bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-06-29 19:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <E15G08g-0000UO-00@the-village.bc.nu>
2001-06-29 16:10 ` VFS locking & HFS problems (2.4.6pre6) Benjamin Herrenschmidt
2001-06-29 16:29 ` Alan Cox
2001-06-29 15:09 Benjamin Herrenschmidt
2001-06-29 15:52 ` Andrew Morton
2001-06-29 19:53 ` Alexander Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®