From: Quentin Casasnovas <quentin.casasnovas@oracle.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org,
Quentin Casasnovas <quentin.casasnovas@oracle.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] ovl: tentative fix for broken vfs_open() on stacked overlayfs.
Date: Fri, 25 Nov 2016 18:09:23 +0100 [thread overview]
Message-ID: <20161125170923.21674-1-quentin.casasnovas@oracle.com> (raw)
In-Reply-To: <20161125145604.GG6842@chrystal.oracle.com>
If two overlayfs filesystems are stacked on top of each other, then we need
to recurse when opening a file. This used to work and was first broken by:
4bacc9c9234c ("overlayfs: Make f_path always point to the overlay...")
and fixed by:
1c8a47df36d7 ("ovl: fix open in stacked overlay")
But it looks like it was re-introduced in:
2d902671ce1c ("vfs: merge .d_select_inode() into .d_real()")
I know close to nothing about VFS/overlayfs so this might be completely
wrong for many reasons but it fixes the following test case for me:
#!/bin/bash -xeu
tmpdir=$(mktemp -d)
pushd ${tmpdir}
mkdir -p {upper,lower,work}
echo -n 'rocks' > lower/ksplice
mount -t overlay level_zero upper -o lowerdir=lower,upperdir=upper,workdir=work
cat upper/ksplice
tmpdir2=$(mktemp -d)
pushd ${tmpdir2}
mkdir -p {upper,work}
mount -t overlay level_one upper -o lowerdir=${tmpdir}/upper,upperdir=upper,workdir=work
ls -l upper/ksplice
cat upper/ksplice
For sanity checking, I've run the test-suite mentionned in
Documentation/filesystems/overlayfs.txt:
git://git.infradead.org/users/dhowells/unionmount-testsuite.git
Though with and without this patch it returned zero so I am assuming it
does not contain any tests with stacked overlayfs.
Fixes: 2d902671ce1c ("vfs: merge .d_select_inode() into .d_real()")
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
---
fs/overlayfs/super.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index edd46a0e951d..ae0b36474a9a 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -321,16 +321,22 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
}
real = ovl_dentry_upper(dentry);
- if (real && (!inode || inode == d_inode(real)))
- return real;
+ if (real && inode && inode == d_inode(real))
+ return real;
+
+ if (real && !inode && d_inode(real))
+ return d_real(real, d_inode(real), open_flags);
real = ovl_dentry_lower(dentry);
if (!real)
goto bug;
- if (!inode || inode == d_inode(real))
+ if (inode && inode == d_inode(real))
return real;
+ if (!inode && d_inode(real))
+ return d_real(real, d_inode(real), open_flags);
+
/* Handle recursion */
return d_real(real, inode, open_flags);
bug:
--
2.11.0.rc2
next prev parent reply other threads:[~2016-11-25 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-25 14:56 opening a file on a stacked overlayfs is broken Quentin Casasnovas
2016-11-25 17:09 ` Quentin Casasnovas [this message]
2016-11-25 19:28 ` [PATCH] ovl: tentative fix for broken vfs_open() on stacked overlayfs Quentin Casasnovas
2016-11-28 9:45 ` Miklos Szeredi
2016-11-28 11:06 ` Quentin Casasnovas
2016-11-29 9:32 Miklos Szeredi
2016-11-29 10:03 ` Amir Goldstein
2016-12-01 16:20 ` Quentin Casasnovas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161125170923.21674-1-quentin.casasnovas@oracle.com \
--to=quentin.casasnovas@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).