Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

device/dax: update devdax to use mmap_prepare

The devdax driver does nothing special in its f_op->mmap hook, so
straightforwardly update it to use the mmap_prepare hook instead.

Link: https://lkml.kernel.org/r/1e8665d052ac8cf2f7ff92b6c7862614f7fd306c.1760959442.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Pedro Falcato <pfalcato@suse.de>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Chatre, Reinette <reinette.chatre@intel.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christian Brauner <brauner@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: Dave Young <dyoung@redhat.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kevin Tian <kevin.tian@intel.com>
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: Nicolas Pitre <nico@fluxnic.net>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Robin Murohy <robin.murphy@arm.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
8e18a7f4 ab3c8e7b

+21 -11
+21 -11
drivers/dax/device.c
··· 13 13 #include "dax-private.h" 14 14 #include "bus.h" 15 15 16 - static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, 17 - const char *func) 16 + static int __check_vma(struct dev_dax *dev_dax, vm_flags_t vm_flags, 17 + unsigned long start, unsigned long end, struct file *file, 18 + const char *func) 18 19 { 19 20 struct device *dev = &dev_dax->dev; 20 21 unsigned long mask; ··· 24 23 return -ENXIO; 25 24 26 25 /* prevent private mappings from being established */ 27 - if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) { 26 + if ((vm_flags & VM_MAYSHARE) != VM_MAYSHARE) { 28 27 dev_info_ratelimited(dev, 29 28 "%s: %s: fail, attempted private mapping\n", 30 29 current->comm, func); ··· 32 31 } 33 32 34 33 mask = dev_dax->align - 1; 35 - if (vma->vm_start & mask || vma->vm_end & mask) { 34 + if (start & mask || end & mask) { 36 35 dev_info_ratelimited(dev, 37 36 "%s: %s: fail, unaligned vma (%#lx - %#lx, %#lx)\n", 38 - current->comm, func, vma->vm_start, vma->vm_end, 37 + current->comm, func, start, end, 39 38 mask); 40 39 return -EINVAL; 41 40 } 42 41 43 - if (!vma_is_dax(vma)) { 42 + if (!file_is_dax(file)) { 44 43 dev_info_ratelimited(dev, 45 44 "%s: %s: fail, vma is not DAX capable\n", 46 45 current->comm, func); ··· 48 47 } 49 48 50 49 return 0; 50 + } 51 + 52 + static int check_vma(struct dev_dax *dev_dax, struct vm_area_struct *vma, 53 + const char *func) 54 + { 55 + return __check_vma(dev_dax, vma->vm_flags, vma->vm_start, vma->vm_end, 56 + vma->vm_file, func); 51 57 } 52 58 53 59 /* see "strong" declaration in tools/testing/nvdimm/dax-dev.c */ ··· 293 285 .pagesize = dev_dax_pagesize, 294 286 }; 295 287 296 - static int dax_mmap(struct file *filp, struct vm_area_struct *vma) 288 + static int dax_mmap_prepare(struct vm_area_desc *desc) 297 289 { 290 + struct file *filp = desc->file; 298 291 struct dev_dax *dev_dax = filp->private_data; 299 292 int rc, id; 300 293 ··· 306 297 * fault time. 307 298 */ 308 299 id = dax_read_lock(); 309 - rc = check_vma(dev_dax, vma, __func__); 300 + rc = __check_vma(dev_dax, desc->vm_flags, desc->start, desc->end, filp, 301 + __func__); 310 302 dax_read_unlock(id); 311 303 if (rc) 312 304 return rc; 313 305 314 - vma->vm_ops = &dax_vm_ops; 315 - vm_flags_set(vma, VM_HUGEPAGE); 306 + desc->vm_ops = &dax_vm_ops; 307 + desc->vm_flags |= VM_HUGEPAGE; 316 308 return 0; 317 309 } 318 310 ··· 386 376 .open = dax_open, 387 377 .release = dax_release, 388 378 .get_unmapped_area = dax_get_unmapped_area, 389 - .mmap = dax_mmap, 379 + .mmap_prepare = dax_mmap_prepare, 390 380 .fop_flags = FOP_MMAP_SYNC, 391 381 }; 392 382