Re: [PATCH] fs: clean up usage of noop_dirty_folio
On Mon, Aug 21, 2023 at 01:20:33PM +0100, Matthew Wilcox wrote: > I was hoping Christoph would weigh in ;-) I don't have a strong I've enjoyed 2 weeks of almost uninterrupted vacation. I agree with this patch and also your incremental improvements.
Re: [PATCH] fs: clean up usage of noop_dirty_folio
On Mon, Aug 21, 2023 at 01:16:43PM +0200, Jan Kara wrote: > On Sat 19-08-23 20:42:25, Xueshi Hu wrote: > > In folio_mark_dirty(), it will automatically fallback to > > noop_dirty_folio() if a_ops->dirty_folio is not registered. > > > > As anon_aops, dev_dax_aops and fb_deferred_io_aops becames empty, remove > > them too. > > > > Signed-off-by: Xueshi Hu > > Yeah, looks sensible to me but for some callbacks we are oscilating between > all users having to provide some callback and providing some default > behavior for NULL callback. I don't have a strong opinion either way so > feel free to add: > > Reviewed-by: Jan Kara > > But I guess let's see what Matthew thinks about this and what plans he has > so that we don't switch back again in the near future. Matthew? I was hoping Christoph would weigh in ;-) I don't have a strong feeling here, but it seems to me that a NULL ->dirty_folio() should mean "do the noop thing" rather than "do the buffer_head thing" or "do the filemap thing". In 0af573780b0b, the buffer_head default was removed. I think enough time has passed that we're OK to change what a NULL ->dirty_folio means (plus we also changed the name of ->set_page_dirty() to ->dirty_folio()) So Ack to the concept. One minor change I'd request: -bool noop_dirty_folio(struct address_space *mapping, struct folio *folio) +static bool noop_dirty_folio(struct address_space *mapping, struct folio *folio) { if (!folio_test_dirty(folio)) return !folio_test_set_dirty(folio); return false; } -EXPORT_SYMBOL(noop_dirty_folio); Please inline this into folio_mark_dirty() instead of calling it.
Re: [PATCH] fs: clean up usage of noop_dirty_folio
On Sat 19-08-23 20:42:25, Xueshi Hu wrote: > In folio_mark_dirty(), it will automatically fallback to > noop_dirty_folio() if a_ops->dirty_folio is not registered. > > As anon_aops, dev_dax_aops and fb_deferred_io_aops becames empty, remove > them too. > > Signed-off-by: Xueshi Hu Yeah, looks sensible to me but for some callbacks we are oscilating between all users having to provide some callback and providing some default behavior for NULL callback. I don't have a strong opinion either way so feel free to add: Reviewed-by: Jan Kara But I guess let's see what Matthew thinks about this and what plans he has so that we don't switch back again in the near future. Matthew? Honza > --- > drivers/dax/device.c| 5 - > drivers/video/fbdev/core/fb_defio.c | 5 - > fs/aio.c| 1 - > fs/ext2/inode.c | 1 - > fs/ext4/inode.c | 1 - > fs/fuse/dax.c | 1 - > fs/hugetlbfs/inode.c| 1 - > fs/libfs.c | 5 - > fs/xfs/xfs_aops.c | 1 - > include/linux/pagemap.h | 1 - > mm/page-writeback.c | 6 +++--- > mm/secretmem.c | 1 - > mm/shmem.c | 1 - > mm/swap_state.c | 1 - > 14 files changed, 3 insertions(+), 28 deletions(-) > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c > index 30665a3ff6ea..018aa9f88ec7 100644 > --- a/drivers/dax/device.c > +++ b/drivers/dax/device.c > @@ -345,10 +345,6 @@ static unsigned long dax_get_unmapped_area(struct file > *filp, > return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags); > } > > -static const struct address_space_operations dev_dax_aops = { > - .dirty_folio= noop_dirty_folio, > -}; > - > static int dax_open(struct inode *inode, struct file *filp) > { > struct dax_device *dax_dev = inode_dax(inode); > @@ -358,7 +354,6 @@ static int dax_open(struct inode *inode, struct file > *filp) > dev_dbg(_dax->dev, "trace\n"); > inode->i_mapping = __dax_inode->i_mapping; > inode->i_mapping->host = __dax_inode; > - inode->i_mapping->a_ops = _dax_aops; > filp->f_mapping = inode->i_mapping; > filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping); > filp->f_sb_err = file_sample_sb_err(filp); > diff --git a/drivers/video/fbdev/core/fb_defio.c > b/drivers/video/fbdev/core/fb_defio.c > index 274f5d0fa247..08be3592281f 100644 > --- a/drivers/video/fbdev/core/fb_defio.c > +++ b/drivers/video/fbdev/core/fb_defio.c > @@ -221,10 +221,6 @@ static const struct vm_operations_struct > fb_deferred_io_vm_ops = { > .page_mkwrite = fb_deferred_io_mkwrite, > }; > > -static const struct address_space_operations fb_deferred_io_aops = { > - .dirty_folio= noop_dirty_folio, > -}; > - > int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) > { > vma->vm_ops = _deferred_io_vm_ops; > @@ -307,7 +303,6 @@ void fb_deferred_io_open(struct fb_info *info, > { > struct fb_deferred_io *fbdefio = info->fbdefio; > > - file->f_mapping->a_ops = _deferred_io_aops; > fbdefio->open_count++; > } > EXPORT_SYMBOL_GPL(fb_deferred_io_open); > diff --git a/fs/aio.c b/fs/aio.c > index 77e33619de40..4cf386f9cb1c 100644 > --- a/fs/aio.c > +++ b/fs/aio.c > @@ -484,7 +484,6 @@ static int aio_migrate_folio(struct address_space > *mapping, struct folio *dst, > #endif > > static const struct address_space_operations aio_ctx_aops = { > - .dirty_folio= noop_dirty_folio, > .migrate_folio = aio_migrate_folio, > }; > > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index 75983215c7a1..ce191bdf1c78 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -971,7 +971,6 @@ const struct address_space_operations ext2_aops = { > static const struct address_space_operations ext2_dax_aops = { > .writepages = ext2_dax_writepages, > .direct_IO = noop_direct_IO, > - .dirty_folio= noop_dirty_folio, > }; > > /* > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 43775a6ca505..67c1710c01b0 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3561,7 +3561,6 @@ static const struct address_space_operations > ext4_da_aops = { > static const struct address_space_operations ext4_dax_aops = { > .writepages = ext4_dax_writepages, > .direct_IO = noop_direct_IO, > - .dirty_folio= noop_dirty_folio, > .bmap = ext4_bmap, > .swap_activate = ext4_iomap_swap_activate, > }; > diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c > index 8e74f278a3f6..50ca767cbd5e 100644 > --- a/fs/fuse/dax.c > +++ b/fs/fuse/dax.c > @@ -1326,7 +1326,6 @@ bool fuse_dax_inode_alloc(struct super_block *sb, > struct fuse_inode *fi)
[PATCH] fs: clean up usage of noop_dirty_folio
In folio_mark_dirty(), it will automatically fallback to noop_dirty_folio() if a_ops->dirty_folio is not registered. As anon_aops, dev_dax_aops and fb_deferred_io_aops becames empty, remove them too. Signed-off-by: Xueshi Hu --- drivers/dax/device.c| 5 - drivers/video/fbdev/core/fb_defio.c | 5 - fs/aio.c| 1 - fs/ext2/inode.c | 1 - fs/ext4/inode.c | 1 - fs/fuse/dax.c | 1 - fs/hugetlbfs/inode.c| 1 - fs/libfs.c | 5 - fs/xfs/xfs_aops.c | 1 - include/linux/pagemap.h | 1 - mm/page-writeback.c | 6 +++--- mm/secretmem.c | 1 - mm/shmem.c | 1 - mm/swap_state.c | 1 - 14 files changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 30665a3ff6ea..018aa9f88ec7 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c @@ -345,10 +345,6 @@ static unsigned long dax_get_unmapped_area(struct file *filp, return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags); } -static const struct address_space_operations dev_dax_aops = { - .dirty_folio= noop_dirty_folio, -}; - static int dax_open(struct inode *inode, struct file *filp) { struct dax_device *dax_dev = inode_dax(inode); @@ -358,7 +354,6 @@ static int dax_open(struct inode *inode, struct file *filp) dev_dbg(_dax->dev, "trace\n"); inode->i_mapping = __dax_inode->i_mapping; inode->i_mapping->host = __dax_inode; - inode->i_mapping->a_ops = _dax_aops; filp->f_mapping = inode->i_mapping; filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping); filp->f_sb_err = file_sample_sb_err(filp); diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index 274f5d0fa247..08be3592281f 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -221,10 +221,6 @@ static const struct vm_operations_struct fb_deferred_io_vm_ops = { .page_mkwrite = fb_deferred_io_mkwrite, }; -static const struct address_space_operations fb_deferred_io_aops = { - .dirty_folio= noop_dirty_folio, -}; - int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) { vma->vm_ops = _deferred_io_vm_ops; @@ -307,7 +303,6 @@ void fb_deferred_io_open(struct fb_info *info, { struct fb_deferred_io *fbdefio = info->fbdefio; - file->f_mapping->a_ops = _deferred_io_aops; fbdefio->open_count++; } EXPORT_SYMBOL_GPL(fb_deferred_io_open); diff --git a/fs/aio.c b/fs/aio.c index 77e33619de40..4cf386f9cb1c 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -484,7 +484,6 @@ static int aio_migrate_folio(struct address_space *mapping, struct folio *dst, #endif static const struct address_space_operations aio_ctx_aops = { - .dirty_folio= noop_dirty_folio, .migrate_folio = aio_migrate_folio, }; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 75983215c7a1..ce191bdf1c78 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -971,7 +971,6 @@ const struct address_space_operations ext2_aops = { static const struct address_space_operations ext2_dax_aops = { .writepages = ext2_dax_writepages, .direct_IO = noop_direct_IO, - .dirty_folio= noop_dirty_folio, }; /* diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 43775a6ca505..67c1710c01b0 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3561,7 +3561,6 @@ static const struct address_space_operations ext4_da_aops = { static const struct address_space_operations ext4_dax_aops = { .writepages = ext4_dax_writepages, .direct_IO = noop_direct_IO, - .dirty_folio= noop_dirty_folio, .bmap = ext4_bmap, .swap_activate = ext4_iomap_swap_activate, }; diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 8e74f278a3f6..50ca767cbd5e 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -1326,7 +1326,6 @@ bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi) static const struct address_space_operations fuse_dax_file_aops = { .writepages = fuse_dax_writepages, .direct_IO = noop_direct_IO, - .dirty_folio= noop_dirty_folio, }; static bool fuse_should_enable_dax(struct inode *inode, unsigned int flags) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 7b17ccfa039d..5404286f0c13 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1266,7 +1266,6 @@ static void hugetlbfs_destroy_inode(struct inode *inode) static const struct address_space_operations hugetlbfs_aops = { .write_begin= hugetlbfs_write_begin, .write_end = hugetlbfs_write_end, - .dirty_folio