Commit 0af57378 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

mm: require ->set_page_dirty to be explicitly wired up

Remove the CONFIG_BLOCK default to __set_page_dirty_buffers and just wire
that method up for the missing instances.

[hch@lst.de: ecryptfs: add a ->set_page_dirty cludge]
  Link: https://lkml.kernel.org/r/20210624125250.536369-1-hch@lst.de

Link: https://lkml.kernel.org/r/20210614061512.3966143-4-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Tyler Hicks <code@tyhicks.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c1e3dbe9
...@@ -73,6 +73,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block) ...@@ -73,6 +73,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
} }
static const struct address_space_operations adfs_aops = { static const struct address_space_operations adfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = adfs_readpage, .readpage = adfs_readpage,
.writepage = adfs_writepage, .writepage = adfs_writepage,
.write_begin = adfs_write_begin, .write_begin = adfs_write_begin,
......
...@@ -453,6 +453,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block) ...@@ -453,6 +453,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
} }
const struct address_space_operations affs_aops = { const struct address_space_operations affs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = affs_readpage, .readpage = affs_readpage,
.writepage = affs_writepage, .writepage = affs_writepage,
.write_begin = affs_write_begin, .write_begin = affs_write_begin,
...@@ -833,6 +834,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, ...@@ -833,6 +834,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
} }
const struct address_space_operations affs_aops_ofs = { const struct address_space_operations affs_aops_ofs = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = affs_readpage_ofs, .readpage = affs_readpage_ofs,
//.writepage = affs_writepage_ofs, //.writepage = affs_writepage_ofs,
.write_begin = affs_write_begin_ofs, .write_begin = affs_write_begin_ofs,
......
...@@ -188,6 +188,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block) ...@@ -188,6 +188,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block)
} }
const struct address_space_operations bfs_aops = { const struct address_space_operations bfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = bfs_readpage, .readpage = bfs_readpage,
.writepage = bfs_writepage, .writepage = bfs_writepage,
.write_begin = bfs_write_begin, .write_begin = bfs_write_begin,
......
...@@ -1754,6 +1754,7 @@ static int blkdev_writepages(struct address_space *mapping, ...@@ -1754,6 +1754,7 @@ static int blkdev_writepages(struct address_space *mapping,
} }
static const struct address_space_operations def_blk_aops = { static const struct address_space_operations def_blk_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = blkdev_readpage, .readpage = blkdev_readpage,
.readahead = blkdev_readahead, .readahead = blkdev_readahead,
.writepage = blkdev_writepage, .writepage = blkdev_writepage,
......
...@@ -533,7 +533,20 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block) ...@@ -533,7 +533,20 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block)
return block; return block;
} }
#include <linux/buffer_head.h>
const struct address_space_operations ecryptfs_aops = { const struct address_space_operations ecryptfs_aops = {
/*
* XXX: This is pretty broken for multiple reasons: ecryptfs does not
* actually use buffer_heads, and ecryptfs will crash without
* CONFIG_BLOCK. But it matches the behavior before the default for
* address_space_operations without the ->set_page_dirty method was
* cleaned up, so this is the best we can do without maintainer
* feedback.
*/
#ifdef CONFIG_BLOCK
.set_page_dirty = __set_page_dirty_buffers,
#endif
.writepage = ecryptfs_writepage, .writepage = ecryptfs_writepage,
.readpage = ecryptfs_readpage, .readpage = ecryptfs_readpage,
.write_begin = ecryptfs_write_begin, .write_begin = ecryptfs_write_begin,
......
...@@ -491,6 +491,7 @@ int exfat_block_truncate_page(struct inode *inode, loff_t from) ...@@ -491,6 +491,7 @@ int exfat_block_truncate_page(struct inode *inode, loff_t from)
} }
static const struct address_space_operations exfat_aops = { static const struct address_space_operations exfat_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = exfat_readpage, .readpage = exfat_readpage,
.readahead = exfat_readahead, .readahead = exfat_readahead,
.writepage = exfat_writepage, .writepage = exfat_writepage,
......
...@@ -961,6 +961,7 @@ ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc ...@@ -961,6 +961,7 @@ ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc
} }
const struct address_space_operations ext2_aops = { const struct address_space_operations ext2_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = ext2_readpage, .readpage = ext2_readpage,
.readahead = ext2_readahead, .readahead = ext2_readahead,
.writepage = ext2_writepage, .writepage = ext2_writepage,
...@@ -975,6 +976,7 @@ const struct address_space_operations ext2_aops = { ...@@ -975,6 +976,7 @@ const struct address_space_operations ext2_aops = {
}; };
const struct address_space_operations ext2_nobh_aops = { const struct address_space_operations ext2_nobh_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = ext2_readpage, .readpage = ext2_readpage,
.readahead = ext2_readahead, .readahead = ext2_readahead,
.writepage = ext2_nobh_writepage, .writepage = ext2_nobh_writepage,
......
...@@ -342,6 +342,7 @@ int fat_block_truncate_page(struct inode *inode, loff_t from) ...@@ -342,6 +342,7 @@ int fat_block_truncate_page(struct inode *inode, loff_t from)
} }
static const struct address_space_operations fat_aops = { static const struct address_space_operations fat_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = fat_readpage, .readpage = fat_readpage,
.readahead = fat_readahead, .readahead = fat_readahead,
.writepage = fat_writepage, .writepage = fat_writepage,
......
...@@ -89,11 +89,13 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb ...@@ -89,11 +89,13 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
} }
const struct address_space_operations gfs2_meta_aops = { const struct address_space_operations gfs2_meta_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.writepage = gfs2_aspace_writepage, .writepage = gfs2_aspace_writepage,
.releasepage = gfs2_releasepage, .releasepage = gfs2_releasepage,
}; };
const struct address_space_operations gfs2_rgrp_aops = { const struct address_space_operations gfs2_rgrp_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.writepage = gfs2_aspace_writepage, .writepage = gfs2_aspace_writepage,
.releasepage = gfs2_releasepage, .releasepage = gfs2_releasepage,
}; };
......
...@@ -159,6 +159,7 @@ static int hfs_writepages(struct address_space *mapping, ...@@ -159,6 +159,7 @@ static int hfs_writepages(struct address_space *mapping,
} }
const struct address_space_operations hfs_btree_aops = { const struct address_space_operations hfs_btree_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = hfs_readpage, .readpage = hfs_readpage,
.writepage = hfs_writepage, .writepage = hfs_writepage,
.write_begin = hfs_write_begin, .write_begin = hfs_write_begin,
...@@ -168,6 +169,7 @@ const struct address_space_operations hfs_btree_aops = { ...@@ -168,6 +169,7 @@ const struct address_space_operations hfs_btree_aops = {
}; };
const struct address_space_operations hfs_aops = { const struct address_space_operations hfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = hfs_readpage, .readpage = hfs_readpage,
.writepage = hfs_writepage, .writepage = hfs_writepage,
.write_begin = hfs_write_begin, .write_begin = hfs_write_begin,
......
...@@ -156,6 +156,7 @@ static int hfsplus_writepages(struct address_space *mapping, ...@@ -156,6 +156,7 @@ static int hfsplus_writepages(struct address_space *mapping,
} }
const struct address_space_operations hfsplus_btree_aops = { const struct address_space_operations hfsplus_btree_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = hfsplus_readpage, .readpage = hfsplus_readpage,
.writepage = hfsplus_writepage, .writepage = hfsplus_writepage,
.write_begin = hfsplus_write_begin, .write_begin = hfsplus_write_begin,
...@@ -165,6 +166,7 @@ const struct address_space_operations hfsplus_btree_aops = { ...@@ -165,6 +166,7 @@ const struct address_space_operations hfsplus_btree_aops = {
}; };
const struct address_space_operations hfsplus_aops = { const struct address_space_operations hfsplus_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = hfsplus_readpage, .readpage = hfsplus_readpage,
.writepage = hfsplus_writepage, .writepage = hfsplus_writepage,
.write_begin = hfsplus_write_begin, .write_begin = hfsplus_write_begin,
......
...@@ -196,6 +196,7 @@ static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ...@@ -196,6 +196,7 @@ static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
} }
const struct address_space_operations hpfs_aops = { const struct address_space_operations hpfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = hpfs_readpage, .readpage = hpfs_readpage,
.writepage = hpfs_writepage, .writepage = hpfs_writepage,
.readahead = hpfs_readahead, .readahead = hpfs_readahead,
......
...@@ -356,6 +356,7 @@ static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -356,6 +356,7 @@ static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
} }
const struct address_space_operations jfs_aops = { const struct address_space_operations jfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = jfs_readpage, .readpage = jfs_readpage,
.readahead = jfs_readahead, .readahead = jfs_readahead,
.writepage = jfs_writepage, .writepage = jfs_writepage,
......
...@@ -442,6 +442,7 @@ static sector_t minix_bmap(struct address_space *mapping, sector_t block) ...@@ -442,6 +442,7 @@ static sector_t minix_bmap(struct address_space *mapping, sector_t block)
} }
static const struct address_space_operations minix_aops = { static const struct address_space_operations minix_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = minix_readpage, .readpage = minix_readpage,
.writepage = minix_writepage, .writepage = minix_writepage,
.write_begin = minix_write_begin, .write_begin = minix_write_begin,
......
...@@ -434,6 +434,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc) ...@@ -434,6 +434,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
static const struct address_space_operations def_mdt_aops = { static const struct address_space_operations def_mdt_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.writepage = nilfs_mdt_write_page, .writepage = nilfs_mdt_write_page,
}; };
......
...@@ -2453,6 +2453,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) ...@@ -2453,6 +2453,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
} }
const struct address_space_operations ocfs2_aops = { const struct address_space_operations ocfs2_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = ocfs2_readpage, .readpage = ocfs2_readpage,
.readahead = ocfs2_readahead, .readahead = ocfs2_readahead,
.writepage = ocfs2_writepage, .writepage = ocfs2_writepage,
......
...@@ -372,6 +372,7 @@ const struct inode_operations omfs_file_inops = { ...@@ -372,6 +372,7 @@ const struct inode_operations omfs_file_inops = {
}; };
const struct address_space_operations omfs_aops = { const struct address_space_operations omfs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = omfs_readpage, .readpage = omfs_readpage,
.readahead = omfs_readahead, .readahead = omfs_readahead,
.writepage = omfs_writepage, .writepage = omfs_writepage,
......
...@@ -495,6 +495,7 @@ static sector_t sysv_bmap(struct address_space *mapping, sector_t block) ...@@ -495,6 +495,7 @@ static sector_t sysv_bmap(struct address_space *mapping, sector_t block)
} }
const struct address_space_operations sysv_aops = { const struct address_space_operations sysv_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = sysv_readpage, .readpage = sysv_readpage,
.writepage = sysv_writepage, .writepage = sysv_writepage,
.write_begin = sysv_write_begin, .write_begin = sysv_write_begin,
......
...@@ -125,6 +125,7 @@ static int udf_adinicb_write_end(struct file *file, struct address_space *mappin ...@@ -125,6 +125,7 @@ static int udf_adinicb_write_end(struct file *file, struct address_space *mappin
} }
const struct address_space_operations udf_adinicb_aops = { const struct address_space_operations udf_adinicb_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = udf_adinicb_readpage, .readpage = udf_adinicb_readpage,
.writepage = udf_adinicb_writepage, .writepage = udf_adinicb_writepage,
.write_begin = udf_adinicb_write_begin, .write_begin = udf_adinicb_write_begin,
......
...@@ -235,6 +235,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block) ...@@ -235,6 +235,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
} }
const struct address_space_operations udf_aops = { const struct address_space_operations udf_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = udf_readpage, .readpage = udf_readpage,
.readahead = udf_readahead, .readahead = udf_readahead,
.writepage = udf_writepage, .writepage = udf_writepage,
......
...@@ -526,6 +526,7 @@ static sector_t ufs_bmap(struct address_space *mapping, sector_t block) ...@@ -526,6 +526,7 @@ static sector_t ufs_bmap(struct address_space *mapping, sector_t block)
} }
const struct address_space_operations ufs_aops = { const struct address_space_operations ufs_aops = {
.set_page_dirty = __set_page_dirty_buffers,
.readpage = ufs_readpage, .readpage = ufs_readpage,
.writepage = ufs_writepage, .writepage = ufs_writepage,
.write_begin = ufs_write_begin, .write_begin = ufs_write_begin,
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/buffer_head.h> /* __set_page_dirty_buffers */
#include <linux/pagevec.h> #include <linux/pagevec.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/sched/rt.h> #include <linux/sched/rt.h>
...@@ -2555,13 +2554,9 @@ EXPORT_SYMBOL(redirty_page_for_writepage); ...@@ -2555,13 +2554,9 @@ EXPORT_SYMBOL(redirty_page_for_writepage);
/* /*
* Dirty a page. * Dirty a page.
* *
* For pages with a mapping this should be done under the page lock * For pages with a mapping this should be done under the page lock for the
* for the benefit of asynchronous memory errors who prefer a consistent * benefit of asynchronous memory errors who prefer a consistent dirty state.
* dirty state. This rule can be broken in some special cases, * This rule can be broken in some special cases, but should be better not to.
* but should be better not to.
*
* If the mapping doesn't provide a set_page_dirty a_op, then
* just fall through and assume that it wants buffer_heads.
*/ */
int set_page_dirty(struct page *page) int set_page_dirty(struct page *page)
{ {
...@@ -2569,7 +2564,6 @@ int set_page_dirty(struct page *page) ...@@ -2569,7 +2564,6 @@ int set_page_dirty(struct page *page)
page = compound_head(page); page = compound_head(page);
if (likely(mapping)) { if (likely(mapping)) {
int (*spd)(struct page *) = mapping->a_ops->set_page_dirty;
/* /*
* readahead/lru_deactivate_page could remain * readahead/lru_deactivate_page could remain
* PG_readahead/PG_reclaim due to race with end_page_writeback * PG_readahead/PG_reclaim due to race with end_page_writeback
...@@ -2582,11 +2576,7 @@ int set_page_dirty(struct page *page) ...@@ -2582,11 +2576,7 @@ int set_page_dirty(struct page *page)
*/ */
if (PageReclaim(page)) if (PageReclaim(page))
ClearPageReclaim(page); ClearPageReclaim(page);
#ifdef CONFIG_BLOCK return mapping->a_ops->set_page_dirty(page);
if (!spd)
spd = __set_page_dirty_buffers;
#endif
return (*spd)(page);
} }
if (!PageDirty(page)) { if (!PageDirty(page)) {
if (!TestSetPageDirty(page)) if (!TestSetPageDirty(page))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment