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.

relay: update relay to use mmap_prepare

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/7c9e82cdddf8b573ea3edb8cdb697363e3ccb5d7.1760959442.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-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: Jan Kara <jack@suse.cz>
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
651fdda8 54c58a2f

+17 -16
+17 -16
kernel/relay.c
··· 72 72 } 73 73 74 74 /** 75 - * relay_mmap_buf: - mmap channel buffer to process address space 76 - * @buf: relay channel buffer 77 - * @vma: vm_area_struct describing memory to be mapped 75 + * relay_mmap_prepare_buf: - mmap channel buffer to process address space 76 + * @buf: the relay channel buffer 77 + * @desc: describing what to map 78 78 * 79 79 * Returns 0 if ok, negative on error 80 80 * 81 81 * Caller should already have grabbed mmap_lock. 82 82 */ 83 - static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma) 83 + static int relay_mmap_prepare_buf(struct rchan_buf *buf, 84 + struct vm_area_desc *desc) 84 85 { 85 - unsigned long length = vma->vm_end - vma->vm_start; 86 + unsigned long length = vma_desc_size(desc); 86 87 87 88 if (!buf) 88 89 return -EBADF; ··· 91 90 if (length != (unsigned long)buf->chan->alloc_size) 92 91 return -EINVAL; 93 92 94 - vma->vm_ops = &relay_file_mmap_ops; 95 - vm_flags_set(vma, VM_DONTEXPAND); 96 - vma->vm_private_data = buf; 93 + desc->vm_ops = &relay_file_mmap_ops; 94 + desc->vm_flags |= VM_DONTEXPAND; 95 + desc->private_data = buf; 97 96 98 97 return 0; 99 98 } ··· 750 749 } 751 750 752 751 /** 753 - * relay_file_mmap - mmap file op for relay files 754 - * @filp: the file 755 - * @vma: the vma describing what to map 752 + * relay_file_mmap_prepare - mmap file op for relay files 753 + * @desc: describing what to map 756 754 * 757 - * Calls upon relay_mmap_buf() to map the file into user space. 755 + * Calls upon relay_mmap_prepare_buf() to map the file into user space. 758 756 */ 759 - static int relay_file_mmap(struct file *filp, struct vm_area_struct *vma) 757 + static int relay_file_mmap_prepare(struct vm_area_desc *desc) 760 758 { 761 - struct rchan_buf *buf = filp->private_data; 762 - return relay_mmap_buf(buf, vma); 759 + struct rchan_buf *buf = desc->file->private_data; 760 + 761 + return relay_mmap_prepare_buf(buf, desc); 763 762 } 764 763 765 764 /** ··· 1007 1006 const struct file_operations relay_file_operations = { 1008 1007 .open = relay_file_open, 1009 1008 .poll = relay_file_poll, 1010 - .mmap = relay_file_mmap, 1009 + .mmap_prepare = relay_file_mmap_prepare, 1011 1010 .read = relay_file_read, 1012 1011 .release = relay_file_release, 1013 1012 };