Skip to content

Commit 5bd2c06

Browse files
ljskernelakpm00
authored andcommitted
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: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Damien Le Moal <dlemoal@kernel.org> [zonefs] Acked-by: "Darrick J. Wong" <djwong@kernel.org> Acked-by: Pedro 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: Andrew Morton <akpm@linux-foundation.org>
1 parent 590d356 commit 5bd2c06

16 files changed

Lines changed: 56 additions & 41 deletions

File tree

drivers/char/mem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static unsigned zero_mmap_capabilities(struct file *file)
306306
/* can't do an in-place private mapping if there's no MMU */
307307
static inline int private_mapping_ok(struct vm_area_desc *desc)
308308
{
309-
return is_nommu_shared_mapping(desc->vm_flags);
309+
return is_nommu_shared_vma_flags(&desc->vma_flags);
310310
}
311311
#else
312312

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

361361
desc->vm_ops = &mmap_mem_ops;
362362

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

526526
desc->action.success_hook = mmap_zero_private_success;

drivers/dax/device.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "dax-private.h"
1414
#include "bus.h"
1515

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

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

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

315315
desc->vm_ops = &dax_vm_ops;
316-
desc->vm_flags |= VM_HUGEPAGE;
316+
vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
317317
return 0;
318318
}
319319

fs/aio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ static const struct vm_operations_struct aio_ring_vm_ops = {
394394

395395
static int aio_ring_mmap_prepare(struct vm_area_desc *desc)
396396
{
397-
desc->vm_flags |= VM_DONTEXPAND;
397+
vma_desc_set_flags(desc, VMA_DONTEXPAND_BIT);
398398
desc->vm_ops = &aio_ring_vm_ops;
399399
return 0;
400400
}

fs/erofs/data.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,12 @@ static int erofs_file_mmap_prepare(struct vm_area_desc *desc)
438438
if (!IS_DAX(file_inode(desc->file)))
439439
return generic_file_readonly_mmap_prepare(desc);
440440

441-
if ((desc->vm_flags & VM_SHARED) && (desc->vm_flags & VM_MAYWRITE))
441+
if (vma_desc_test_flags(desc, VMA_SHARED_BIT) &&
442+
vma_desc_test_flags(desc, VMA_MAYWRITE_BIT))
442443
return -EINVAL;
443444

444445
desc->vm_ops = &erofs_dax_vm_ops;
445-
desc->vm_flags |= VM_HUGEPAGE;
446+
vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
446447
return 0;
447448
}
448449
#else

fs/ext4/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,13 +822,13 @@ static int ext4_file_mmap_prepare(struct vm_area_desc *desc)
822822
* We don't support synchronous mappings for non-DAX files and
823823
* for DAX files if underneath dax_device is not synchronous.
824824
*/
825-
if (!daxdev_mapping_supported(desc->vm_flags, file_inode(file), dax_dev))
825+
if (!daxdev_mapping_supported(desc, file_inode(file), dax_dev))
826826
return -EOPNOTSUPP;
827827

828828
file_accessed(file);
829829
if (IS_DAX(file_inode(file))) {
830830
desc->vm_ops = &ext4_dax_vm_ops;
831-
desc->vm_flags |= VM_HUGEPAGE;
831+
vma_desc_set_flags(desc, VMA_HUGEPAGE_BIT);
832832
} else {
833833
desc->vm_ops = &ext4_file_vm_ops;
834834
}

fs/ntfs3/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
347347
struct inode *inode = file_inode(file);
348348
struct ntfs_inode *ni = ntfs_i(inode);
349349
u64 from = ((u64)desc->pgoff << PAGE_SHIFT);
350-
bool rw = desc->vm_flags & VM_WRITE;
350+
const bool rw = vma_desc_test_flags(desc, VMA_WRITE_BIT);
351351
int err;
352352

353353
/* Avoid any operation if inode is bad. */

fs/orangefs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ static int orangefs_file_mmap_prepare(struct vm_area_desc *desc)
411411
"orangefs_file_mmap: called on %pD\n", file);
412412

413413
/* set the sequential readahead hint */
414-
desc->vm_flags |= VM_SEQ_READ;
415-
desc->vm_flags &= ~VM_RAND_READ;
414+
vma_desc_set_flags(desc, VMA_SEQ_READ_BIT);
415+
vma_desc_clear_flags(desc, VMA_RAND_READ_BIT);
416416

417417
file_accessed(file);
418418
desc->vm_ops = &orangefs_file_vm_ops;

fs/ramfs/file-nommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
264264
*/
265265
static int ramfs_nommu_mmap_prepare(struct vm_area_desc *desc)
266266
{
267-
if (!is_nommu_shared_mapping(desc->vm_flags))
267+
if (!is_nommu_shared_vma_flags(&desc->vma_flags))
268268
return -ENOSYS;
269269

270270
file_accessed(desc->file);

fs/resctrl/pseudo_lock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ static int pseudo_lock_dev_mmap_prepare(struct vm_area_desc *desc)
10441044
* Ensure changes are carried directly to the memory being mapped,
10451045
* do not allow copy-on-write mapping.
10461046
*/
1047-
if (!(desc->vm_flags & VM_SHARED)) {
1047+
if (!vma_desc_test_flags(desc, VMA_SHARED_BIT)) {
10481048
mutex_unlock(&rdtgroup_mutex);
10491049
return -EINVAL;
10501050
}

fs/romfs/mmap-nommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
6363
*/
6464
static int romfs_mmap_prepare(struct vm_area_desc *desc)
6565
{
66-
return is_nommu_shared_mapping(desc->vm_flags) ? 0 : -ENOSYS;
66+
return is_nommu_shared_vma_flags(&desc->vma_flags) ? 0 : -ENOSYS;
6767
}
6868

6969
static unsigned romfs_mmap_capabilities(struct file *file)

0 commit comments

Comments
 (0)