From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [PATCH v3 13/23] ovl: use ovl_inode_init() for initializing new inode
Date: Wed, 14 Jun 2017 10:26:32 +0300 [thread overview]
Message-ID: <1497425202-16270-14-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1497425202-16270-1-git-send-email-amir73il@gmail.com>
In preparation for hashing all overlay inodes, modify the helper
ovl_inode_init() to hash a new non-dir upper overlay inode.
Use this helper for initializing new upper inode in ovl_instantiate()
instead of ovl_inode_update(), because the implementations for new inode
case and copy up case are going to diverge.
Also move ovl_copyattr() into ovl_inode_init() and ovl_inode_get(),
so attributes will be copied only for new inode.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/dir.c | 3 +--
fs/overlayfs/inode.c | 1 +
fs/overlayfs/namei.c | 1 -
fs/overlayfs/util.c | 11 ++++++++++-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index a63a71656e9b..f87cef27741f 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -156,8 +156,7 @@ static void ovl_instantiate(struct dentry *dentry, struct inode *inode,
ovl_dentry_version_inc(dentry->d_parent);
ovl_dentry_update(dentry, newdentry);
if (!hardlink) {
- ovl_inode_update(inode, d_inode(newdentry));
- ovl_copyattr(newdentry->d_inode, inode);
+ ovl_inode_init(inode, d_inode(newdentry), true);
} else {
WARN_ON(ovl_inode_real(inode, NULL) != d_inode(newdentry));
inc_nlink(inode);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 49492b982726..6f0ec691d8d5 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -477,6 +477,7 @@ struct inode *ovl_get_inode(struct super_block *sb, struct inode *realinode)
if (inode && inode->i_state & I_NEW) {
ovl_fill_inode(inode, realinode->i_mode, realinode->i_rdev);
set_nlink(inode, realinode->i_nlink);
+ ovl_copyattr(realinode, inode);
unlock_new_inode(inode);
}
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index fe84e482d926..228b9eaa19f6 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -623,7 +623,6 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
}
if (!inode)
goto out_free_oe;
- ovl_copyattr(realdentry->d_inode, inode);
}
revert_creds(old_cred);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 0ce6efd8f19d..9bbcfcb20ec4 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -267,6 +267,12 @@ void ovl_dentry_update(struct dentry *dentry, struct dentry *upperdentry)
ovl_update_type(dentry, d_is_dir(dentry));
}
+static void ovl_insert_inode_hash(struct inode *inode, struct inode *realinode)
+{
+ WARN_ON(!inode_unhashed(inode));
+ __insert_inode_hash(inode, (unsigned long) realinode);
+}
+
void ovl_inode_init(struct inode *inode, struct inode *realinode, bool is_upper)
{
struct ovl_inode_info *oi = OVL_I_INFO(inode);
@@ -274,10 +280,13 @@ void ovl_inode_init(struct inode *inode, struct inode *realinode, bool is_upper)
if (is_upper) {
oi->__upperinode = realinode;
oi->lowerinode = NULL;
+ if (!S_ISDIR(realinode->i_mode))
+ ovl_insert_inode_hash(inode, realinode);
} else {
oi->__upperinode = NULL;
oi->lowerinode = realinode;
}
+ ovl_copyattr(realinode, inode);
}
struct inode *ovl_inode_real(struct inode *inode, bool *is_upper)
@@ -300,7 +309,7 @@ void ovl_inode_update(struct inode *inode, struct inode *upperinode)
WARN_ON(!inode_unhashed(inode));
WRITE_ONCE(OVL_I_INFO(inode)->__upperinode, upperinode);
if (!S_ISDIR(upperinode->i_mode))
- __insert_inode_hash(inode, (unsigned long) upperinode);
+ ovl_insert_inode_hash(inode, upperinode);
}
void ovl_dentry_version_inc(struct dentry *dentry)
--
2.7.4
next prev parent reply other threads:[~2017-06-14 7:26 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 7:26 [PATCH v3 00/23] Overlayfs inodes index Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 01/23] vfs: introduce inode 'inuse' lock Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 02/23] ovl: get exclusive ownership on upper/work dirs Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 03/23] ovl: relax same fs constrain for ovl_check_origin() Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 04/23] ovl: generalize ovl_create_workdir() Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 05/23] ovl: introduce the inodes index dir feature Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 06/23] ovl: verify upper root dir matches lower root dir Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 07/23] ovl: verify index dir matches upper dir Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 08/23] ovl: store path type in dentry Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 09/23] ovl: cram dentry state booleans into type flags Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 10/23] ovl: lookup index entry for copy up origin Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 11/23] ovl: allocate an ovl_inode struct Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 12/23] ovl: store upper/lower real inode in ovl_inode_info Amir Goldstein
2017-06-14 11:00 ` Amir Goldstein
2017-06-16 11:55 ` Amir Goldstein
2017-06-14 7:26 ` Amir Goldstein [this message]
2017-06-14 7:26 ` [PATCH v3 14/23] ovl: hash overlay non-dir inodes by copy up origin inode Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 15/23] ovl: defer upper dir lock to tempfile link Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 16/23] ovl: factor out ovl_copy_up_inode() helper Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 17/23] ovl: generalize ovl_copy_up_locked() using actors Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 18/23] ovl: generalize ovl_copy_up_one() " Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 19/23] ovl: use ovl_inode mutex to synchronize concurrent copy up Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 20/23] ovl: implement index dir copy up method Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 21/23] ovl: link up indexed lower hardlink on lookup Amir Goldstein
2017-06-19 10:22 ` Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 22/23] ovl: fix nlink leak in ovl_rename() Amir Goldstein
2017-06-14 7:26 ` [PATCH v3 23/23] ovl: adjust overlay inode nlink for indexed inodes Amir Goldstein
2017-06-14 7:30 ` [PATCH v3 00/23] Overlayfs inodes index Miklos Szeredi
2017-06-14 7:48 ` 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=1497425202-16270-14-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