From 1c4d2a96122ca06411caf030434bc1b0178f6901 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 19 Jul 2019 17:50:46 +0200 Subject: [PATCH] UBUNTU: SAUCE: shiftfs: add O_DIRECT support BugLink: https://bugs.launchpad.net/bugs/1837223 This enabled O_DIRECT support for shiftfs if the underlay supports it. Currently shiftfs does not handle O_DIRECT if the underlay supports it. This is blocking dqlite - an essential part of LXD - from profiting from the performance benefits of O_DIRECT on suitable filesystems when used with async io such as aio or io_uring. Overlayfs cannot support this directly since the upper filesystem in overlay can be any filesystem. So if the upper filesystem does not support O_DIRECT but the lower filesystem does you're out of luck. Shiftfs does not suffer from the same problem since there is not concept of an upper filesystem in the same way that overlayfs has it. Essentially, shiftfs is a transparent shim relaying everything to the underlay while overlayfs' upper layer is not (completely). Cc: Seth Forshee Signed-off-by: Christian Brauner Signed-off-by: Seth Forshee --- fs/shiftfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/shiftfs.c b/fs/shiftfs.c index 49f6714e9f95..addaa6e21e57 100644 --- a/fs/shiftfs.c +++ b/fs/shiftfs.c @@ -1126,6 +1126,9 @@ static int shiftfs_open(struct inode *inode, struct file *file) } file->private_data = file_info; + /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO. */ + file->f_mapping = realfile->f_mapping; + file_info->realfile = realfile; return 0; } -- 2.39.5