From: mru@users.sourceforge.net (Måns Rullgård)
To: linux-kernel@vger.kernel.org
Subject: Re: how to turn off, or to clear read cache?
Date: Wed, 20 Aug 2003 14:30:18 +0200 [thread overview]
Message-ID: <yw1xlltocy05.fsf@users.sourceforge.net> (raw)
In-Reply-To: 3F4360F0.209@gamic.com
Sergey Spiridonov <spiridonov@gamic.com> writes:
> I need to make some performance tests. I need to switch off or to
> clear read cache, so that consequent reading of the same file will
> take the same amount of time.
>
> Is there an easy way to do it, without rebuilding the kernel?
I never found one, so I made this little patch. It adds a mount
option to the ext3 filesystem that makes it drop the cache when a file
is closed. Diff is against 2.4.21. It's just a quick hack that
accomplishes what I needed. I'm sure there's a better, more generic,
way.
Index: include/linux/ext3_fs.h
===================================================================
RCS file: /home/cvs/linux-2.4/include/linux/ext3_fs.h,v
retrieving revision 1.8
diff -u -r1.8 ext3_fs.h
--- include/linux/ext3_fs.h 1 Apr 2003 21:09:23 -0000 1.8
+++ include/linux/ext3_fs.h 17 Jun 2003 09:10:56 -0000
@@ -339,6 +339,7 @@
#define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
#define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
#define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
+#define EXT3_MOUNT_NOCACHE 0x4000 /* Free cached blocks on close */
/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
#ifndef _LINUX_EXT2_FS_H
Index: fs/ext3/file.c
===================================================================
RCS file: /home/cvs/linux-2.4/fs/ext3/file.c,v
retrieving revision 1.4
diff -u -r1.4 file.c
--- fs/ext3/file.c 28 Aug 2002 21:11:16 -0000 1.4
+++ fs/ext3/file.c 17 Jun 2003 09:10:57 -0000
@@ -35,6 +35,10 @@
{
if (filp->f_mode & FMODE_WRITE)
ext3_discard_prealloc (inode);
+ if (inode->i_sb->u.ext3_sb.s_mount_opt & EXT3_MOUNT_NOCACHE){
+ write_inode_now(inode, 1);
+ invalidate_inode_pages(inode);
+ }
return 0;
}
Index: fs/ext3/super.c
===================================================================
RCS file: /home/cvs/linux-2.4/fs/ext3/super.c,v
retrieving revision 1.10
diff -u -r1.10 super.c
--- fs/ext3/super.c 28 Apr 2003 21:14:51 -0000 1.10
+++ fs/ext3/super.c 17 Jun 2003 09:10:59 -0000
@@ -654,6 +654,8 @@
if (want_numeric(value, "commit", &v))
return 0;
sbi->s_commit_interval = (HZ * v);
+ } else if (!strcmp (this_char, "nocache")){
+ set_opt (*mount_options, NOCACHE);
} else {
printk (KERN_ERR
"EXT3-fs: Unrecognized mount option %s\n",
--
Måns Rullgård
mru@users.sf.net
next prev parent reply other threads:[~2003-08-20 12:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-20 11:52 how to turn off, or to clear read cache? Sergey Spiridonov
2003-08-20 12:30 ` Måns Rullgård [this message]
2003-08-20 13:11 ` Denis Vlasenko
2003-08-20 14:30 ` Sergey Spiridonov
2003-08-20 22:46 ` Jamie Lokier
2003-08-20 22:52 ` Mike Fedyk
-- strict thread matches above, loose matches on Subject: below --
2003-08-20 13:22 John Bradford
2003-08-20 13:23 ` Sergey Spiridonov
2003-08-20 13:31 ` Måns Rullgård
2003-08-20 16:49 ` Luciano Miguel Ferreira Rocha
2003-08-20 16:57 ` Måns Rullgård
2003-08-20 17:17 ` Jeff Garzik
2003-08-20 17:28 ` Måns Rullgård
[not found] <mzNF.3z3.47@gated-at.bofh.it>
[not found] ` <mB2M.4Jv.35@gated-at.bofh.it>
[not found] ` <mCi4.5Kq.3@gated-at.bofh.it>
2003-08-21 10:01 ` Ihar 'Philips' Filipau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yw1xlltocy05.fsf@users.sourceforge.net \
--to=mru@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.