diff mbox series

[v2,1/5] fs: add bdev writepage hook to block device

Message ID 20200617115947.836221-2-yi.zhang@huawei.com (mailing list archive)
State New, archived
Headers show
Series ext4: fix inconsistency since reading old metadata from disk | expand

Commit Message

Zhang Yi June 17, 2020, 11:59 a.m. UTC
Add a new bdev_write_page hook into struct super_operations and called
by bdev_writepage(), which could be used by filesystem to propagate
private handlers.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
---
 fs/block_dev.c     | 5 +++++
 include/linux/fs.h | 1 +
 2 files changed, 6 insertions(+)

Comments

Christoph Hellwig June 18, 2020, 7:02 a.m. UTC | #1
On Wed, Jun 17, 2020 at 07:59:43PM +0800, zhangyi (F) wrote:
> Add a new bdev_write_page hook into struct super_operations and called
> by bdev_writepage(), which could be used by filesystem to propagate
> private handlers.

Sorry. but no.  We've been trying to get the fs decoupled from the whole
buffer_head crap for quite a while, and this just makes it much worse.
Please don't add layering violations like this.
diff mbox series

Patch

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 47860e589388..46e25a4e3ebf 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -606,6 +606,11 @@  EXPORT_SYMBOL(thaw_bdev);
 
 static int blkdev_writepage(struct page *page, struct writeback_control *wbc)
 {
+	struct super_block *super = BDEV_I(page->mapping->host)->bdev.bd_super;
+
+	if (super && super->s_op->bdev_write_page)
+		return super->s_op->bdev_write_page(page, blkdev_get_block, wbc);
+
 	return block_write_full_page(page, blkdev_get_block, wbc);
 }
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cffc3619eed5..b87b784c6bc6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1983,6 +1983,7 @@  struct super_operations {
 	struct dquot **(*get_dquots)(struct inode *);
 #endif
 	int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
+	int (*bdev_write_page)(struct page *, get_block_t *, struct writeback_control *);
 	long (*nr_cached_objects)(struct super_block *,
 				  struct shrink_control *);
 	long (*free_cached_objects)(struct super_block *,