lkml.org 
[lkml]   [1999]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch] ramdisk blocksize
On Fri, 20 Aug 1999, Bradley D. LaRonde wrote:

>What is the relationship between the page cache and the buffer cache? Are
>they completely separate allocations of memory? Is the page cache stored in
>the buffer cache? IOW, is the buffer cache the "back end" for the page

No. It's the buffer cache that sometime overlaps the page-cache when we
need to do I/O. We was just used to do that for do I/O brw I/O with the
swap cache, but now we can also left the bh header allocated over the swap
cache and the VM will care to free them when the memory goes low.

>> It's because we read and write the image using the blockdevice access.
>
>"We" meaning the initrd code?

Not only, also to upload a ramdisk you are going to use the blockdevice
interface over the ramdisk.

This patch will fix the ramdisk but I found some major bug (that can lead
to data corruption) in the page/buffer cache (not ramdisk related) and I
think that once I'll have fixed them the ramdisk won't need any change. So
take the below patch as a temp (wrong) fix.

--- 2.3.15-pre1-ramdisk/drivers/block/rd.c Fri Aug 20 20:58:03 1999
+++ 2.3.15-pre1-ramdisk-page-cache/drivers/block/rd.c Fri Aug 20 21:31:32 1999
@@ -217,9 +217,24 @@
* If we're writing, we protect the buffer.
*/

- if (CURRENT->cmd == READ)
- memset(CURRENT->buffer, 0, len);
- else
+ if (CURRENT->cmd == READ)
+ {
+ struct buffer_head * bh, * oldbh;
+
+ bh = CURRENT->bh; /* can the req->bh be null? I think no... */
+ oldbh = get_hash_table(bh->b_rdev, bh->b_blocknr, bh->b_size);
+ if (!oldbh)
+ memset(bh->b_data, 0, len);
+ else
+ {
+ memcpy(bh->b_data, oldbh->b_data, bh->b_size);
+ if (test_and_clear_bit(BH_Protected, &oldbh->b_state))
+ set_bit(BH_Protected, &bh->b_state);
+ if (atomic_set_buffer_clean(oldbh))
+ set_bit(BH_Protected, &bh->b_state);
+ atomic_dec(&oldbh->b_count);
+ }
+ } else
set_bit(BH_Protected, &CURRENT->bh->b_state);

end_request(1);

>Is the ramdisk actually cached? I mean, its primary storage is in (buffer
>cache) buffers, but will it actually get copied to the page cache, so that
>now there are two copies of (at least some of) the ramdisk data in memory?

Not at all. The data will be resident in the page cache and when the
pagecache will be removed the data will remains in orhapend buffers.

I hope to finish the right VM fix very soon...

Andrea


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

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.087 / U:2.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site