Skip to contentSkip to conversation

VFS locking & HFS problems (2.4.6pre6)

DISCUSSION Benjamin Herrenschmidt 3 participants 3 messages Jun 29, 2001

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 7 lines · Benjamin Herrenschmidt

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

hfs/catalog.c +1 -3
diff -u -r1.2 catalog.c
@@ -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;
 }
#2 lore raw
In reply to Benjamin Herrenschmidt
Quoted 2 lines · Benjamin Herrenschmidt

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.

Quoted 2 lines

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.