Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83cde9e8 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Linus Torvalds
Browse files

mm: use new helper functions around the i_mmap_mutex



Convert all open coded mutex_lock/unlock calls to the
i_mmap_[lock/unlock]_write() helpers.

Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Acked-by: default avatarRik van Riel <riel@redhat.com>
Acked-by: default avatar"Kirill A. Shutemov" <kirill@shutemov.name>
Acked-by: default avatarHugh Dickins <hughd@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: default avatarMel Gorman <mgorman@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8b28f621
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -412,10 +412,10 @@ static int hugetlb_vmtruncate(struct inode *inode, loff_t offset)
	pgoff = offset >> PAGE_SHIFT;

	i_size_write(inode, offset);
	mutex_lock(&mapping->i_mmap_mutex);
	i_mmap_lock_write(mapping);
	if (!RB_EMPTY_ROOT(&mapping->i_mmap))
		hugetlb_vmtruncate_list(&mapping->i_mmap, pgoff);
	mutex_unlock(&mapping->i_mmap_mutex);
	i_mmap_unlock_write(mapping);
	truncate_hugepages(inode, offset);
	return 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -724,7 +724,7 @@ build_map_info(struct address_space *mapping, loff_t offset, bool is_register)
	int more = 0;

 again:
	mutex_lock(&mapping->i_mmap_mutex);
	i_mmap_lock_write(mapping);
	vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
		if (!valid_vma(vma, is_register))
			continue;
@@ -755,7 +755,7 @@ build_map_info(struct address_space *mapping, loff_t offset, bool is_register)
		info->mm = vma->vm_mm;
		info->vaddr = offset_to_vaddr(vma, offset);
	}
	mutex_unlock(&mapping->i_mmap_mutex);
	i_mmap_unlock_write(mapping);

	if (!more)
		goto out;
+2 −2
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
			get_file(file);
			if (tmp->vm_flags & VM_DENYWRITE)
				atomic_dec(&inode->i_writecount);
			mutex_lock(&mapping->i_mmap_mutex);
			i_mmap_lock_write(mapping);
			if (tmp->vm_flags & VM_SHARED)
				atomic_inc(&mapping->i_mmap_writable);
			flush_dcache_mmap_lock(mapping);
@@ -445,7 +445,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
				vma_interval_tree_insert_after(tmp, mpnt,
							&mapping->i_mmap);
			flush_dcache_mmap_unlock(mapping);
			mutex_unlock(&mapping->i_mmap_mutex);
			i_mmap_unlock_write(mapping);
		}

		/*
+2 −2
Original line number Diff line number Diff line
@@ -182,7 +182,7 @@ __xip_unmap (struct address_space * mapping,
		return;

retry:
	mutex_lock(&mapping->i_mmap_mutex);
	i_mmap_lock_write(mapping);
	vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff, pgoff) {
		mm = vma->vm_mm;
		address = vma->vm_start +
@@ -202,7 +202,7 @@ __xip_unmap (struct address_space * mapping,
			page_cache_release(page);
		}
	}
	mutex_unlock(&mapping->i_mmap_mutex);
	i_mmap_unlock_write(mapping);

	if (locked) {
		mutex_unlock(&xip_sparse_mutex);
+2 −2
Original line number Diff line number Diff line
@@ -238,13 +238,13 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
			}
			goto out_freed;
		}
		mutex_lock(&mapping->i_mmap_mutex);
		i_mmap_lock_write(mapping);
		flush_dcache_mmap_lock(mapping);
		vma->vm_flags |= VM_NONLINEAR;
		vma_interval_tree_remove(vma, &mapping->i_mmap);
		vma_nonlinear_insert(vma, &mapping->i_mmap_nonlinear);
		flush_dcache_mmap_unlock(mapping);
		mutex_unlock(&mapping->i_mmap_mutex);
		i_mmap_unlock_write(mapping);
	}

	if (vma->vm_flags & VM_LOCKED) {
Loading