From: Herbert Xu <herbert@gondor.apana.org.au>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] Soft block sizes for RAM disks
Date: Mon, 21 May 2001 21:53:39 +1000 [thread overview]
Message-ID: <20010521215339.A3847@gondor.apana.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 456 bytes --]
Here's a slightly different approach to the CRAMFS over RAM disk problem.
This patch (against 2.4) allows the RAM disk block size to be changed
through set_blocksize() without destroying its previous content. Comments
are welcome.
--
Debian GNU/Linux 2.2 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
[-- Attachment #2: p --]
[-- Type: text/plain, Size: 1796 bytes --]
diff -u -r1.1.1.5 -r1.5
--- drivers/block/rd.c 2001/02/09 19:30:22 1.1.1.5
+++ drivers/block/rd.c 2001/05/20 01:36:07 1.5
@@ -197,8 +198,11 @@
static int rd_make_request(request_queue_t * q, int rw, struct buffer_head *sbh)
{
unsigned int minor;
- unsigned long offset, len;
- struct buffer_head *rbh;
+ unsigned int hardsec;
+ unsigned int len;
+ unsigned int size;
+ unsigned long block;
+ unsigned long offset;
char *bdata;
@@ -221,20 +225,32 @@
goto fail;
}
- rbh = getblk(sbh->b_rdev, sbh->b_rsector/(sbh->b_size>>9), sbh->b_size);
+ hardsec = (unsigned int) rd_hardsec[minor];
+ block = offset / hardsec;
+ offset %= hardsec;
+ size = len <= hardsec ? len : hardsec;
+
/* I think that it is safe to assume that rbh is not in HighMem, though
* sbh might be - NeilBrown
*/
bdata = bh_kmap(sbh);
- if (rw == READ) {
- if (sbh != rbh)
- memcpy(bdata, rbh->b_data, rbh->b_size);
- } else
- if (sbh != rbh)
- memcpy(rbh->b_data, bdata, rbh->b_size);
+ do {
+ struct buffer_head *rbh;
+
+ rbh = getblk(sbh->b_rdev, block, hardsec);
+ if (sbh != rbh) {
+ if (rw == READ)
+ memcpy(bdata, rbh->b_data + offset, size);
+ else
+ memcpy(rbh->b_data + offset, bdata, size);
+ }
+ mark_buffer_protected(rbh);
+ brelse(rbh);
+ len -= size;
+ bdata += size;
+ block++;
+ } while (len > 0);
bh_kunmap(sbh);
- mark_buffer_protected(rbh);
- brelse(rbh);
sbh->b_end_io(sbh,1);
return 0;
diff -u -r1.1.1.10 -r1.2
--- fs/buffer.c 2001/04/27 21:23:25 1.1.1.10
+++ fs/buffer.c 2001/05/20 01:36:07 1.2
@@ -711,6 +711,8 @@
bh_next = bh->b_next_free;
if (bh->b_dev != dev || bh->b_size == size)
continue;
+ if (buffer_protected(bh))
+ continue;
if (buffer_locked(bh)) {
atomic_inc(&bh->b_count);
spin_unlock(&lru_list_lock);
reply other threads:[~2001-05-21 11:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20010521215339.A3847@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).