mm: require ->set_page_dirty to be explicitly wired up
authorChristoph Hellwig <hch@lst.de>
Tue, 29 Jun 2021 02:36:12 +0000 (19:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Jun 2021 17:53:48 +0000 (10:53 -0700)
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.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Jan 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
22 files changed:
fs/adfs/inode.c
fs/affs/file.c
fs/bfs/file.c
fs/block_dev.c
fs/ecryptfs/mmap.c
fs/exfat/inode.c
fs/ext2/inode.c
fs/fat/inode.c
fs/gfs2/meta_io.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/hpfs/file.c
fs/jfs/inode.c
fs/minix/inode.c
fs/nilfs2/mdt.c
fs/ocfs2/aops.c
fs/omfs/file.c
fs/sysv/itree.c
fs/udf/file.c
fs/udf/inode.c
fs/ufs/inode.c
mm/page-writeback.c

index fb7ee026d1016bc230370bf8122c8c552b48bda2..adbb3a1edcbf562269e896d38639f52ae14d2918 100644 (file)
@@ -73,6 +73,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
 }
 
 static const struct address_space_operations adfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = adfs_readpage,
        .writepage      = adfs_writepage,
        .write_begin    = adfs_write_begin,
index d91b0133d95da5e225e01f3a6e9ef76b89c575d0..75ebd2b576ca4b9cf33e4d978c8cac3bba066bb5 100644 (file)
@@ -453,6 +453,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations affs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = affs_readpage,
        .writepage = affs_writepage,
        .write_begin = affs_write_begin,
@@ -833,6 +834,7 @@ err_bh:
 }
 
 const struct address_space_operations affs_aops_ofs = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = affs_readpage_ofs,
        //.writepage = affs_writepage_ofs,
        .write_begin = affs_write_begin_ofs,
index 0dceefc54b48abd99bfb766355ddf3e5666643ce..7f8544abf636f4ba58fc4cab24d1bd2c221fd262 100644 (file)
@@ -188,6 +188,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations bfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = bfs_readpage,
        .writepage      = bfs_writepage,
        .write_begin    = bfs_write_begin,
index 6cc4d4cfe0c286dd3268969e834b59e2e9a284d7..eb34f5c357cfe97c2fce9c37e4eec056c1cb46a3 100644 (file)
@@ -1754,6 +1754,7 @@ static int blkdev_writepages(struct address_space *mapping,
 }
 
 static const struct address_space_operations def_blk_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = blkdev_readpage,
        .readahead      = blkdev_readahead,
        .writepage      = blkdev_writepage,
index 392e721b50a3d6c254f83f0ff85246fd8635dadd..7d85e64ea62f3880311cd32b81ca96b596b89f5a 100644 (file)
@@ -533,7 +533,20 @@ static sector_t ecryptfs_bmap(struct address_space *mapping, sector_t block)
        return block;
 }
 
+#include <linux/buffer_head.h>
+
 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,
        .readpage = ecryptfs_readpage,
        .write_begin = ecryptfs_write_begin,
index 1803ef3220fdbd6ca51470b736ca3ab596588fc3..ca37d43443612c61200b07b69e40993ea0eff8d2 100644 (file)
@@ -491,6 +491,7 @@ int exfat_block_truncate_page(struct inode *inode, loff_t from)
 }
 
 static const struct address_space_operations exfat_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = exfat_readpage,
        .readahead      = exfat_readahead,
        .writepage      = exfat_writepage,
index 68178b2234bded60d05fe6ca62f86d2c9a4f9c52..bf41f579ed3ed6b1283f5bb2b3b3d7230a0d68ad 100644 (file)
@@ -961,6 +961,7 @@ ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc
 }
 
 const struct address_space_operations ext2_aops = {
+       .set_page_dirty         = __set_page_dirty_buffers,
        .readpage               = ext2_readpage,
        .readahead              = ext2_readahead,
        .writepage              = ext2_writepage,
@@ -975,6 +976,7 @@ const struct address_space_operations ext2_aops = {
 };
 
 const struct address_space_operations ext2_nobh_aops = {
+       .set_page_dirty         = __set_page_dirty_buffers,
        .readpage               = ext2_readpage,
        .readahead              = ext2_readahead,
        .writepage              = ext2_nobh_writepage,
index bab9b202b496686b5f97447609db4b32f23cf900..de0c9b013a8512098dbf73f5463b882cb45327f6 100644 (file)
@@ -342,6 +342,7 @@ int fat_block_truncate_page(struct inode *inode, loff_t from)
 }
 
 static const struct address_space_operations fat_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = fat_readpage,
        .readahead      = fat_readahead,
        .writepage      = fat_writepage,
index d68184ebbfdd3ec1184706c443d1405fce3a16a9..7c96199973552bc93a09872a360e6ff01f92ec54 100644 (file)
@@ -89,11 +89,13 @@ static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wb
 }
 
 const struct address_space_operations gfs2_meta_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .writepage = gfs2_aspace_writepage,
        .releasepage = gfs2_releasepage,
 };
 
 const struct address_space_operations gfs2_rgrp_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .writepage = gfs2_aspace_writepage,
        .releasepage = gfs2_releasepage,
 };
index 3fc5cb34658641f2e6266c37a89500051e351d79..4a95a92546a0da7eda87d646d53226a8fba0bc3a 100644 (file)
@@ -159,6 +159,7 @@ static int hfs_writepages(struct address_space *mapping,
 }
 
 const struct address_space_operations hfs_btree_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = hfs_readpage,
        .writepage      = hfs_writepage,
        .write_begin    = hfs_write_begin,
@@ -168,6 +169,7 @@ const struct address_space_operations hfs_btree_aops = {
 };
 
 const struct address_space_operations hfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = hfs_readpage,
        .writepage      = hfs_writepage,
        .write_begin    = hfs_write_begin,
index 8ea447e5c4708a3d4dbf1b55e6b484b437a00c6e..70e8374ddac4029819449e4d2b5e145eab258feb 100644 (file)
@@ -156,6 +156,7 @@ static int hfsplus_writepages(struct address_space *mapping,
 }
 
 const struct address_space_operations hfsplus_btree_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = hfsplus_readpage,
        .writepage      = hfsplus_writepage,
        .write_begin    = hfsplus_write_begin,
@@ -165,6 +166,7 @@ const struct address_space_operations hfsplus_btree_aops = {
 };
 
 const struct address_space_operations hfsplus_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = hfsplus_readpage,
        .writepage      = hfsplus_writepage,
        .write_begin    = hfsplus_write_begin,
index 077c25128eb7417adaedfba9cdfdce4522d43c30..c3a49aacf20affc935b4e24fdaa188f2f1df5793 100644 (file)
@@ -196,6 +196,7 @@ static int hpfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 }
 
 const struct address_space_operations hpfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = hpfs_readpage,
        .writepage = hpfs_writepage,
        .readahead = hpfs_readahead,
index 6f65bfa9f18d5b629b82c3efc349107e6d2dbecf..3663dd5a23bc832cdce8af6538dafe69d6e4c5e8 100644 (file)
@@ -356,6 +356,7 @@ static ssize_t jfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 }
 
 const struct address_space_operations jfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = jfs_readpage,
        .readahead      = jfs_readahead,
        .writepage      = jfs_writepage,
index a532a99bbe8184f1aee2e33b0fae6c78daf94a9e..a71f1cf894b9f1218f8c739dda034f100ed20c99 100644 (file)
@@ -442,6 +442,7 @@ static sector_t minix_bmap(struct address_space *mapping, sector_t block)
 }
 
 static const struct address_space_operations minix_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = minix_readpage,
        .writepage = minix_writepage,
        .write_begin = minix_write_begin,
index c0361ce45f62d524ae865a17987ab5ff3c87fe9f..97769fe4d5885a9ed3fe54829261c5ca30007e2c 100644 (file)
@@ -434,6 +434,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
 
 
 static const struct address_space_operations def_mdt_aops = {
+       .set_page_dirty         = __set_page_dirty_buffers,
        .writepage              = nilfs_mdt_write_page,
 };
 
index e1c6fa5bd0e73afd45447883f2bf79d7b7509c55..68d11c295dd345aa7307fd77301df44dd4b76797 100644 (file)
@@ -2453,6 +2453,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 }
 
 const struct address_space_operations ocfs2_aops = {
+       .set_page_dirty         = __set_page_dirty_buffers,
        .readpage               = ocfs2_readpage,
        .readahead              = ocfs2_readahead,
        .writepage              = ocfs2_writepage,
index 11e733aab25d486478c5bf39bacdcc1bb97dbede..89725b15a64b4c709238d8078430ccaf944ae6d4 100644 (file)
@@ -372,6 +372,7 @@ const struct inode_operations omfs_file_inops = {
 };
 
 const struct address_space_operations omfs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = omfs_readpage,
        .readahead = omfs_readahead,
        .writepage = omfs_writepage,
index 8b2e99b7bc9fa4afe911dc478ac4d6cbce038fec..749385015a8d3f1e8d1d8b47010330f7e7b009c0 100644 (file)
@@ -495,6 +495,7 @@ static sector_t sysv_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations sysv_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = sysv_readpage,
        .writepage = sysv_writepage,
        .write_begin = sysv_write_begin,
index 2846dcd921977e47c7fbd23023da439b645664d2..1baff8ddb754497ef41757d2fa75d9385137e34a 100644 (file)
@@ -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 = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = udf_adinicb_readpage,
        .writepage      = udf_adinicb_writepage,
        .write_begin    = udf_adinicb_write_begin,
index 0dd2f93ac0480e55cab212dce3506e8c89427765..4917670860a0103193915868dee9a353946e631c 100644 (file)
@@ -235,6 +235,7 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations udf_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage       = udf_readpage,
        .readahead      = udf_readahead,
        .writepage      = udf_writepage,
index debc282c1bb47d3e28a83202c98d67aac062e6a8..ac628de69601d932b0e4211646cad01fdc47cd9a 100644 (file)
@@ -526,6 +526,7 @@ static sector_t ufs_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations ufs_aops = {
+       .set_page_dirty = __set_page_dirty_buffers,
        .readpage = ufs_readpage,
        .writepage = ufs_writepage,
        .write_begin = ufs_write_begin,
index c2a849d653a9bd7c2bb2da94bbd8aa1fc4054ebc..21f4b5972311de25318aaf9abc509dfdf2ac79d7 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/sysctl.h>
 #include <linux/cpu.h>
 #include <linux/syscalls.h>
-#include <linux/buffer_head.h> /* __set_page_dirty_buffers */
 #include <linux/pagevec.h>
 #include <linux/timer.h>
 #include <linux/sched/rt.h>
@@ -2555,13 +2554,9 @@ EXPORT_SYMBOL(redirty_page_for_writepage);
 /*
  * Dirty a page.
  *
- * For pages with a mapping this should be done under the page lock
- * for the benefit of asynchronous memory errors who prefer a consistent
- * dirty state. This rule can be broken in some special cases,
- * 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.
+ * For pages with a mapping this should be done under the page lock for the
+ * benefit of asynchronous memory errors who prefer a consistent dirty state.
+ * This rule can be broken in some special cases, but should be better not to.
  */
 int set_page_dirty(struct page *page)
 {
@@ -2569,7 +2564,6 @@ int set_page_dirty(struct page *page)
 
        page = compound_head(page);
        if (likely(mapping)) {
-               int (*spd)(struct page *) = mapping->a_ops->set_page_dirty;
                /*
                 * readahead/lru_deactivate_page could remain
                 * PG_readahead/PG_reclaim due to race with end_page_writeback
@@ -2582,11 +2576,7 @@ int set_page_dirty(struct page *page)
                 */
                if (PageReclaim(page))
                        ClearPageReclaim(page);
-#ifdef CONFIG_BLOCK
-               if (!spd)
-                       spd = __set_page_dirty_buffers;
-#endif
-               return (*spd)(page);
+               return mapping->a_ops->set_page_dirty(page);
        }
        if (!PageDirty(page)) {
                if (!TestSetPageDirty(page))