From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-unionfs@vger.kernel.org
Subject: [RFC][PATCH 4/4] ovl: use RENAME_DT_WHT to optimize ovl_dir_read_merged()
Date: Thu, 22 Dec 2016 19:25:35 +0200 [thread overview]
Message-ID: <1482427535-12801-5-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1482427535-12801-1-git-send-email-amir73il@gmail.com>
Try to use the new vfs rename flag RENAME_DT_WHT, to request from
underlying file system to mark whiteout directory entries as DT_WHT
instead of DT_CHR.
When whiteouts are classified as DT_WHT, ovl_dir_read_merged() can
distinguish between whiteouts to real character devices without
having to stat the suspect inodes.
Because this is only done for optimization, it is not a problem
if file system does not respect the new RENAME_DT_WHT flag, which
is most likely the case, so we retry the rename without the flag.
Even if DT_WHT type is set on rename using an experimental file
system patch, file system repair tools may later re-classify the
file type. That would break the optimization, but will not break
the functionality of ovl_dir_read_merged().
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/overlayfs/dir.c | 12 +++++++++---
fs/overlayfs/readdir.c | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 16e06dd..0e1c3f2 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -630,7 +630,13 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
struct dentry *upper;
struct dentry *opaquedir = NULL;
int err;
- int flags = 0;
+ /*
+ * Mark whiteout objects as DT_WHT instead of DT_CHR, so it easy
+ * to distinguish them real character devices in iterate_dir().
+ * File system repair tools may re-classify the file type
+ * and that will break optimization, but not functionality.
+ */
+ int flags = RENAME_DT_WHT;
if (WARN_ON(!workdir))
return -EROFS;
@@ -665,12 +671,12 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
goto out_dput_upper;
if (d_is_dir(upper))
- flags = RENAME_EXCHANGE;
+ flags |= RENAME_EXCHANGE;
err = ovl_do_rename(wdir, whiteout, udir, upper, flags);
if (err)
goto kill_whiteout;
- if (flags)
+ if (flags & RENAME_EXCHANGE)
ovl_cleanup(wdir, upper);
ovl_dentry_version_inc(dentry->d_parent);
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index f241b4e..32c5c96 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -98,7 +98,7 @@ static struct ovl_cache_entry *ovl_cache_entry_new(struct ovl_readdir_data *rdd,
p->len = len;
p->type = d_type;
p->ino = ino;
- p->is_whiteout = false;
+ p->is_whiteout = (d_type == DT_WHT);
if (d_type == DT_CHR) {
p->next_maybe_whiteout = rdd->first_maybe_whiteout;
--
2.7.4
prev parent reply other threads:[~2016-12-22 17:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-22 17:25 [RFC][PATCH 0/4] ovl: optimize dir iteration Amir Goldstein
2016-12-22 17:25 ` [RFC][PATCH 1/4] vfs: add RENAME_VFS_DTYPE vfs_rename() flag Amir Goldstein
2016-12-22 17:25 ` [RFC][PATCH 2/4] xfs: support RENAME_VFS_DTYPE flag Amir Goldstein
2016-12-22 17:25 ` [RFC][PATCH 3/4] ovl: use RENAME_DT_UNKNOWN to optimize stable d_inode Amir Goldstein
2016-12-22 17:25 ` Amir Goldstein [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=1482427535-12801-5-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