From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: linux-unionfs@vger.kernel.org, amir73il@gmail.com
Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>, miklos@szeredi.hu
Subject: [PATCH 3/3] ovl: Relax same fs constraint for constant d_ino
Date: Fri, 6 Oct 2017 14:55:35 +0530 [thread overview]
Message-ID: <20171006092535.15199-3-chandan@linux.vnet.ibm.com> (raw)
In-Reply-To: <20171006092535.15199-1-chandan@linux.vnet.ibm.com>
For a pure upper dir in a non-samefs setup, ovl_getattr() returns the
overlay inode number as the value of st_ino. To keep in line with this
behaviour, ovl_fill_real() has been modified to return overlay inode
number of the "." entry as the d_ino of a pure upper dir.
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
fs/overlayfs/readdir.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 02f48cb..21e82ff 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -428,7 +428,6 @@ static struct ovl_dir_cache *ovl_cache_get(struct dentry *dentry)
* sure that d_ino will be consistent with st_ino from stat(2).
*/
static int ovl_cache_update_ino(struct path *path, struct ovl_cache_entry *p)
-
{
struct dentry *dir = path->dentry;
struct dentry *this = NULL;
@@ -436,9 +435,6 @@ static int ovl_cache_update_ino(struct path *path, struct ovl_cache_entry *p)
u64 ino = p->real_ino;
int err = 0;
- if (!ovl_same_sb(dir->d_sb))
- goto out;
-
if (p->name[0] == '.') {
if (p->len == 1) {
this = dget(dir);
@@ -470,8 +466,8 @@ static int ovl_cache_update_ino(struct path *path, struct ovl_cache_entry *p)
err = vfs_getattr(&statpath, &stat, STATX_INO, 0);
if (err)
goto fail;
-
- WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev);
+ if (d_is_dir(this) || ovl_same_sb(this->d_sb))
+ WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev);
ino = stat.ino;
}
@@ -593,6 +589,7 @@ struct ovl_readdir_translate {
struct ovl_dir_cache *cache;
struct dir_context ctx;
u64 parent_ino;
+ u64 current_ino;
};
static int ovl_fill_real(struct dir_context *ctx, const char *name,
@@ -605,6 +602,8 @@ static int ovl_fill_real(struct dir_context *ctx, const char *name,
if (rdt->parent_ino && strcmp(name, "..") == 0)
ino = rdt->parent_ino;
+ else if (rdt->current_ino && namelen == 1 && name[0] == '.')
+ ino = rdt->current_ino;
else if (rdt->cache) {
struct ovl_cache_entry *p;
@@ -645,6 +644,9 @@ static int ovl_iterate_real(struct file *file, struct dir_context *ctx)
return PTR_ERR(rdt.cache);
}
+ if (!ovl_same_sb(dir->d_sb))
+ rdt.current_ino = dir->d_inode->i_ino;
+
return iterate_dir(od->realfile, &rdt.ctx);
}
@@ -665,9 +667,9 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
* dir is impure then need to adjust d_ino for copied up
* entries.
*/
- if (ovl_same_sb(dentry->d_sb) &&
- (ovl_test_flag(OVL_IMPURE, d_inode(dentry)) ||
- OVL_TYPE_MERGE(ovl_path_type(dentry->d_parent)))) {
+ if (ovl_test_flag(OVL_IMPURE, d_inode(dentry)) ||
+ OVL_TYPE_MERGE(ovl_path_type(dentry->d_parent)) ||
+ !ovl_same_sb(dentry->d_sb)) {
return ovl_iterate_real(file, ctx);
}
return iterate_dir(od->realfile, ctx);
--
2.9.5
prev parent reply other threads:[~2017-10-06 9:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 9:25 [PATCH 1/3] ovl: Allocate anonymous devs for lowerdirs Chandan Rajendra
2017-10-06 9:25 ` [PATCH 2/3] ovl: relax same fs constrain for constant st_ino Chandan Rajendra
2017-10-06 9:25 ` Chandan Rajendra [this message]
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=20171006092535.15199-3-chandan@linux.vnet.ibm.com \
--to=chandan@linux.vnet.ibm.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).