Messages in this thread Patch in this message | | | Date | Mon, 27 Dec 1999 22:52:23 -0800 | From | "B. D. Elliott" <> | Subject | REPOST: Some Cleanup Fixes for the Ramdisk Stuff |
| |
Sorry if you have seen this before -- I haven't seen it from linux-kernel, so I assume it went into a black hole somewhere.
The attached patch makes some mostly cosmetic corrections to the recent ramdisk patch. This is against pre-2.3.35-4, although it should be the same against pre-2.3.35-6.
1. Clean up the commentary somewhat.
2. Remove two non-zero values from memset() calls that were there for debugging.
3. In the case of no buffers available, return a failure reply to the caller, rather than performing a BUG() call. This doesn't change anything as far as out-of-memory conditions are concerned; only the reporting.
===================================================================== --- linux/drivers/block/rd.c.orig Sun Dec 26 20:58:01 1999 +++ linux/drivers/block/rd.c Sun Dec 26 21:06:10 1999 @@ -217,24 +217,23 @@ } /* - * This has become somewhat more complicated with the addition of - * the page cache. The problem is that in some cases the furnished + * There is a problem here in that in some cases the furnished * buffer is "real", i.e., part of the existing ramdisk, while in * others it is "unreal", e.g., part of a page. In the first case * not much needs to be done, while in the second, some kind of * transfer is needed. * - * The two cases are distinguished here by checking whether the - * real buffer is already in the buffer cache, and whether it is - * the same as the one supplied. + * The two cases are distinguished by checking whether the real + * buffer is already in the buffer cache, and whether it matches + * the one supplied. * * There are three cases with read/write to consider: * - * 1. Supplied buffer matched one in the buffer cache: - * Read - Clear the buffer, as it wasn't already valid. + * 1. Supplied buffer matched the one in the buffer cache: + * Read - Clear the buffer, as it wasn't previously valid. * Write - Mark the buffer as "Protected". * - * 2. Supplied buffer mismatched one in the buffer cache: + * 2. Supplied buffer mismatched the one in the buffer cache: * Read - Copy the data from the buffer cache entry. * Write - Copy the data to the buffer cache entry. * @@ -243,19 +242,13 @@ * one. * Write - Create a real buffer, copy the data to it, and mark * it as "Protected". - * - * NOTE: There seems to be some schizophrenia here - the logic - * using "len" seems to assume arbitrary request lengths, while - * the "protect" logic assumes a single buffer cache entry. - * This seems to be left over from the ancient contiguous ramdisk - * logic. */ sbh = CURRENT->bh; rbh = get_hash_table(sbh->b_dev, sbh->b_blocknr, sbh->b_size); if (sbh == rbh) { if (CURRENT->cmd == READ) - memset(CURRENT->buffer, 1, len); + memset(CURRENT->buffer, 0, len); } else if (rbh) { if (CURRENT->cmd == READ) memcpy(CURRENT->buffer, rbh->b_data, rbh->b_size); @@ -263,14 +256,18 @@ memcpy(rbh->b_data, CURRENT->buffer, rbh->b_size); } else { /* !rbh */ if (CURRENT->cmd == READ) - memset(sbh->b_data, 2, len); + memset(sbh->b_data, 0, len); else { rbh = getblk(sbh->b_dev, sbh->b_blocknr, sbh->b_size); if (rbh) memcpy(rbh->b_data, CURRENT->buffer, rbh->b_size); - else - BUG(); /* No buffer, what to do here? */ + else { + printk(KERN_ERR "RAMDISK: " + "could not allocate buffer\n"); + end_request(0); + goto repeat; + } } } if (rbh) { ===================================================================== -- B. D. Elliott bde@nwlink.com (Seattle) - 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/
| |