aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2014-12-12 19:54:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 15:42:45 -0500
commitc8c06efa8b552608493b7066c234cfa82c47fcea (patch)
tree7e206c669149766fb5a77a3ef85cdd4fac63be78 /fs
parent83cde9e8ba95d180eaefefe834958fbf7008cf39 (diff)
mm: convert i_mmap_mutex to rwsem
The i_mmap_mutex is a close cousin of the anon vma lock, both protecting similar data, one for file backed pages and the other for anon memory. To this end, this lock can also be a rwsem. In addition, there are some important opportunities to share the lock when there are no tree modifications. This conversion is straightforward. For now, all users take the write lock. [sfr@canb.auug.org.au: update fremap.c] Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Acked-by: "Kirill A. Shutemov" <kirill@shutemov.name> Acked-by: Hugh Dickins <hughd@google.com> Cc: Oleg Nesterov <oleg@redhat.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Acked-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/hugetlbfs/inode.c10
-rw-r--r--fs/inode.c2
2 files changed, 6 insertions, 6 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a082709aa427..5eba47f593f8 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -472,12 +472,12 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
472} 472}
473 473
474/* 474/*
475 * Hugetlbfs is not reclaimable; therefore its i_mmap_mutex will never 475 * Hugetlbfs is not reclaimable; therefore its i_mmap_rwsem will never
476 * be taken from reclaim -- unlike regular filesystems. This needs an 476 * be taken from reclaim -- unlike regular filesystems. This needs an
477 * annotation because huge_pmd_share() does an allocation under 477 * annotation because huge_pmd_share() does an allocation under
478 * i_mmap_mutex. 478 * i_mmap_rwsem.
479 */ 479 */
480static struct lock_class_key hugetlbfs_i_mmap_mutex_key; 480static struct lock_class_key hugetlbfs_i_mmap_rwsem_key;
481 481
482static struct inode *hugetlbfs_get_inode(struct super_block *sb, 482static struct inode *hugetlbfs_get_inode(struct super_block *sb,
483 struct inode *dir, 483 struct inode *dir,
@@ -495,8 +495,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
495 struct hugetlbfs_inode_info *info; 495 struct hugetlbfs_inode_info *info;
496 inode->i_ino = get_next_ino(); 496 inode->i_ino = get_next_ino();
497 inode_init_owner(inode, dir, mode); 497 inode_init_owner(inode, dir, mode);
498 lockdep_set_class(&inode->i_mapping->i_mmap_mutex, 498 lockdep_set_class(&inode->i_mapping->i_mmap_rwsem,
499 &hugetlbfs_i_mmap_mutex_key); 499 &hugetlbfs_i_mmap_rwsem_key);
500 inode->i_mapping->a_ops = &hugetlbfs_aops; 500 inode->i_mapping->a_ops = &hugetlbfs_aops;
501 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 501 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
502 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 502 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
diff --git a/fs/inode.c b/fs/inode.c
index 2ed95f7caa4f..ad60555b4768 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -346,7 +346,7 @@ void address_space_init_once(struct address_space *mapping)
346 memset(mapping, 0, sizeof(*mapping)); 346 memset(mapping, 0, sizeof(*mapping));
347 INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC); 347 INIT_RADIX_TREE(&mapping->page_tree, GFP_ATOMIC);
348 spin_lock_init(&mapping->tree_lock); 348 spin_lock_init(&mapping->tree_lock);
349 mutex_init(&mapping->i_mmap_mutex); 349 init_rwsem(&mapping->i_mmap_rwsem);
350 INIT_LIST_HEAD(&mapping->private_list); 350 INIT_LIST_HEAD(&mapping->private_list);
351 spin_lock_init(&mapping->private_lock); 351 spin_lock_init(&mapping->private_lock);
352 mapping->i_mmap = RB_ROOT; 352 mapping->i_mmap = RB_ROOT;