Commit 0c2aa663 authored by Lorenzo Stoakes (Oracle)'s avatar Lorenzo Stoakes (Oracle) Committed by Andrew Morton
Browse files

mm: reintroduce vma_desc_test() as a singular flag test

Similar to vma_flags_test(), we have previously renamed vma_desc_test() to
vma_desc_test_any().  Now that is in place, we can reintroduce
vma_desc_test() to explicitly check for a single VMA flag.

As with vma_flags_test(), this is useful as often flag tests are against a
single flag, and vma_desc_test_any(flags, VMA_READ_BIT) reads oddly and
potentially causes confusion.

As with vma_flags_test() a combination of sparse and vma_flags_t being a
struct means that users cannot misuse this function without it getting
flagged.

Also update the VMA tests to reflect this change.

Link: https://lkml.kernel.org/r/3a65ca23defb05060333f0586428fe279a484564.1772704455.git.ljs@kernel.org


Signed-off-by: default avatarLorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: default avatarDavid Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: default avatarPedro Falcato <pfalcato@suse.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Babu Moger <babu.moger@amd.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Chatre, Reinette <reinette.chatre@intel.com>
Cc: Chunhai Guo <guochunhai@vivo.com>
Cc: Damien Le Maol <dlemoal@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Dave Martin <dave.martin@arm.com>
Cc: Gao Xiang <xiang@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hongbo Li <lihongbo22@huawei.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naohiro Aota <naohiro.aota@wdc.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Sandeep Dhavale <dhavale@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Yue Hu <zbestahu@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 5e6d45d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -520,7 +520,7 @@ static int mmap_zero_prepare(struct vm_area_desc *desc)
#ifndef CONFIG_MMU
	return -ENOSYS;
#endif
	if (vma_desc_test_any(desc, VMA_SHARED_BIT))
	if (vma_desc_test(desc, VMA_SHARED_BIT))
		return shmem_zero_setup_desc(desc);

	desc->action.success_hook = mmap_zero_private_success;
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ static int hugetlbfs_file_mmap_prepare(struct vm_area_desc *desc)
		goto out;

	ret = 0;
	if (vma_desc_test_any(desc, VMA_WRITE_BIT) && inode->i_size < len)
	if (vma_desc_test(desc, VMA_WRITE_BIT) && inode->i_size < len)
		i_size_write(inode, len);
out:
	inode_unlock(inode);
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ static int ntfs_file_mmap_prepare(struct vm_area_desc *desc)
	struct file *file = desc->file;
	struct inode *inode = file_inode(file);
	struct ntfs_inode *ni = ntfs_i(inode);
	const bool rw = vma_desc_test_any(desc, VMA_WRITE_BIT);
	const bool rw = vma_desc_test(desc, VMA_WRITE_BIT);
	int err;

	/* Avoid any operation if inode is bad. */
+1 −1
Original line number Diff line number Diff line
@@ -1044,7 +1044,7 @@ static int pseudo_lock_dev_mmap_prepare(struct vm_area_desc *desc)
	 * Ensure changes are carried directly to the memory being mapped,
	 * do not allow copy-on-write mapping.
	 */
	if (!vma_desc_test_any(desc, VMA_SHARED_BIT)) {
	if (!vma_desc_test(desc, VMA_SHARED_BIT)) {
		mutex_unlock(&rdtgroup_mutex);
		return -EINVAL;
	}
+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ static inline bool daxdev_mapping_supported(const struct vm_area_desc *desc,
					    const struct inode *inode,
					    struct dax_device *dax_dev)
{
	if (!vma_desc_test_any(desc, VMA_SYNC_BIT))
	if (!vma_desc_test(desc, VMA_SYNC_BIT))
		return true;
	if (!IS_DAX(inode))
		return false;
@@ -115,7 +115,7 @@ static inline bool daxdev_mapping_supported(const struct vm_area_desc *desc,
					    const struct inode *inode,
					    struct dax_device *dax_dev)
{
	return !vma_desc_test_any(desc, VMA_SYNC_BIT);
	return !vma_desc_test(desc, VMA_SYNC_BIT);
}
static inline size_t dax_recovery_write(struct dax_device *dax_dev,
		pgoff_t pgoff, void *addr, size_t bytes, struct iov_iter *i)
Loading