ext4: move check under lock scope to close a race.
[firefly-linux-kernel-4.4.55.git] / fs / dcache.c
index e33a0934efd7a7024dda7f14ac98ff4fc2f1811f..c71e3732e53bcebbffca749e65b7095fd4ff6e7e 100644 (file)
@@ -1677,7 +1677,7 @@ EXPORT_SYMBOL(d_set_fallthru);
 
 static unsigned d_flags_for_inode(struct inode *inode)
 {
-       unsigned add_flags = DCACHE_FILE_TYPE;
+       unsigned add_flags = DCACHE_REGULAR_TYPE;
 
        if (!inode)
                return DCACHE_MISS_TYPE;
@@ -1690,13 +1690,21 @@ static unsigned d_flags_for_inode(struct inode *inode)
                        else
                                inode->i_opflags |= IOP_LOOKUP;
                }
-       } else if (unlikely(!(inode->i_opflags & IOP_NOFOLLOW))) {
-               if (unlikely(inode->i_op->follow_link))
+               goto type_determined;
+       }
+
+       if (unlikely(!(inode->i_opflags & IOP_NOFOLLOW))) {
+               if (unlikely(inode->i_op->follow_link)) {
                        add_flags = DCACHE_SYMLINK_TYPE;
-               else
-                       inode->i_opflags |= IOP_NOFOLLOW;
+                       goto type_determined;
+               }
+               inode->i_opflags |= IOP_NOFOLLOW;
        }
 
+       if (unlikely(!S_ISREG(inode->i_mode)))
+               add_flags = DCACHE_SPECIAL_TYPE;
+
+type_determined:
        if (unlikely(IS_AUTOMOUNT(inode)))
                add_flags |= DCACHE_NEED_AUTOMOUNT;
        return add_flags;