]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/dcache.c
static-keys.txt: standardize document format
[karo-tx-linux.git] / fs / dcache.c
index a140fe1dbb1acc26e9e452f06b8ca108c085ecca..6c30be668487ca53725efc2229ac64dce68b9abc 100644 (file)
@@ -277,6 +277,33 @@ static inline int dname_external(const struct dentry *dentry)
        return dentry->d_name.name != dentry->d_iname;
 }
 
+void take_dentry_name_snapshot(struct name_snapshot *name, struct dentry *dentry)
+{
+       spin_lock(&dentry->d_lock);
+       if (unlikely(dname_external(dentry))) {
+               struct external_name *p = external_name(dentry);
+               atomic_inc(&p->u.count);
+               spin_unlock(&dentry->d_lock);
+               name->name = p->name;
+       } else {
+               memcpy(name->inline_name, dentry->d_iname, DNAME_INLINE_LEN);
+               spin_unlock(&dentry->d_lock);
+               name->name = name->inline_name;
+       }
+}
+EXPORT_SYMBOL(take_dentry_name_snapshot);
+
+void release_dentry_name_snapshot(struct name_snapshot *name)
+{
+       if (unlikely(name->name != name->inline_name)) {
+               struct external_name *p;
+               p = container_of(name->name, struct external_name, name[0]);
+               if (unlikely(atomic_dec_and_test(&p->u.count)))
+                       kfree_rcu(p, u.head);
+       }
+}
+EXPORT_SYMBOL(release_dentry_name_snapshot);
+
 static inline void __d_set_inode_and_type(struct dentry *dentry,
                                          struct inode *inode,
                                          unsigned type_flags)
@@ -1133,11 +1160,12 @@ void shrink_dcache_sb(struct super_block *sb)
                LIST_HEAD(dispose);
 
                freed = list_lru_walk(&sb->s_dentry_lru,
-                       dentry_lru_isolate_shrink, &dispose, UINT_MAX);
+                       dentry_lru_isolate_shrink, &dispose, 1024);
 
                this_cpu_sub(nr_dentry_unused, freed);
                shrink_dentry_list(&dispose);
-       } while (freed > 0);
+               cond_resched();
+       } while (list_lru_count(&sb->s_dentry_lru) > 0);
 }
 EXPORT_SYMBOL(shrink_dcache_sb);
 
@@ -3598,6 +3626,11 @@ EXPORT_SYMBOL(d_genocide);
 
 void __init vfs_caches_init_early(void)
 {
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(in_lookup_hashtable); i++)
+               INIT_HLIST_BL_HEAD(&in_lookup_hashtable[i]);
+
        dcache_init_early();
        inode_init_early();
 }