Re: How to bypass buffer caches?

From: Helge Hafting (helgehaf@aitel.hist.no)
Date: Fri Feb 14 2003 - 03:36:30 EST


Bruno Diniz de Paula wrote:
>
> Hi,
>
> I've sent some messages about using O_DIRECT to read files, but I
> suppose that is not possible using 2.4 kernel and ext2. So I was
> wondering which other alternatives I have to bypass the buffer cache of
> the kernel.

You don't say why you need this. I recommend that you
simply don't use a filesystem - use a partition like
/dev/hda5 without a filesystem and read/write diskblocks
to and from it.

Without a filesystem you decide what data goes in what disk block,
and of course no fs cache gets in the way.

Transfering data between a range of blocks on a partition
and a ordinary file is easy - use the dd command.

file->partition
dd if=yourfile of=/dev/hdaX bs=4096 seek=<number of first block you want
to use>

partition->file
dd if=/dev/hdaX of=yourfile bs=4096 skip=<number of first disk block you
want copied> count=<total number of blocks>

Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 15 2003 - 22:00:52 EST