patch-2.0.30 linux/fs/block_dev.c
Next file: linux/fs/buffer.c
Previous file: linux/drivers/scsi/u14-34f.h
Back to the patch index
Back to the overall index
- Lines: 140
- Date:
Tue Mar 11 14:35:16 1997
- Orig file:
v2.0.29/linux/fs/block_dev.c
- Orig date:
Mon May 6 02:26:13 1996
diff -u --recursive --new-file v2.0.29/linux/fs/block_dev.c linux/fs/block_dev.c
@@ -20,21 +20,19 @@
#define MAX_BUF_PER_PAGE (PAGE_SIZE / 512)
#define NBUF 64
-int block_write(struct inode * inode, struct file * filp, const char * buf, int count)
+int block_write(struct inode * inode, struct file * filp,
+ const char * buf, int count)
{
- int blocksize, blocksize_bits, i, j, buffercount,write_error;
+ int blocksize, blocksize_bits, i, buffercount,write_error;
int block, blocks;
loff_t offset;
int chars;
int written = 0;
- int cluster_list[MAX_BUF_PER_PAGE];
struct buffer_head * bhlist[NBUF];
- int blocks_per_cluster;
unsigned int size;
kdev_t dev;
struct buffer_head * bh, *bufferlist[NBUF];
register char * p;
- int excess;
write_error = buffercount = 0;
dev = inode->i_rdev;
@@ -51,8 +49,6 @@
i >>= 1;
}
- blocks_per_cluster = PAGE_SIZE / blocksize;
-
block = filp->f_pos >> blocksize_bits;
offset = filp->f_pos & (blocksize-1);
@@ -68,15 +64,14 @@
chars=count;
#if 0
- if (chars == blocksize)
- bh = getblk(dev, block, blocksize);
- else
- bh = breada(dev,block,block+1,block+2,-1);
-
+ /* get the buffer head */
+ {
+ struct buffer_head * (*fn)(kdev_t, int, int) = getblk;
+ if (chars != blocksize)
+ fn = bread;
+ bh = fn(dev, block, blocksize);
+ }
#else
- for(i=0; i<blocks_per_cluster; i++) cluster_list[i] = block+i;
- if((block % blocks_per_cluster) == 0)
- generate_cluster(dev, cluster_list, blocksize);
bh = getblk(dev, block, blocksize);
if (chars != blocksize && !buffer_uptodate(bh)) {
@@ -90,15 +85,8 @@
blocks = read_ahead[MAJOR(dev)] / (blocksize >> 9) / 2;
if (block + blocks > size) blocks = size - block;
if (blocks > NBUF) blocks=NBUF;
- excess = (block + blocks) % blocks_per_cluster;
- if ( blocks > excess )
- blocks -= excess;
bhlist[0] = bh;
for(i=1; i<blocks; i++){
- if(((i+block) % blocks_per_cluster) == 0) {
- for(j=0; j<blocks_per_cluster; j++) cluster_list[j] = block+i+j;
- generate_cluster(dev, cluster_list, blocksize);
- };
bhlist[i] = getblk (dev, block+i, blocksize);
if(!bhlist[i]){
while(i >= 0) brelse(bhlist[i--]);
@@ -157,7 +145,8 @@
return written;
}
-int block_read(struct inode * inode, struct file * filp, char * buf, int count)
+int block_read(struct inode * inode, struct file * filp,
+ char * buf, int count)
{
unsigned int block;
loff_t offset;
@@ -165,8 +154,6 @@
int blocksize_bits, i;
unsigned int blocks, rblocks, left;
int bhrequest, uptodate;
- int cluster_list[MAX_BUF_PER_PAGE];
- int blocks_per_cluster;
struct buffer_head ** bhb, ** bhe;
struct buffer_head * buflist[NBUF];
struct buffer_head * bhreq[NBUF];
@@ -174,7 +161,6 @@
loff_t size;
kdev_t dev;
int read;
- int excess;
dev = inode->i_rdev;
blocksize = BLOCK_SIZE;
@@ -193,8 +179,6 @@
else
size = INT_MAX;
- blocks_per_cluster = PAGE_SIZE / blocksize;
-
if (offset > size)
left = 0;
/* size - offset might not fit into left, so check explicitly. */
@@ -215,9 +199,6 @@
if (filp->f_reada) {
if (blocks < read_ahead[MAJOR(dev)] / (blocksize >> 9))
blocks = read_ahead[MAJOR(dev)] / (blocksize >> 9);
- excess = (block + blocks) % blocks_per_cluster;
- if ( blocks > excess )
- blocks -= excess;
if (rblocks > blocks)
blocks = rblocks;
@@ -240,12 +221,6 @@
uptodate = 1;
while (blocks) {
--blocks;
-#if 1
- if((block % blocks_per_cluster) == 0) {
- for(i=0; i<blocks_per_cluster; i++) cluster_list[i] = block+i;
- generate_cluster(dev, cluster_list, blocksize);
- }
-#endif
*bhb = getblk(dev, block++, blocksize);
if (*bhb && !buffer_uptodate(*bhb)) {
uptodate = 0;
@@ -266,7 +241,6 @@
/* Now request them all */
if (bhrequest) {
ll_rw_block(READ, bhrequest, bhreq);
- refill_freelist(blocksize);
}
do { /* Finish off all I/O that has actually completed */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov