From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Jeff Layton <jlayton@poochiereds.net>,
"J . Bruce Fields" <bfields@fieldses.org>,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 13/17] ovl: hash directory inodes for NFS export
Date: Thu, 4 Jan 2018 19:20:45 +0200 [thread overview]
Message-ID: <1515086449-26563-14-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1515086449-26563-1-git-send-email-amir73il@gmail.com>
If NFS export is enabled, hash indexed directory inodes by origin inode,
so we can find them in inode cache using the decoded origin inode before
looking up origin file handle in index.
Non-indexed and pure upper dirs are hashed by upper inode, because those
are encoded as upper file handles.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/inode.c | 11 +++++++----
fs/overlayfs/super.c | 3 +++
fs/overlayfs/util.c | 4 +++-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index a25908ba3512..8db3f466df60 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -563,7 +563,9 @@ unsigned int ovl_get_nlink(struct dentry *lowerdentry,
char buf[13];
int err;
- if (!lowerdentry || !upperdentry || d_inode(lowerdentry)->i_nlink == 1)
+ if (!lowerdentry || !upperdentry ||
+ d_inode(lowerdentry)->i_nlink == 1 ||
+ S_ISDIR(d_inode(upperdentry)->i_mode))
return fallback;
err = vfs_getxattr(upperdentry, OVL_XATTR_NLINK, &buf, sizeof(buf) - 1);
@@ -661,6 +663,7 @@ struct inode *ovl_get_inode(struct super_block *sb, struct dentry *upperdentry,
struct inode *inode;
/* Already indexed or could be indexed on copy up? */
bool indexed = (index || (ovl_indexdir(sb) && !upperdentry));
+ struct dentry *origin = indexed ? lowerdentry : upperdentry;
if (WARN_ON(upperdentry && indexed && !lowerdentry))
return ERR_PTR(-EIO);
@@ -673,10 +676,10 @@ struct inode *ovl_get_inode(struct super_block *sb, struct dentry *upperdentry,
* not use lower as hash key in that case.
* Hash inodes that are or could be indexed by origin inode and
* non-indexed upper inodes that could be hard linked by upper inode.
+ * Hash directory inodes only if NFS export is supported.
*/
- if (!S_ISDIR(realinode->i_mode) && (upperdentry || indexed)) {
- struct inode *key = d_inode(indexed ? lowerdentry :
- upperdentry);
+ if (origin && (!S_ISDIR(realinode->i_mode) || sb->s_export_op)) {
+ struct inode *key = d_inode(origin);
unsigned int nlink;
inode = iget5_locked(sb, (unsigned long) key,
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index f152b817e4d0..1bc37bc23e89 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -1341,6 +1341,9 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
/* Root is always merge -> can have whiteouts */
ovl_set_flag(OVL_WHITEOUTS, d_inode(root_dentry));
+ /* Hash root directory inode by upper dir inode for NFS export */
+ if (sb->s_export_op)
+ ovl_inode_update(d_inode(root_dentry), upperpath.dentry);
ovl_inode_init(d_inode(root_dentry), upperpath.dentry,
ovl_dentry_lower(root_dentry));
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 1b0dc903cf6d..92a2a70db67c 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -308,7 +308,9 @@ void ovl_inode_update(struct inode *inode, struct dentry *upperdentry)
*/
smp_wmb();
OVL_I(inode)->__upperdentry = upperdentry;
- if (!S_ISDIR(upperinode->i_mode) && inode_unhashed(inode)) {
+ /* Hash directory inodes only if NFS export is supported */
+ if ((!S_ISDIR(upperinode->i_mode) || inode->i_sb->s_export_op) &&
+ inode_unhashed(inode)) {
inode->i_private = upperinode;
__insert_inode_hash(inode, (unsigned long) upperinode);
}
--
2.7.4
next prev parent reply other threads:[~2018-01-04 17:20 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-04 17:20 [PATCH v2 00/17] Overlayfs NFS export support Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 01/17] ovl: document NFS export Amir Goldstein
2018-01-11 16:06 ` Miklos Szeredi
2018-01-11 16:26 ` Amir Goldstein
2018-01-12 15:43 ` Miklos Szeredi
2018-01-12 15:49 ` Miklos Szeredi
2018-01-12 18:50 ` Amir Goldstein
2018-01-13 8:54 ` Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 02/17] ovl: encode pure upper file handles Amir Goldstein
2018-01-18 10:31 ` Miklos Szeredi
2018-01-04 17:20 ` [PATCH v2 03/17] ovl: decode " Amir Goldstein
2018-01-18 14:09 ` Miklos Szeredi
2018-01-18 14:34 ` Amir Goldstein
2018-01-18 14:39 ` Miklos Szeredi
2018-01-18 19:49 ` Amir Goldstein
2018-01-18 20:10 ` Miklos Szeredi
2018-01-18 20:35 ` Amir Goldstein
2018-01-18 22:57 ` Amir Goldstein
2018-01-19 0:23 ` Amir Goldstein
2018-01-19 10:39 ` Miklos Szeredi
2018-01-19 11:07 ` Amir Goldstein
2018-01-19 20:10 ` Amir Goldstein
2018-01-24 10:34 ` Miklos Szeredi
2018-01-24 11:04 ` Amir Goldstein
2018-01-24 11:18 ` Amir Goldstein
2018-01-24 11:55 ` Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 04/17] ovl: decode connected upper dir " Amir Goldstein
2018-01-05 12:33 ` Amir Goldstein
2018-01-05 15:18 ` J . Bruce Fields
2018-01-05 15:34 ` Amir Goldstein
2018-01-15 11:41 ` Miklos Szeredi
2018-01-15 11:33 ` Miklos Szeredi
2018-01-15 12:20 ` Amir Goldstein
2018-01-15 14:56 ` Miklos Szeredi
2018-01-17 11:18 ` Amir Goldstein
2018-01-17 12:20 ` Amir Goldstein
2018-01-17 13:29 ` Amir Goldstein
2018-01-17 15:42 ` Miklos Szeredi
2018-01-17 16:34 ` Amir Goldstein
2018-01-17 21:36 ` Amir Goldstein
2018-01-18 8:22 ` Miklos Szeredi
2018-01-18 8:47 ` Amir Goldstein
2018-01-18 9:12 ` Miklos Szeredi
2018-01-18 10:28 ` Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 05/17] ovl: encode non-indexed upper " Amir Goldstein
2018-01-15 11:58 ` Miklos Szeredi
2018-01-15 12:07 ` Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 06/17] ovl: copy up before encoding dir file handle when ofs->numlower > 1 Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 07/17] ovl: encode lower file handles Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 08/17] ovl: decode lower non-dir " Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 09/17] ovl: decode indexed " Amir Goldstein
2018-01-18 13:11 ` Miklos Szeredi
2018-01-04 17:20 ` [PATCH v2 10/17] ovl: decode lower file handles of unlinked but open files Amir Goldstein
2018-01-16 9:16 ` Miklos Szeredi
2018-01-16 9:37 ` Amir Goldstein
2018-01-16 10:10 ` Miklos Szeredi
2018-01-16 10:40 ` Amir Goldstein
2018-01-16 11:07 ` Miklos Szeredi
2018-01-17 21:05 ` Amir Goldstein
2018-01-18 14:18 ` Amir Goldstein
2018-02-27 11:35 ` Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 11/17] ovl: decode indexed dir file handles Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 12/17] ovl: decode pure lower " Amir Goldstein
2018-01-04 17:20 ` Amir Goldstein [this message]
2018-01-04 17:20 ` [PATCH v2 14/17] ovl: lookup connected ancestor of dir in inode cache Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 15/17] ovl: lookup indexed ancestor of lower dir Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 16/17] ovl: wire up NFS export support Amir Goldstein
2018-01-04 17:20 ` [PATCH v2 17/17] nfsd: encode stat->mtime for getattr instead of inode->i_mtime 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=1515086449-26563-14-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=bfields@fieldses.org \
--cc=jlayton@poochiereds.net \
--cc=linux-fsdevel@vger.kernel.org \
--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).