Commit 5bd2c065 authored by Lorenzo Stoakes's avatar Lorenzo Stoakes Committed by Andrew Morton
Browse files

mm: update all remaining mmap_prepare users to use vma_flags_t

We will be shortly removing the vm_flags_t field from vm_area_desc so we
need to update all mmap_prepare users to only use the dessc->vma_flags
field.

This patch achieves that and makes all ancillary changes required to make
this possible.

This lays the groundwork for future work to eliminate the use of
vm_flags_t in vm_area_desc altogether and more broadly throughout the
kernel.

While we're here, we take the opportunity to replace VM_REMAP_FLAGS with
VMA_REMAP_FLAGS, the vma_flags_t equivalent.

No functional changes intended.

Link: https://lkml.kernel.org/r/fb1f55323799f09fe6a36865b31550c9ec67c225.1769097829.git.lorenzo.stoakes@oracle.com


Signed-off-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Damien Le Moal <dlemoal@kernel.org>	[zonefs]
Acked-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Acked-by: default avatarPedro Falcato <pfalcato@suse.de>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: Yury Norov <ynorov@nvidia.com>
Cc: Chris Mason <clm@fb.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 590d356a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -306,7 +306,7 @@ static unsigned zero_mmap_capabilities(struct file *file)
/* can't do an in-place private mapping if there's no MMU */
static inline int private_mapping_ok(struct vm_area_desc *desc)
{
	return is_nommu_shared_mapping(desc->vm_flags);
	return is_nommu_shared_vma_flags(&desc->vma_flags);
}
#else

@@ -360,7 +360,7 @@ static int mmap_mem_prepare(struct vm_area_desc *desc)

	desc->vm_ops = &mmap_mem_ops;

	/* Remap-pfn-range will mark the range VM_IO. */
	/* Remap-pfn-range will mark the range with the I/O flag. */
	mmap_action_remap_full(desc, desc->pgoff);
	/* We filter remap errors to -EAGAIN. */
	desc->action.error_hook = mmap_filter_error;
@@ -520,7 +520,7 @@ static int mmap_zero_prepare(struct vm_area_desc *desc)
#ifndef CONFIG_MMU
	return -ENOSYS;
#endif
	if (desc->vm_flags & VM_SHARED)
	if (vma_desc_test_flags(desc, VMA_SHARED_BIT))
		return shmem_zero_setup_desc(desc);

	desc->action.success_hook = mmap_zero_private_success;
+5 −5
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#include "dax-private.h"
#include "bus.h"

static int __check_vma(struct dev_dax *dev_dax, vm_flags_t vm_flags,
static int __check_vma(struct dev_dax *dev_dax, vma_flags_t flags,
		       unsigned long start, unsigned long end, struct file *file,
		       const char *func)
{
@@ -24,7 +24,7 @@ static int __check_vma(struct dev_dax *dev_dax, vm_flags_t vm_flags,
		return -ENXIO;

	/* prevent private mappings from being established */
	if ((vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
	if (!vma_flags_test(&flags, VMA_MAYSHARE_BIT)) {
		dev_info_ratelimited(dev,
				"%s: %s: fail, attempted private mapping\n",
				current->comm, func);
@@ -53,7 +53,7 @@ static int __check_vma(struct dev_dax *dev_dax, vm_flags_t vm_flags,
static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma,
		     const char *func)
{
	return __check_vma(dev_dax, vma->vm_flags, vma->vm_start, vma->vm_end,
	return __check_vma(dev_dax, vma->flags, vma->vm_start, vma->vm_end,
			   vma->vm_file, func);
}

@@ -306,14 +306,14 @@ static int dax_mmap_prepare(struct vm_area_desc *desc)
	 * fault time.
	 */
	id = dax_read_lock();
	rc = __check_vma(dev_dax, desc->vm_flags, desc->start, desc->end, filp,
	rc = __check_vma(dev_dax, desc->vma_flags, desc->start, desc->end, filp,
			 __func__);
	dax_read_unlock(id);
	if (rc)
		return rc;

	desc->vm_ops = &dax_vm_ops;
	desc->vm_flags |= VM_HUGEPAGE;
	vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -394,7 +394,7 @@ static const struct vm_operations_struct aio_ring_vm_ops = {

static int aio_ring_mmap_prepare(struct vm_area_desc *desc)
{
	desc->vm_flags |= VM_DONTEXPAND;
	vma_desc_set_flags(desc, VMA_DONTEXPAND_BIT);
	desc->vm_ops = &aio_ring_vm_ops;
	return 0;
}
+3 −2
Original line number Diff line number Diff line
@@ -438,11 +438,12 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
	if (!IS_DAX(file_inode(desc->file)))
		return generic_file_readonly_mmap_prepare(desc);

	if ((desc->vm_flags & VM_SHARED) && (desc->vm_flags & VM_MAYWRITE))
	if (vma_desc_test_flags(desc, VMA_SHARED_BIT) &&
	    vma_desc_test_flags(desc, VMA_MAYWRITE_BIT))
		return -EINVAL;

	desc->vm_ops = &erofs_dax_vm_ops;
	desc->vm_flags |= VM_HUGEPAGE;
	vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
	return 0;
}
#else
+2 −2
Original line number Diff line number Diff line
@@ -822,13 +822,13 @@ static int ext4_file_mmap_prepare(struct vm_area_desc *desc)
	 * We don't support synchronous mappings for non-DAX files and
	 * for DAX files if underneath dax_device is not synchronous.
	 */
	if (!daxdev_mapping_supported(desc->vm_flags, file_inode(file), dax_dev))
	if (!daxdev_mapping_supported(desc, file_inode(file), dax_dev))
		return -EOPNOTSUPP;

	file_accessed(file);
	if (IS_DAX(file_inode(file))) {
		desc->vm_ops = &ext4_dax_vm_ops;
		desc->vm_flags |= VM_HUGEPAGE;
		vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
	} else {
		desc->vm_ops = &ext4_file_vm_ops;
	}
Loading