diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-10 15:37:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-10 22:54:35 -0400 |
commit | ee983e89670704b2a05e897b161f2674a42d1508 (patch) | |
tree | 51b96ffafd9e2496f8a7cf550245850d5a7a5929 /fs | |
parent | 94753db5ed9ad97582ef453127d9626a7a2be602 (diff) |
vfs: move dentry name length comparison from dentry_cmp() into callers
All callers do want to check the dentry length, but some of them can
check the length and the hash together, so doing it in dentry_cmp() can
be counter-productive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 5c09ad7b4a15..e6707a1f72c6 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -192,9 +192,6 @@ static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char | |||
192 | 192 | ||
193 | static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount) | 193 | static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount) |
194 | { | 194 | { |
195 | if (dentry->d_name.len != tcount) | ||
196 | return 1; | ||
197 | |||
198 | /* | 195 | /* |
199 | * Be careful about RCU walk racing with rename: | 196 | * Be careful about RCU walk racing with rename: |
200 | * use ACCESS_ONCE to fetch the name pointer. | 197 | * use ACCESS_ONCE to fetch the name pointer. |
@@ -1464,6 +1461,8 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry, | |||
1464 | continue; | 1461 | continue; |
1465 | if (alias->d_parent != entry->d_parent) | 1462 | if (alias->d_parent != entry->d_parent) |
1466 | continue; | 1463 | continue; |
1464 | if (alias->d_name.len != len) | ||
1465 | continue; | ||
1467 | if (dentry_cmp(alias, name, len)) | 1466 | if (dentry_cmp(alias, name, len)) |
1468 | continue; | 1467 | continue; |
1469 | __dget(alias); | 1468 | __dget(alias); |
@@ -1882,6 +1881,8 @@ seqretry: | |||
1882 | } | 1881 | } |
1883 | } | 1882 | } |
1884 | 1883 | ||
1884 | if (dentry->d_name.len != len) | ||
1885 | continue; | ||
1885 | if (!dentry_cmp(dentry, str, len)) | 1886 | if (!dentry_cmp(dentry, str, len)) |
1886 | return dentry; | 1887 | return dentry; |
1887 | } | 1888 | } |
@@ -1984,6 +1985,8 @@ struct dentry *__d_lookup(struct dentry *parent, struct qstr *name) | |||
1984 | tlen, tname, name)) | 1985 | tlen, tname, name)) |
1985 | goto next; | 1986 | goto next; |
1986 | } else { | 1987 | } else { |
1988 | if (dentry->d_name.len != len) | ||
1989 | goto next; | ||
1987 | if (dentry_cmp(dentry, str, len)) | 1990 | if (dentry_cmp(dentry, str, len)) |
1988 | goto next; | 1991 | goto next; |
1989 | } | 1992 | } |