From: Gabriel Krisman Bertazi <krisman@collabora.com> To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org Cc: ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi <krisman@collabora.com>, kernel@collabora.com Subject: [PATCH 1/7] fs: Expose name under lookup to d_revalidate hook Date: Wed, 22 Jun 2022 15:45:57 -0400 [thread overview] Message-ID: <20220622194603.102655-2-krisman@collabora.com> (raw) In-Reply-To: <20220622194603.102655-1-krisman@collabora.com> Negative dentries support on case-insensitive ext4/f2fs will require access to the name under lookup to ensure it matches the dentry. This adds an optional new flavor of cached dentry revalidation hook to expose this extra parameter. I'm fine with extending d_revalidate instead of adding a new hook, if it is considered cleaner and the approach is accepted. I wrote a new hook to simplify reviewing. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> --- fs/dcache.c | 2 +- fs/namei.c | 23 ++++++++++++++--------- include/linux/dcache.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 93f4f5ee07bf..a0fe9e3676fb 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1928,7 +1928,7 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) dentry->d_flags |= DCACHE_OP_HASH; if (op->d_compare) dentry->d_flags |= DCACHE_OP_COMPARE; - if (op->d_revalidate) + if (op->d_revalidate || op->d_revalidate_name) dentry->d_flags |= DCACHE_OP_REVALIDATE; if (op->d_weak_revalidate) dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE; diff --git a/fs/namei.c b/fs/namei.c index 1f28d3f463c3..c01bb19723db 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -842,11 +842,16 @@ static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry, unsi return false; } -static inline int d_revalidate(struct dentry *dentry, unsigned int flags) +static inline int d_revalidate(struct dentry *dentry, + const struct qstr *name, + unsigned int flags) { - if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) + + if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) { + if (dentry->d_op->d_revalidate_name) + return dentry->d_op->d_revalidate_name(dentry, name, flags); return dentry->d_op->d_revalidate(dentry, flags); - else + } else return 1; } @@ -1563,7 +1568,7 @@ static struct dentry *lookup_dcache(const struct qstr *name, { struct dentry *dentry = d_lookup(dir, name); if (dentry) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) d_invalidate(dentry); @@ -1647,19 +1652,19 @@ static struct dentry *lookup_fast(struct nameidata *nd, return ERR_PTR(-ECHILD); *seqp = seq; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); if (likely(status > 0)) return dentry; if (!try_to_unlazy_next(nd, dentry, seq)) return ERR_PTR(-ECHILD); if (status == -ECHILD) /* we'd been told to redo it in non-rcu mode */ - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } else { dentry = __d_lookup(parent, &nd->last); if (unlikely(!dentry)) return NULL; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } if (unlikely(status <= 0)) { if (!status) @@ -1687,7 +1692,7 @@ static struct dentry *__lookup_slow(const struct qstr *name, if (IS_ERR(dentry)) return dentry; if (unlikely(!d_in_lookup(dentry))) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) { d_invalidate(dentry); @@ -3302,7 +3307,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, if (d_in_lookup(dentry)) break; - error = d_revalidate(dentry, nd->flags); + error = d_revalidate(dentry, &nd->last, nd->flags); if (likely(error > 0)) break; if (error) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..871f65c8ef7f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -126,6 +126,7 @@ enum dentry_d_lock_class struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); + int (*d_revalidate_name)(struct dentry *, const struct qstr *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, -- 2.36.1
WARNING: multiple messages have this Message-ID (diff)
From: Gabriel Krisman Bertazi <krisman@collabora.com> To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org Cc: kernel@collabora.com, linux-f2fs-devel@lists.sourceforge.net, ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi <krisman@collabora.com> Subject: [f2fs-dev] [PATCH 1/7] fs: Expose name under lookup to d_revalidate hook Date: Wed, 22 Jun 2022 15:45:57 -0400 [thread overview] Message-ID: <20220622194603.102655-2-krisman@collabora.com> (raw) In-Reply-To: <20220622194603.102655-1-krisman@collabora.com> Negative dentries support on case-insensitive ext4/f2fs will require access to the name under lookup to ensure it matches the dentry. This adds an optional new flavor of cached dentry revalidation hook to expose this extra parameter. I'm fine with extending d_revalidate instead of adding a new hook, if it is considered cleaner and the approach is accepted. I wrote a new hook to simplify reviewing. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> --- fs/dcache.c | 2 +- fs/namei.c | 23 ++++++++++++++--------- include/linux/dcache.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 93f4f5ee07bf..a0fe9e3676fb 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1928,7 +1928,7 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) dentry->d_flags |= DCACHE_OP_HASH; if (op->d_compare) dentry->d_flags |= DCACHE_OP_COMPARE; - if (op->d_revalidate) + if (op->d_revalidate || op->d_revalidate_name) dentry->d_flags |= DCACHE_OP_REVALIDATE; if (op->d_weak_revalidate) dentry->d_flags |= DCACHE_OP_WEAK_REVALIDATE; diff --git a/fs/namei.c b/fs/namei.c index 1f28d3f463c3..c01bb19723db 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -842,11 +842,16 @@ static bool try_to_unlazy_next(struct nameidata *nd, struct dentry *dentry, unsi return false; } -static inline int d_revalidate(struct dentry *dentry, unsigned int flags) +static inline int d_revalidate(struct dentry *dentry, + const struct qstr *name, + unsigned int flags) { - if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) + + if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) { + if (dentry->d_op->d_revalidate_name) + return dentry->d_op->d_revalidate_name(dentry, name, flags); return dentry->d_op->d_revalidate(dentry, flags); - else + } else return 1; } @@ -1563,7 +1568,7 @@ static struct dentry *lookup_dcache(const struct qstr *name, { struct dentry *dentry = d_lookup(dir, name); if (dentry) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) d_invalidate(dentry); @@ -1647,19 +1652,19 @@ static struct dentry *lookup_fast(struct nameidata *nd, return ERR_PTR(-ECHILD); *seqp = seq; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); if (likely(status > 0)) return dentry; if (!try_to_unlazy_next(nd, dentry, seq)) return ERR_PTR(-ECHILD); if (status == -ECHILD) /* we'd been told to redo it in non-rcu mode */ - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } else { dentry = __d_lookup(parent, &nd->last); if (unlikely(!dentry)) return NULL; - status = d_revalidate(dentry, nd->flags); + status = d_revalidate(dentry, &nd->last, nd->flags); } if (unlikely(status <= 0)) { if (!status) @@ -1687,7 +1692,7 @@ static struct dentry *__lookup_slow(const struct qstr *name, if (IS_ERR(dentry)) return dentry; if (unlikely(!d_in_lookup(dentry))) { - int error = d_revalidate(dentry, flags); + int error = d_revalidate(dentry, name, flags); if (unlikely(error <= 0)) { if (!error) { d_invalidate(dentry); @@ -3302,7 +3307,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, if (d_in_lookup(dentry)) break; - error = d_revalidate(dentry, nd->flags); + error = d_revalidate(dentry, &nd->last, nd->flags); if (likely(error > 0)) break; if (error) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index f5bba51480b2..871f65c8ef7f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -126,6 +126,7 @@ enum dentry_d_lock_class struct dentry_operations { int (*d_revalidate)(struct dentry *, unsigned int); + int (*d_revalidate_name)(struct dentry *, const struct qstr *, unsigned int); int (*d_weak_revalidate)(struct dentry *, unsigned int); int (*d_hash)(const struct dentry *, struct qstr *); int (*d_compare)(const struct dentry *, -- 2.36.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2022-06-22 19:46 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-22 19:45 [PATCH 0/7] Support negative dentries on case-insensitive directories Gabriel Krisman Bertazi 2022-06-22 19:45 ` [f2fs-dev] " Gabriel Krisman Bertazi 2022-06-22 19:45 ` Gabriel Krisman Bertazi [this message] 2022-06-22 19:45 ` [f2fs-dev] [PATCH 1/7] fs: Expose name under lookup to d_revalidate hook Gabriel Krisman Bertazi 2023-03-23 14:33 ` Theodore Ts'o 2023-03-23 14:33 ` [f2fs-dev] " Theodore Ts'o 2023-03-25 13:33 ` Theodore Ts'o 2023-03-25 13:33 ` [f2fs-dev] " Theodore Ts'o 2023-03-26 5:03 ` Al Viro 2023-03-26 5:03 ` [f2fs-dev] " Al Viro 2022-06-22 19:45 ` [PATCH 2/7] fs: Add DCACHE_CASEFOLD_LOOKUP flag Gabriel Krisman Bertazi 2022-06-22 19:45 ` [f2fs-dev] " Gabriel Krisman Bertazi 2023-03-23 14:33 ` Theodore Ts'o 2023-03-23 14:33 ` [f2fs-dev] " Theodore Ts'o 2022-06-22 19:45 ` [PATCH 3/7] libfs: Validate negative dentries in case-insensitive directories Gabriel Krisman Bertazi 2022-06-22 19:45 ` [f2fs-dev] " Gabriel Krisman Bertazi 2023-03-23 14:36 ` Theodore Ts'o 2023-03-23 14:36 ` [f2fs-dev] " Theodore Ts'o 2023-03-26 4:46 ` Al Viro 2023-03-26 4:46 ` [f2fs-dev] " Al Viro 2023-03-31 15:31 ` Gabriel Krisman Bertazi 2023-03-31 15:31 ` Gabriel Krisman Bertazi 2022-06-22 19:46 ` [PATCH 4/7] libfs: Support revalidation of encrypted case-insensitive dentries Gabriel Krisman Bertazi 2022-06-22 19:46 ` [f2fs-dev] " Gabriel Krisman Bertazi 2023-03-23 14:37 ` Theodore Ts'o 2023-03-23 14:37 ` [f2fs-dev] " Theodore Ts'o 2022-06-22 19:46 ` [PATCH 5/7] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Gabriel Krisman Bertazi 2022-06-22 19:46 ` [f2fs-dev] " Gabriel Krisman Bertazi 2023-03-23 14:39 ` Theodore Ts'o 2023-03-23 14:39 ` [f2fs-dev] " Theodore Ts'o 2022-06-22 19:46 ` [PATCH 6/7] ext4: Enable negative dentries on case-insensitive lookup Gabriel Krisman Bertazi 2022-06-22 19:46 ` [f2fs-dev] " Gabriel Krisman Bertazi 2022-06-23 7:29 ` kernel test robot 2022-06-23 7:29 ` [f2fs-dev] " kernel test robot 2022-06-23 16:36 ` Gabriel Krisman Bertazi 2022-06-23 16:36 ` Gabriel Krisman Bertazi 2022-06-23 16:36 ` [f2fs-dev] " Gabriel Krisman Bertazi 2023-03-23 14:39 ` Theodore Ts'o 2023-03-23 14:39 ` [f2fs-dev] " Theodore Ts'o 2022-06-22 19:46 ` [PATCH 7/7] f2fs: " Gabriel Krisman Bertazi 2022-06-22 19:46 ` [f2fs-dev] " Gabriel Krisman Bertazi 2022-06-23 12:44 ` kernel test robot 2022-06-23 12:44 ` [f2fs-dev] " kernel test robot 2023-02-24 22:36 ` [PATCH 0/7] Support negative dentries on case-insensitive directories Daniel Rosenberg 2023-02-24 22:36 ` [f2fs-dev] " Daniel Rosenberg via Linux-f2fs-devel
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=20220622194603.102655-2-krisman@collabora.com \ --to=krisman@collabora.com \ --cc=ebiggers@kernel.org \ --cc=jaegeuk@kernel.org \ --cc=kernel@collabora.com \ --cc=linux-ext4@vger.kernel.org \ --cc=linux-f2fs-devel@lists.sourceforge.net \ --cc=linux-fsdevel@vger.kernel.org \ --cc=tytso@mit.edu \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.