aboutsummaryrefslogtreecommitdiffstats
path: root/fs/buffer.c
diff options
context:
space:
mode:
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>2014-02-06 15:04:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-02-06 16:48:51 -0500
commit227d53b397a32a7614667b3ecaf1d89902fb6c12 (patch)
treecfdccad47eb1404da7a657cd260af3ba1b3c3120 /fs/buffer.c
parent7bc35fdde6724549a0239b71e08b9f33d8bf2bfb (diff)
mm: __set_page_dirty uses spin_lock_irqsave instead of spin_lock_irq
To use spin_{un}lock_irq is dangerous if caller disabled interrupt. During aio buffer migration, we have a possibility to see the following call stack. aio_migratepage [disable interrupt] migrate_page_copy clear_page_dirty_for_io set_page_dirty __set_page_dirty_buffers __set_page_dirty spin_lock_irq This mean, current aio migration is a deadlockable. spin_lock_irqsave is a safer alternative and we should use it. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reported-by: David Rientjes rientjes@google.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/buffer.c')
-rw-r--r--fs/buffer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 651dba10b9c2..27265a8b43c1 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -654,14 +654,16 @@ EXPORT_SYMBOL(mark_buffer_dirty_inode);
654static void __set_page_dirty(struct page *page, 654static void __set_page_dirty(struct page *page,
655 struct address_space *mapping, int warn) 655 struct address_space *mapping, int warn)
656{ 656{
657 spin_lock_irq(&mapping->tree_lock); 657 unsigned long flags;
658
659 spin_lock_irqsave(&mapping->tree_lock, flags);
658 if (page->mapping) { /* Race with truncate? */ 660 if (page->mapping) { /* Race with truncate? */
659 WARN_ON_ONCE(warn && !PageUptodate(page)); 661 WARN_ON_ONCE(warn && !PageUptodate(page));
660 account_page_dirtied(page, mapping); 662 account_page_dirtied(page, mapping);
661 radix_tree_tag_set(&mapping->page_tree, 663 radix_tree_tag_set(&mapping->page_tree,
662 page_index(page), PAGECACHE_TAG_DIRTY); 664 page_index(page), PAGECACHE_TAG_DIRTY);
663 } 665 }
664 spin_unlock_irq(&mapping->tree_lock); 666 spin_unlock_irqrestore(&mapping->tree_lock, flags);
665 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); 667 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
666} 668}
667 669