]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
relay: update relay to use mmap_prepare
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Wed, 10 Sep 2025 20:21:59 +0000 (21:21 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:26:10 +0000 (17:26 -0700)
It is relatively trivial to update this code to use the f_op->mmap_prepare
hook in favour of the deprecated f_op->mmap hook, so do so.

Link: https://lkml.kernel.org/r/3e34bb15a386d64e308c897ea1125e5e24fc6fa4.1757534913.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
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: Jan Kara <jack@suse.cz>
Cc: Jann Horn <jannh@google.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Jonathan Corbet <corbet@lwn.net>
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: 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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/relay.c

index 8d915fe9819891ce0fa1f6bed50c9417d3588511..e36f6b926f7f044efd36d0a1c55a106969d7cdfe 100644 (file)
@@ -72,17 +72,18 @@ static void relay_free_page_array(struct page **array)
 }
 
 /**
- *     relay_mmap_buf: - mmap channel buffer to process address space
- *     @buf: relay channel buffer
- *     @vma: vm_area_struct describing memory to be mapped
+ *     relay_mmap_prepare_buf: - mmap channel buffer to process address space
+ *     @buf: the relay channel buffer
+ *     @desc: describing what to map
  *
  *     Returns 0 if ok, negative on error
  *
  *     Caller should already have grabbed mmap_lock.
  */
-static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
+static int relay_mmap_prepare_buf(struct rchan_buf *buf,
+                                 struct vm_area_desc *desc)
 {
-       unsigned long length = vma->vm_end - vma->vm_start;
+       unsigned long length = vma_desc_size(desc);
 
        if (!buf)
                return -EBADF;
@@ -90,9 +91,9 @@ static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
        if (length != (unsigned long)buf->chan->alloc_size)
                return -EINVAL;
 
-       vma->vm_ops = &relay_file_mmap_ops;
-       vm_flags_set(vma, VM_DONTEXPAND);
-       vma->vm_private_data = buf;
+       desc->vm_ops = &relay_file_mmap_ops;
+       desc->vm_flags |= VM_DONTEXPAND;
+       desc->private_data = buf;
 
        return 0;
 }
@@ -749,16 +750,16 @@ static int relay_file_open(struct inode *inode, struct file *filp)
 }
 
 /**
- *     relay_file_mmap - mmap file op for relay files
- *     @filp: the file
- *     @vma: the vma describing what to map
+ *     relay_file_mmap_prepare - mmap file op for relay files
+ *     @desc: describing what to map
  *
- *     Calls upon relay_mmap_buf() to map the file into user space.
+ *     Calls upon relay_mmap_prepare_buf() to map the file into user space.
  */
-static int relay_file_mmap(struct file *filp, struct vm_area_struct *vma)
+static int relay_file_mmap_prepare(struct vm_area_desc *desc)
 {
-       struct rchan_buf *buf = filp->private_data;
-       return relay_mmap_buf(buf, vma);
+       struct rchan_buf *buf = desc->file->private_data;
+
+       return relay_mmap_prepare_buf(buf, desc);
 }
 
 /**
@@ -1006,7 +1007,7 @@ static ssize_t relay_file_read(struct file *filp,
 const struct file_operations relay_file_operations = {
        .open           = relay_file_open,
        .poll           = relay_file_poll,
-       .mmap           = relay_file_mmap,
+       .mmap_prepare   = relay_file_mmap_prepare,
        .read           = relay_file_read,
        .release        = relay_file_release,
 };