* more memory, or simply when we need to unmount
* something (at which point we need to unuse
* all dentries).
- *
- * "priority" is a value between 0-6, 0 means that
- * we should work really hard on releasing stuff..
*/
-void shrink_dcache(int priority)
+void shrink_dcache(void)
{
- int nr = 42; /* "random" number */
-
- nr <<= 6; nr >>= priority;
- do {
+ for (;;) {
struct dentry *dentry;
struct list_head *tmp = dentry_unused.prev;
d_free(dentry);
dput(parent);
}
- } while (--nr);
+ }
}
#define NAME_ALLOC_LEN(len) ((len+16) & ~15)
/* allocate/de-allocate */
extern void d_free(struct dentry *);
extern struct dentry * d_alloc(struct dentry * parent, const struct qstr *name);
-extern void shrink_dcache(int);
+extern void shrink_dcache(void);
/* only used at mount-time */
extern struct dentry * d_alloc_root(struct inode * root_inode, struct dentry * old_root);
return 1;
state = 1;
case 1:
- if (kmem_cache_reap(i, dma, wait))
- return 1;
+ shrink_dcache();
state = 2;
case 2:
- if (shm_swap(i, dma))
+ /*
+ * We shouldn't have a priority here:
+ * If we're low on memory we should
+ * unconditionally throw away _all_
+ * kmalloc caches!
+ */
+ if (kmem_cache_reap(0, dma, wait))
return 1;
state = 3;
case 3:
- shrink_dcache(i);
+ if (shm_swap(i, dma))
+ return 1;
state = 4;
default:
if (swap_out(i, dma, wait))