lkml.org 
[lkml]   [2001]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] dcache 2nd chance replacement
On Wed, 3 Jan 2001, Linus Torvalds wrote:
> On Wed, 3 Jan 2001, Rik van Riel wrote:
> >
> > I rediffed this trivial patch by Andrea (that went
> > into 2.2.19-pre5) which adds 2nd chance replacement
> > to the dentry cache, this should make our dcache
> > behave a little bit better than the current FIFO.
>
> Looks ok, but I'd be happier if the
>
> dentry->d_flags |= DCACHE_REFERENCED;
>
> line would be inside the dcache lock (ie just move it up a line).

OK, here's a new patch ;)

regards,

Rik
--
Hollywood goes for world dumbination,
Trailer at 11.

http://www.surriel.com/
http://www.conectiva.com/ http://distro.conectiva.com.br/


--- linux-2.4.0-prerelease/include/linux/dcache.h.orig Wed Jan 3 16:33:43 2001
+++ linux-2.4.0-prerelease/include/linux/dcache.h Wed Jan 3 16:43:29 2001
@@ -115,6 +115,7 @@
* If this dentry points to a directory, then
* s_nfsd_free_path semaphore will be down
*/
+#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */

extern spinlock_t dcache_lock;

--- linux-2.4.0-prerelease/fs/dcache.c.orig Wed Jan 3 16:33:09 2001
+++ linux-2.4.0-prerelease/fs/dcache.c Wed Jan 3 17:10:50 2001
@@ -339,10 +339,17 @@

if (tmp == &dentry_unused)
break;
- dentry_stat.nr_unused--;
list_del_init(tmp);
dentry = list_entry(tmp, struct dentry, d_lru);

+ /* If the dentry was recently referenced, don't free it. */
+ if (dentry->d_flags & DCACHE_REFERENCED) {
+ dentry->d_flags &= ~DCACHE_REFERENCED;
+ list_add(&dentry->d_lru, &dentry_unused);
+ continue;
+ }
+ dentry_stat.nr_unused--;
+
/* Unused dentry with a count? */
if (atomic_read(&dentry->d_count))
BUG();
@@ -732,6 +739,7 @@
continue;
}
__dget_locked(dentry);
+ dentry->d_flags |= DCACHE_REFERENCED;
spin_unlock(&dcache_lock);
return dentry;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.072 / U:3.744 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site