Re: make alloc_anon_inode more useful
From: Matthew Wilcox <willy@infradead.org>
Date: 2021-03-10 04:08:06
Also in:
dri-devel, linux-mm, linuxppc-dev, lkml, virtualization
Subsystem:
arc framebuffer driver, framebuffer core, framebuffer layer, the rest · Maintainers:
Jaya Kumar, Simona Vetter, Helge Deller, Linus Torvalds
On Tue, Mar 09, 2021 at 04:53:39PM +0100, Christoph Hellwig wrote:
this series first renames the existing alloc_anon_inode to alloc_anon_inode_sb to clearly mark it as requiring a superblock. It then adds a new alloc_anon_inode that works on the anon_inode file system super block, thus removing tons of boilerplate code. The few remainig callers of alloc_anon_inode_sb all use alloc_file_pseudo later, but might also be ripe for some cleanup.
On a somewhat related note, could I get you to look at drivers/video/fbdev/core/fb_defio.c? As far as I can tell, there's no need for fb_deferred_io_aops to exist. We could just set file->f_mapping->a_ops to NULL, and set_page_dirty() would do the exact same thing this code does (except it would get the return value correct). But maybe that would make something else go wrong that distinguishes between page->mapping being NULL and page->mapping->a_ops->foo being NULL? Completely untested patch ...
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c
index a591d291b231..441ec31d3e4d 100644
--- a/drivers/video/fbdev/core/fb_defio.c
+++ b/drivers/video/fbdev/core/fb_defio.c@@ -151,17 +151,6 @@ static const struct vm_operations_struct fb_deferred_io_vm_ops = { .page_mkwrite = fb_deferred_io_mkwrite, }; -static int fb_deferred_io_set_page_dirty(struct page *page) -{ - if (!PageDirty(page)) - SetPageDirty(page); - return 0; -} - -static const struct address_space_operations fb_deferred_io_aops = { - .set_page_dirty = fb_deferred_io_set_page_dirty, -}; - int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) { vma->vm_ops = &fb_deferred_io_vm_ops;
@@ -212,14 +201,6 @@ void fb_deferred_io_init(struct fb_info *info) } EXPORT_SYMBOL_GPL(fb_deferred_io_init); -void fb_deferred_io_open(struct fb_info *info, - struct inode *inode, - struct file *file) -{ - file->f_mapping->a_ops = &fb_deferred_io_aops; -} -EXPORT_SYMBOL_GPL(fb_deferred_io_open); - void fb_deferred_io_cleanup(struct fb_info *info) { struct fb_deferred_io *fbdefio = info->fbdefio;
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 06f5805de2de..c4ba76359f22 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c@@ -1415,10 +1415,7 @@ __releases(&info->lock) if (res) module_put(info->fbops->owner); } -#ifdef CONFIG_FB_DEFERRED_IO - if (info->fbdefio) - fb_deferred_io_open(info, inode, file); -#endif + file->f_mapping->a_ops = NULL; out: unlock_fb_info(info); if (res)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index ecfbcc0553a5..a8dccd23c249 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h@@ -659,9 +659,6 @@ static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, /* drivers/video/fb_defio.c */ int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma); extern void fb_deferred_io_init(struct fb_info *info); -extern void fb_deferred_io_open(struct fb_info *info, - struct inode *inode, - struct file *file); extern void fb_deferred_io_cleanup(struct fb_info *info); extern int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasync);