From ee7780de75566bf49b6fe7bf41bfe1de7e8c3536 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Tue, 16 Oct 2007 10:50:16 -0400 Subject: [PATCH] Unionfs: support lower filesystems without writeback capability Implement unionfs_writepages. As per mm/filemap.c:__filemap_fdatawrite_range(), don't call our writepage if the lower mapping has BDI_CAP_NO_WRITEBACK capability set. Signed-off-by: Pekka J Enberg Signed-off-by: Erez Zadok --- fs/unionfs/mmap.c | 23 +++++++++++++++++++++++ fs/unionfs/union.h | 1 + 2 files changed, 24 insertions(+) diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c index 644028279fa..b43557ee00c 100644 --- a/fs/unionfs/mmap.c +++ b/fs/unionfs/mmap.c @@ -144,6 +144,28 @@ out: return err; } +static int unionfs_writepages(struct address_space *mapping, + struct writeback_control *wbc) +{ + int err = 0; + struct inode *lower_inode; + struct inode *inode; + + inode = mapping->host; + lower_inode = unionfs_lower_inode(inode); + BUG_ON(!lower_inode); + + if (!mapping_cap_writeback_dirty(lower_inode->i_mapping)) + goto out; + + /* Note: generic_writepages may return AOP_WRITEPAGE_ACTIVATE */ + err = generic_writepages(mapping, wbc); + if (err == 0) + unionfs_copy_attr_times(inode); +out: + return err; +} + /* * readpage is called from generic_page_read and the fault handler. * If your file system uses generic_page_read for the read op, it @@ -374,6 +396,7 @@ out: struct address_space_operations unionfs_aops = { .writepage = unionfs_writepage, + .writepages = unionfs_writepages, .readpage = unionfs_readpage, .prepare_write = unionfs_prepare_write, .commit_write = unionfs_commit_write, diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 22a4b917947..36dddd4a7e6 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -45,6 +45,7 @@ #include #include #include +#include #include -- 2.43.0