提交 8966be90 编写于 作者: L Linus Torvalds

vfs: trivial __d_lookup_rcu() cleanups

These don't change any semantics, but they clean up the code a bit and
mark some arguments appropriately 'const'.

They came up as I was doing the word-at-a-time dcache name accessor
code, and cleaning this up now allows me to send out a smaller relevant
interesting patch for the experimental stuff.
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 2273d5cc
...@@ -104,7 +104,7 @@ static unsigned int d_hash_shift __read_mostly; ...@@ -104,7 +104,7 @@ static unsigned int d_hash_shift __read_mostly;
static struct hlist_bl_head *dentry_hashtable __read_mostly; static struct hlist_bl_head *dentry_hashtable __read_mostly;
static inline struct hlist_bl_head *d_hash(struct dentry *parent, static inline struct hlist_bl_head *d_hash(const struct dentry *parent,
unsigned long hash) unsigned long hash)
{ {
hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES; hash += ((unsigned long) parent ^ GOLDEN_RATIO_PRIME) / L1_CACHE_BYTES;
...@@ -1717,8 +1717,9 @@ EXPORT_SYMBOL(d_add_ci); ...@@ -1717,8 +1717,9 @@ EXPORT_SYMBOL(d_add_ci);
* child is looked up. Thus, an interlocking stepping of sequence lock checks * child is looked up. Thus, an interlocking stepping of sequence lock checks
* is formed, giving integrity down the path walk. * is formed, giving integrity down the path walk.
*/ */
struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, struct dentry *__d_lookup_rcu(const struct dentry *parent,
unsigned *seq, struct inode **inode) const struct qstr *name,
unsigned *seqp, struct inode **inode)
{ {
unsigned int len = name->len; unsigned int len = name->len;
unsigned int hash = name->hash; unsigned int hash = name->hash;
...@@ -1748,6 +1749,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, ...@@ -1748,6 +1749,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
* See Documentation/filesystems/path-lookup.txt for more details. * See Documentation/filesystems/path-lookup.txt for more details.
*/ */
hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) { hlist_bl_for_each_entry_rcu(dentry, node, b, d_hash) {
unsigned seq;
struct inode *i; struct inode *i;
const char *tname; const char *tname;
int tlen; int tlen;
...@@ -1756,7 +1758,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, ...@@ -1756,7 +1758,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
continue; continue;
seqretry: seqretry:
*seq = read_seqcount_begin(&dentry->d_seq); seq = read_seqcount_begin(&dentry->d_seq);
if (dentry->d_parent != parent) if (dentry->d_parent != parent)
continue; continue;
if (d_unhashed(dentry)) if (d_unhashed(dentry))
...@@ -1771,7 +1773,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, ...@@ -1771,7 +1773,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
* edge of memory when walking. If we could load this * edge of memory when walking. If we could load this
* atomically some other way, we could drop this check. * atomically some other way, we could drop this check.
*/ */
if (read_seqcount_retry(&dentry->d_seq, *seq)) if (read_seqcount_retry(&dentry->d_seq, seq))
goto seqretry; goto seqretry;
if (unlikely(parent->d_flags & DCACHE_OP_COMPARE)) { if (unlikely(parent->d_flags & DCACHE_OP_COMPARE)) {
if (parent->d_op->d_compare(parent, *inode, if (parent->d_op->d_compare(parent, *inode,
...@@ -1788,6 +1790,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, ...@@ -1788,6 +1790,7 @@ struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
* order to do anything useful with the returned dentry * order to do anything useful with the returned dentry
* anyway. * anyway.
*/ */
*seqp = seq;
*inode = i; *inode = i;
return dentry; return dentry;
} }
......
...@@ -309,7 +309,8 @@ extern struct dentry *d_ancestor(struct dentry *, struct dentry *); ...@@ -309,7 +309,8 @@ extern struct dentry *d_ancestor(struct dentry *, struct dentry *);
extern struct dentry *d_lookup(struct dentry *, struct qstr *); extern struct dentry *d_lookup(struct dentry *, struct qstr *);
extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *); extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
extern struct dentry *__d_lookup(struct dentry *, struct qstr *); extern struct dentry *__d_lookup(struct dentry *, struct qstr *);
extern struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name, extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
const struct qstr *name,
unsigned *seq, struct inode **inode); unsigned *seq, struct inode **inode);
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册