Unionfs: support lower filesystems without writeback capability
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 16 Oct 2007 14:50:16 +0000 (10:50 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 29 Apr 2011 02:25:05 +0000 (22:25 -0400)
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 <penberg@cs.helsinki.fi>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/mmap.c
fs/unionfs/union.h

index 644028279fae73289ccb32210024763dc14a1115..b43557ee00c2f0bd87395ff7baf9839cd64c41fc 100644 (file)
@@ -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,
index 22a4b917947bb1d12b7a1443b0304ab35ffb3299..36dddd4a7e6e69f489cb667bea54b50956f91984 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/log2.h>
 #include <linux/poison.h>
 #include <linux/mman.h>
+#include <linux/backing-dev.h>
 
 #include <asm/system.h>