aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2006-12-06 23:39:38 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:43 -0500
commitc949d4eb40ce021b1abc3b63af23aa535662cb17 (patch)
tree054b4464c4968f9e07f65fe9680b483cae6e71df /fs/autofs
parent595142e0490918af5ffae5a833a2b2acd7097c02 (diff)
[PATCH] autofs: fix error code path in autofs_fill_sb()
When kernel is compiled with old version of autofs (CONFIG_AUTOFS_FS), and new (observed at least with 5.x.x) automount deamon is started, kernel correctly reports incompatible version of kernel and userland daemon, but then screws things up instead of correct handling of the error: autofs: kernel does not match daemon version ===================================== [ BUG: bad unlock balance detected! ] ------------------------------------- automount/4199 is trying to release lock (&type->s_umount_key) at: [<c0163b9e>] get_sb_nodev+0x76/0xa4 but there are no more locks to release! other info that might help us debug this: no locks held by automount/4199. stack backtrace: [<c0103b15>] dump_trace+0x68/0x1b2 [<c0103c77>] show_trace_log_lvl+0x18/0x2c [<c01041db>] show_trace+0xf/0x11 [<c010424d>] dump_stack+0x12/0x14 [<c012e02c>] print_unlock_inbalance_bug+0xe7/0xf3 [<c012fd4f>] lock_release+0x8d/0x164 [<c012b452>] up_write+0x14/0x27 [<c0163b9e>] get_sb_nodev+0x76/0xa4 [<c0163689>] vfs_kern_mount+0x83/0xf6 [<c016373e>] do_kern_mount+0x2d/0x3e [<c017513f>] do_mount+0x607/0x67a [<c0175224>] sys_mount+0x72/0xa4 [<c0102b96>] sysenter_past_esp+0x5f/0x99 DWARF2 unwinder stuck at sysenter_past_esp+0x5f/0x99 Leftover inexact backtrace: ======================= and then deadlock comes. The problem: autofs_fill_super() returns EINVAL to get_sb_nodev(), but before that, it calls kill_anon_super() to destroy the superblock which won't be needed. This is however way too soon to call kill_anon_super(), because get_sb_nodev() has to perform its own cleanup of the superblock first (deactivate_super(), etc.). The correct time to call kill_anon_super() is in the autofs_kill_sb() callback, which is called by deactivate_super() at proper time, when the superblock is ready to be killed. I can see the same faulty codepath also in autofs4. This patch solves issues in both filesystems in a same way - it postpones the kill_anon_super() until the proper time is signalized by deactivate_super() calling the kill_sb() callback. [raven@themaw.net: update comment] Signed-off-by: Jiri Kosina <jkosina@suse.cz> Acked-by: Ian Kent <raven@themaw.net> Cc: <stable@kernel.org> Signed-off-by: Ian Kent <raven@themaw.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/autofs')
-rw-r--r--fs/autofs/inode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 38ede5c9d6fd..f968d1342808 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -28,10 +28,11 @@ void autofs_kill_sb(struct super_block *sb)
28 /* 28 /*
29 * In the event of a failure in get_sb_nodev the superblock 29 * In the event of a failure in get_sb_nodev the superblock
30 * info is not present so nothing else has been setup, so 30 * info is not present so nothing else has been setup, so
31 * just exit when we are called from deactivate_super. 31 * just call kill_anon_super when we are called from
32 * deactivate_super.
32 */ 33 */
33 if (!sbi) 34 if (!sbi)
34 return; 35 goto out_kill_sb;
35 36
36 if ( !sbi->catatonic ) 37 if ( !sbi->catatonic )
37 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ 38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
@@ -44,6 +45,7 @@ void autofs_kill_sb(struct super_block *sb)
44 45
45 kfree(sb->s_fs_info); 46 kfree(sb->s_fs_info);
46 47
48out_kill_sb:
47 DPRINTK(("autofs: shutting down\n")); 49 DPRINTK(("autofs: shutting down\n"));
48 kill_anon_super(sb); 50 kill_anon_super(sb);
49} 51}
@@ -209,7 +211,6 @@ fail_iput:
209fail_free: 211fail_free:
210 kfree(sbi); 212 kfree(sbi);
211 s->s_fs_info = NULL; 213 s->s_fs_info = NULL;
212 kill_anon_super(s);
213fail_unlock: 214fail_unlock:
214 return -EINVAL; 215 return -EINVAL;
215} 216}