Skip to content

Commit 5408c22

Browse files
author
Al Viro
committed
dcache.c: more idiomatic "positives are not allowed" sanity checks
Several functions have BUG_ON/WARN_ON sanity checks that want to verify that dentry is not positive and instead of looking at ->d_inode (as we do in all other places that check that) they look at ->d_alias. Just use the normal helpers instead - that way we no longer even look at ->d_alias for negative dentries Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2420067 commit 5408c22

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

fs/dcache.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static inline void __d_clear_type_and_inode(struct dentry *dentry)
428428

429429
static void dentry_free(struct dentry *dentry)
430430
{
431-
WARN_ON(!hlist_unhashed(&dentry->d_alias));
431+
WARN_ON(d_really_is_positive(dentry));
432432
if (unlikely(dname_external(dentry))) {
433433
struct external_name *p = external_name(dentry);
434434
if (likely(atomic_dec_and_test(&p->count))) {
@@ -2004,7 +2004,7 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
20042004

20052005
void d_instantiate(struct dentry *entry, struct inode * inode)
20062006
{
2007-
BUG_ON(!hlist_unhashed(&entry->d_alias));
2007+
BUG_ON(d_really_is_positive(entry));
20082008
if (inode) {
20092009
security_d_instantiate(entry, inode);
20102010
spin_lock(&inode->i_lock);
@@ -2024,7 +2024,7 @@ EXPORT_SYMBOL(d_instantiate);
20242024
*/
20252025
void d_instantiate_new(struct dentry *entry, struct inode *inode)
20262026
{
2027-
BUG_ON(!hlist_unhashed(&entry->d_alias));
2027+
BUG_ON(d_really_is_positive(entry));
20282028
BUG_ON(!inode);
20292029
lockdep_annotate_inode_mutex_key(inode);
20302030
security_d_instantiate(entry, inode);
@@ -2795,7 +2795,7 @@ EXPORT_SYMBOL(d_add);
27952795

27962796
struct dentry *d_make_persistent(struct dentry *dentry, struct inode *inode)
27972797
{
2798-
WARN_ON(!hlist_unhashed(&dentry->d_alias));
2798+
WARN_ON(d_really_is_positive(dentry));
27992799
WARN_ON(!inode);
28002800
security_d_instantiate(dentry, inode);
28012801
spin_lock(&inode->i_lock);
@@ -3185,7 +3185,7 @@ void d_mark_tmpfile(struct file *file, struct inode *inode)
31853185
struct dentry *dentry = file->f_path.dentry;
31863186

31873187
BUG_ON(dname_external(dentry) ||
3188-
!hlist_unhashed(&dentry->d_alias) ||
3188+
d_really_is_positive(dentry) ||
31893189
!d_unlinked(dentry));
31903190
spin_lock(&dentry->d_parent->d_lock);
31913191
spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);

0 commit comments

Comments
 (0)