From: Jeff Layton <jlayton@kernel.org>
To: viro@zeniv.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
miklos@szeredi.hu, gregkh@linuxfoundation.org, tj@kernel.org,
jack@suse.cz, amir73il@gmail.com, paul@paul-moore.com,
eparis@redhat.com, linux-audit@redhat.com, rafael@kernel.org
Subject: [PATCH 1/5] dcache: track the length of the string in struct name_snapshot
Date: Fri, 26 Apr 2019 14:28:43 -0400 [thread overview]
Message-ID: <20190426182847.25088-2-jlayton@kernel.org> (raw)
In-Reply-To: <20190426182847.25088-1-jlayton@kernel.org>
Several existing callers end up having to strlen the string, so just
convert the code over to set up a qstr instead and copy the length
from the original.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/dcache.c | 11 +++++++----
fs/debugfs/inode.c | 2 +-
fs/namei.c | 2 +-
fs/notify/fsnotify.c | 4 ++--
fs/overlayfs/export.c | 2 +-
include/linux/dcache.h | 2 +-
include/linux/fsnotify.h | 2 +-
7 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index aac41adf4743..a8dcc27ce2d0 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -287,22 +287,25 @@ void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry
if (unlikely(dname_external(dentry))) {
struct external_name *p = external_name(dentry);
atomic_inc(&p->u.count);
+ name->name.len = dentry->d_name.len;
spin_unlock(&dentry->d_lock);
- name->name = p->name;
+ name->name.name = p->name;
} else {
memcpy(name->inline_name, dentry->d_iname,
dentry->d_name.len + 1);
+ name->name.len = dentry->d_name.len;
spin_unlock(&dentry->d_lock);
- name->name = name->inline_name;
+ name->name.name = name->inline_name;
}
}
EXPORT_SYMBOL(take_dentry_name_snapshot);
void release_dentry_name_snapshot(struct name_snapshot *name)
{
- if (unlikely(name->name != name->inline_name)) {
+ if (unlikely(name->name.name != name->inline_name)) {
struct external_name *p;
- p = container_of(name->name, struct external_name, name[0]);
+ p = container_of(name->name.name, struct external_name,
+ name[0]);
if (unlikely(atomic_dec_and_test(&p->u.count)))
kfree_rcu(p, u.head);
}
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index f25daa207421..37c0a025d7e8 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -824,7 +824,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
goto exit;
}
d_move(old_dentry, dentry);
- fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name,
+ fsnotify_move(d_inode(old_dir), d_inode(new_dir), old_name.name.name,
d_is_dir(old_dentry),
NULL, old_dentry);
release_dentry_name_snapshot(&old_name);
diff --git a/fs/namei.c b/fs/namei.c
index dede0147b3f6..c96713077326 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4498,7 +4498,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
inode_unlock(target);
dput(new_dentry);
if (!error) {
- fsnotify_move(old_dir, new_dir, old_name.name, is_dir,
+ fsnotify_move(old_dir, new_dir, old_name.name.name, is_dir,
!(flags & RENAME_EXCHANGE) ? target : NULL, old_dentry);
if (flags & RENAME_EXCHANGE) {
fsnotify_move(new_dir, old_dir, old_dentry->d_name.name,
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index df06f3da166c..fb22f76329ae 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -179,10 +179,10 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
take_dentry_name_snapshot(&name, dentry);
if (path)
ret = fsnotify(p_inode, mask, path, FSNOTIFY_EVENT_PATH,
- name.name, 0);
+ name.name.name, 0);
else
ret = fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE,
- name.name, 0);
+ name.name.name, 0);
release_dentry_name_snapshot(&name);
}
diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 54e5d17d7f3e..cc1c9e5606ba 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -398,7 +398,7 @@ static struct dentry *ovl_lookup_real_one(struct dentry *connected,
* pointer because we hold no lock on the real dentry.
*/
take_dentry_name_snapshot(&name, real);
- this = lookup_one_len(name.name, connected, strlen(name.name));
+ this = lookup_one_len(name.name.name, connected, name.name.len);
err = PTR_ERR(this);
if (IS_ERR(this)) {
goto fail;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 60996e64c579..2ff5f3bb9ddc 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -594,7 +594,7 @@ static inline struct inode *d_real_inode(const struct dentry *dentry)
}
struct name_snapshot {
- const unsigned char *name;
+ struct qstr name;
unsigned char inline_name[DNAME_INLINE_LEN];
};
void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 09587e2860b5..e09cfff69bb2 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -178,7 +178,7 @@ static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
take_dentry_name_snapshot(&name, dentry);
fsnotify(d_inode(parent), mask, d_inode(dentry), FSNOTIFY_EVENT_INODE,
- name.name, 0);
+ name.name.name, 0);
release_dentry_name_snapshot(&name);
dput(parent);
--
2.20.1
next prev parent reply other threads:[~2019-04-26 18:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 18:28 [PATCH 0/5] vfs: track the dentry name length in name_snapshot Jeff Layton
2019-04-26 18:28 ` Jeff Layton [this message]
2019-04-26 18:28 ` [PATCH 2/5] fsnotify: have fsnotify_move take a struct qstr instead of a string Jeff Layton
2019-04-26 18:28 ` [PATCH 3/5] fsnotify: have fsnotify() take a " Jeff Layton
2019-04-26 18:28 ` [PATCH 4/5] fsnotify: change ->handle_event and send_to_group to take a qstr Jeff Layton
2019-04-26 18:28 ` [PATCH 5/5] audit: fix audit_compare_dname_path " Jeff Layton
2019-04-26 19:02 ` Paul Moore
2019-04-26 18:51 ` [PATCH 0/5] vfs: track the dentry name length in name_snapshot Al Viro
2019-04-26 18:59 ` Paul Moore
2019-04-26 19:03 ` Jeff Layton
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=20190426182847.25088-2-jlayton@kernel.org \
--to=jlayton@kernel.org \
--cc=amir73il@gmail.com \
--cc=eparis@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=linux-audit@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=paul@paul-moore.com \
--cc=rafael@kernel.org \
--cc=tj@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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