On Thu, May 15, 2014 at 12:04 PM, Erez Zadok <[email protected]> wrote:
> Any pointers on where/how it should be supported in a stackable f/s
> would be appreciated.  I’ll probably start by testing it in wrapfs
> first.

I think supporting address_space_operations->direct_IO should be
enough. This attached patch passes xfstests generic/247 which uses
O_DIRECT.

diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index 52c7945..1c28458 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -18,6 +18,7 @@
  */

 #include "union.h"
+#include "linux/aio.h"


 /*
@@ -85,12 +86,39 @@ static int unionfs_page_mkwrite(struct
vm_area_struct *vma, struct vm_fault *vmf
        return err;
 }

+static ssize_t
+unionfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
+                       loff_t offset, unsigned long nr_segs)
+{
+       int err = 0;
+       struct file *lower_file;
+       struct file *file = iocb->ki_filp;
+       struct inode *lower_inode;
+
+       lower_file = unionfs_lower_file(file);
+       lower_inode = file_inode(lower_file);
+       if (!lower_inode->i_mapping->a_ops ||
+                       lower_inode->i_mapping->a_ops->direct_IO) {
+               printk("Underlying file doesn't support direct_IO\n");
+               err = -EINVAL;
+               goto out;
+       }
+
+       iocb->ki_filp = lower_file;
+       err = lower_inode->i_mapping->a_ops->direct_IO(rw, iocb, iov,
+                                                       offset, nr_segs);
+       printk("direct_IO returned: %d", err);
+out:
+       return err;
+}
+
 /*
  * XXX: the default address_space_ops for unionfs is empty.  We cannot set
  * our inode->i_mapping->a_ops to NULL because too many code paths expect
  * the a_ops vector to be non-NULL.
  */
 struct address_space_operations unionfs_aops = {
+       .direct_IO              = unionfs_direct_IO,
        /* empty on purpose */
 };



Vaibhav
_______________________________________________
unionfs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs

Reply via email to