From 51ee049e771c14a29aaee8ecd6cbbe14db088f3a Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Tue, 27 Apr 2010 14:23:57 -0700 Subject: vfs: add lockdep annotation to s_vfs_rename_key for ecryptfs > ============================================= > [ INFO: possible recursive locking detected ] > 2.6.31-2-generic #14~rbd3 > --------------------------------------------- > firefox-3.5/4162 is trying to acquire lock: > (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > > but task is already holding lock: > (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > > other info that might help us debug this: > 3 locks held by firefox-3.5/4162: > #0: (&s->s_vfs_rename_mutex){+.+.+.}, at: [] lock_rename+0x41/0xf0 > #1: (&sb->s_type->i_mutex_key#11/1){+.+.+.}, at: [] lock_rename+0x6a/0xf0 > #2: (&sb->s_type->i_mutex_key#11/2){+.+.+.}, at: [] lock_rename+0x7f/0xf0 > > stack backtrace: > Pid: 4162, comm: firefox-3.5 Tainted: G C 2.6.31-2-generic #14~rbd3 > Call Trace: > [] print_deadlock_bug+0xf4/0x100 > [] validate_chain+0x4c6/0x750 > [] __lock_acquire+0x237/0x430 > [] lock_acquire+0xa5/0x150 > [] ? lock_rename+0x41/0xf0 > [] __mutex_lock_common+0x4d/0x3d0 > [] ? lock_rename+0x41/0xf0 > [] ? lock_rename+0x41/0xf0 > [] ? ecryptfs_rename+0x99/0x170 > [] mutex_lock_nested+0x46/0x60 > [] lock_rename+0x41/0xf0 > [] ecryptfs_rename+0xca/0x170 > [] vfs_rename_dir+0x13e/0x160 > [] vfs_rename+0xee/0x290 > [] ? __lookup_hash+0x102/0x160 > [] sys_renameat+0x252/0x280 > [] ? cp_new_stat+0xe4/0x100 > [] ? sysret_check+0x2e/0x69 > [] ? trace_hardirqs_on_caller+0x14d/0x190 > [] sys_rename+0x1b/0x20 > [] system_call_fastpath+0x16/0x1b The trace above is totally reproducible by doing a cross-directory rename on an ecryptfs directory. The issue seems to be that sys_renameat() does lock_rename() then calls into the filesystem; if the filesystem is ecryptfs, then ecryptfs_rename() again does lock_rename() on the lower filesystem, and lockdep can't tell that the two s_vfs_rename_mutexes are different. It seems an annotation like the following is sufficient to fix this (it does get rid of the lockdep trace in my simple tests); however I would like to make sure I'm not misunderstanding the locking, hence the CC list... Signed-off-by: Roland Dreier Cc: Tyler Hicks Cc: Dustin Kirkland Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Al Viro --- fs/super.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/super.c') diff --git a/fs/super.c b/fs/super.c index 89afca5..69688b1 100644 --- a/fs/super.c +++ b/fs/super.c @@ -88,6 +88,7 @@ static struct super_block *alloc_super(struct file_system_type *type) s->s_count = 1; atomic_set(&s->s_active, 1); mutex_init(&s->s_vfs_rename_mutex); + lockdep_set_class(&s->s_vfs_rename_mutex, &type->s_vfs_rename_key); mutex_init(&s->s_dquot.dqio_mutex); mutex_init(&s->s_dquot.dqonoff_mutex); init_rwsem(&s->s_dquot.dqptr_sem); -- cgit v1.1