From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [RFC][PATCH 1/2] ovl: store path type in dentry
Date: Tue, 21 Mar 2017 12:16:44 -0400 [thread overview]
Message-ID: <1490113005-28787-2-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1490113005-28787-1-git-send-email-amir73il@gmail.com>
ovl_path_type() is called quite often (e.g.: on every file open)
to calculate the path type flags of overlay dentry. Those flags
are rarely changed after dentry instantiation and when changed,
flags can only be added. (e.g.: on copyup, rename and create).
Store the type value in ovl_entry and update the flags when
needed, so ovl_path_type() just returns the stored value.
The old ovl_path_type() took care of clearing OVL_TYPE_MERGE
for a non-dir entry. It did so for a reason that seem obsolete.
In any case, the code never checks OVL_TYPE_MERGE on non-dir entry,
so merge flag for non-dir is harmless.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/namei.c | 1 +
fs/overlayfs/overlayfs.h | 1 +
fs/overlayfs/ovl_entry.h | 3 +++
fs/overlayfs/super.c | 1 +
fs/overlayfs/util.c | 20 ++++++++++++--------
5 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 70a6b64..c230ee1 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -481,6 +481,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
kfree(stack);
kfree(d.redirect);
dentry->d_fsdata = oe;
+ ovl_update_type(dentry);
d_add(dentry, inode);
return NULL;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 2ef53f0..d37ec4c 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -168,6 +168,7 @@ struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
bool ovl_dentry_remote(struct dentry *dentry);
bool ovl_dentry_weird(struct dentry *dentry);
enum ovl_path_type ovl_path_type(struct dentry *dentry);
+enum ovl_path_type ovl_update_type(struct dentry *dentry);
void ovl_path_upper(struct dentry *dentry, struct path *path);
void ovl_path_lower(struct dentry *dentry, struct path *path);
enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 85c886d..b07c29f 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -33,6 +33,8 @@ struct ovl_fs {
wait_queue_head_t copyup_wq;
};
+enum ovl_path_type;
+
/* private information held for every overlayfs dentry */
struct ovl_entry {
struct dentry *__upperdentry;
@@ -46,6 +48,7 @@ struct ovl_entry {
};
struct rcu_head rcu;
};
+ enum ovl_path_type type;
unsigned numlower;
struct path lowerstack[];
};
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index f771366..bdbed27 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -977,6 +977,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
kfree(stack);
root_dentry->d_fsdata = oe;
+ ovl_update_type(root_dentry);
realinode = d_inode(ovl_dentry_real(root_dentry));
ovl_inode_init(d_inode(root_dentry), realinode, !!upperpath.dentry);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index aaac1ac..f9693a8 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -70,21 +70,24 @@ bool ovl_dentry_weird(struct dentry *dentry)
enum ovl_path_type ovl_path_type(struct dentry *dentry)
{
struct ovl_entry *oe = dentry->d_fsdata;
- enum ovl_path_type type = 0;
- if (oe->__upperdentry) {
- type = __OVL_PATH_UPPER;
+ return oe->type;
+}
+
+enum ovl_path_type ovl_update_type(struct dentry *dentry)
+{
+ struct ovl_entry *oe = dentry->d_fsdata;
+ enum ovl_path_type type = oe->type;
- /*
- * Non-dir dentry can hold lower dentry from previous
- * location.
- */
- if (oe->numlower && d_is_dir(dentry))
+ if (oe->__upperdentry) {
+ type |= __OVL_PATH_UPPER;
+ if (oe->numlower)
type |= __OVL_PATH_MERGE;
} else {
if (oe->numlower > 1)
type |= __OVL_PATH_MERGE;
}
+ oe->type = type;
return type;
}
@@ -248,6 +251,7 @@ void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
*/
smp_wmb();
oe->__upperdentry = upperdentry;
+ ovl_update_type(dentry);
}
void ovl_inode_init(struct inode *inode, struct inode *realinode, bool is_upper)
--
2.7.4
next prev parent reply other threads:[~2017-03-21 16:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 16:16 [RFC][PATCH 0/2] ovl: make room to store state flags in dentry Amir Goldstein
2017-03-21 16:16 ` Amir Goldstein [this message]
2017-03-28 14:03 ` [RFC][PATCH 1/2] ovl: store path type " Miklos Szeredi
2017-03-28 16:59 ` Amir Goldstein
2017-03-28 20:13 ` Amir Goldstein
2017-03-21 16:16 ` [RFC][PATCH 2/2] ovl: cram opaque boolean into type flags Amir Goldstein
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=1490113005-28787-2-git-send-email-amir73il@gmail.com \
--to=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