[PATCH] ovl: Add d_select_inode op to ovl_reval_dentry_operations

Nikolay Borisov
2016-02-08T14:52:10Z

Commit daee0af5b522 ("overlayfs: Make f_path always point to the
overlay and f_inode to the underlay") changed the way overlayed dentries
are opened and introduced ovl_d_select_inode so that in cases when an overlayed
file is opened its f_ops are being fetched from the underlying
(in the case of writes the upper directory) layer.

However, by not adding this operation to the ovl_reval_dentry_operations
this essentially disables writes to the upper layer in setups which
use a remote (as per the check in ovl_dentry_remote) lower layers, since
in this case ovl_reval_dentry_operations is going to be used when
dentries are created. This results in code in vfs_open never calling
d_select_inode to get the upper layer inode, which leads to do_dentry_open
using the overlay inode which has empty_fops.

This patch fixes this by adding d_select_inode operation to
ovl_reval_dentry_operations, which allows querying the correct inode
when writing to an overlayed location, using a remote lower dir.

Fixes: daee0af5b522 ("overlayfs: Make f_path always point to the
overlay and f_inode to the underlay")

Signed-off-by: Nikolay Borisov <kernel@kyup.com>
---

This took me quite a while to catch, and so far it survives local
testing. I'm mostly interested in knowing whether it (silently)
breaks stuff.

fs/overlayfs/super.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index e38ee0fed24a..787e075709fa 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -321,6 +321,7 @@ static const struct dentry_operations ovl_dentry_operations = {

static const struct dentry_operations ovl_reval_dentry_operations = {
.d_release = ovl_dentry_release,
+ .d_select_inode = ovl_d_select_inode,
.d_revalidate = ovl_dentry_revalidate,
.d_weak_revalidate = ovl_dentry_weak_revalidate,
};
--
2.5.0