PATCH 2.4.4 some fixes for the usage of blksize_size and others

2001-04-30 Thread Martin Dalecki

The attached patch does the following:

1. Streamlining the usage of the blksize_size[] array by 
introducing a function get_blksize_size(),
similiar in spirit to get_hardsect_size().
It's all inline, so no API will change.

2. Clarification of comments about the underlying arrays in ll_rw_blk.c

3. Removal of functions, which where already serving precisely the same
purpose as get_blksize_size(). Those where:

loop_get_bs(), lvm_get_blksize() and device_bsize() in raid code.

4. Fixing a thinko in actual raw.c device code. The code there had
serious chances to interferre with already mounted filesystems.

5. Fixing the reiserfs to user get_hardsect_size() as the measure for
minimal
block size allowed for the access to a particular device, in the same
way
*ALL* other filesystems already do, instead of looking at the 
blksize_size[], which is only giving the most desirable chunk 
size for access to the FS iff set before, which isn't allways the case.

6. Spotting an abuse inside of the LVM header, introduced by the AS/390
people,
which seem to be the most confused about the difference between
blksize_size 
and hardsect_size anyway.

7. Well, adding some misspellings and bad english grammar to the
kernel's
comments...

I have added my personal tag, where I think someone looking at
the code could need some possible contact for further hand-holding.

Please apply, it's all for the better :-).

diff -urN linux/drivers/block/ll_rw_blk.c new/drivers/block/ll_rw_blk.c
--- linux/drivers/block/ll_rw_blk.c Thu Apr 12 21:15:52 2001
+++ new/drivers/block/ll_rw_blk.c   Mon Apr 30 23:16:03 2001
@@ -85,25 +85,21 @@
 int * blk_size[MAX_BLKDEV];
 
 /*
- * blksize_size contains the size of all block-devices:
+ * blksize_size contains the block size of all block-devices:
  *
  * blksize_size[MAJOR][MINOR]
  *
- * if (!blksize_size[MAJOR]) then 1024 bytes is assumed.
+ * Access to this array should happen through the get_blksize_size() function.
+ * If (!blksize_size[MAJOR]) then 1024 bytes is assumed.
  */
 int * blksize_size[MAX_BLKDEV];
 
 /*
  * hardsect_size contains the size of the hardware sector of a device.
  *
- * hardsect_size[MAJOR][MINOR]
- *
- * if (!hardsect_size[MAJOR])
- * then 512 bytes is assumed.
- * else
- * sector_size is hardsect_size[MAJOR][MINOR]
- * This is currently set by some scsi devices and read by the msdos fs driver.
- * Other uses may appear later.
+ * Access to this array should happen through the get_hardsect_size() function.
+ * The default value is assumed to be 512 unless specified differently by the
+ * corresponding low-level driver.
  */
 int * hardsect_size[MAX_BLKDEV];
 
@@ -992,22 +988,14 @@
 
 void ll_rw_block(int rw, int nr, struct buffer_head * bhs[])
 {
-   unsigned int major;
-   int correct_size;
+   ssize_t correct_size;
int i;
 
if (!nr)
return;
 
-   major = MAJOR(bhs[0]->b_dev);
-
/* Determine correct block size for this device. */
-   correct_size = BLOCK_SIZE;
-   if (blksize_size[major]) {
-   i = blksize_size[major][MINOR(bhs[0]->b_dev)];
-   if (i)
-   correct_size = i;
-   }
+   correct_size = get_blksize_size(bhs[0]->b_dev);
 
/* Verify requested block sizes. */
for (i = 0; i < nr; i++) {
diff -urN linux/drivers/block/loop.c new/drivers/block/loop.c
--- linux/drivers/block/loop.c  Thu Apr 12 04:05:14 2001
+++ new/drivers/block/loop.cMon Apr 30 23:30:17 2001
@@ -272,22 +272,10 @@
return desc.error;
 }
 
-static inline int loop_get_bs(struct loop_device *lo)
-{
-   int bs = 0;
-
-   if (blksize_size[MAJOR(lo->lo_device)])
-   bs = blksize_size[MAJOR(lo->lo_device)][MINOR(lo->lo_device)];
-   if (!bs)
-   bs = BLOCK_SIZE;
-
-   return bs;
-}
-
 static inline unsigned long loop_get_iv(struct loop_device *lo,
unsigned long sector)
 {
-   int bs = loop_get_bs(lo);
+   int bs = get_blksize_size(lo->lo_device);
unsigned long offset, IV;
 
IV = sector / (bs >> 9) + lo->lo_offset / bs;
@@ -306,9 +294,9 @@
pos = ((loff_t) bh->b_rsector << 9) + lo->lo_offset;
 
if (rw == WRITE)
-   ret = lo_send(lo, bh, loop_get_bs(lo), pos);
+   ret = lo_send(lo, bh, get_blksize_size(lo->lo_device), pos);
else
-   ret = lo_receive(lo, bh, loop_get_bs(lo), pos);
+   ret = lo_receive(lo, bh, get_blksize_size(lo->lo_device), pos);
 
return ret;
 }
@@ -650,12 +638,7 @@
lo->old_gfp_mask = inode->i_mapping->gfp_mask;
inode->i_mapping->gfp_mask = GFP_BUFFER;
 
-   bs = 0;
-   if (blksize_size[MAJOR(inode->i_rdev)])
-   bs = blksize_size[MAJOR(inode->i_rdev)][MINOR(inode->i_rdev)];
-   if (!bs)
-   bs = BLOCK_SIZE;
-
+   bs = get_blksize_size(inode->i_rdev);

PATCH 2.4.4 some fixes for the usage of blksize_size and others

2001-04-30 Thread Martin Dalecki

The attached patch does the following:

1. Streamlining the usage of the blksize_size[] array by 
introducing a function get_blksize_size(),
similiar in spirit to get_hardsect_size().
It's all inline, so no API will change.

2. Clarification of comments about the underlying arrays in ll_rw_blk.c

3. Removal of functions, which where already serving precisely the same
purpose as get_blksize_size(). Those where:

loop_get_bs(), lvm_get_blksize() and device_bsize() in raid code.

4. Fixing a thinko in actual raw.c device code. The code there had
serious chances to interferre with already mounted filesystems.

5. Fixing the reiserfs to user get_hardsect_size() as the measure for
minimal
block size allowed for the access to a particular device, in the same
way
*ALL* other filesystems already do, instead of looking at the 
blksize_size[], which is only giving the most desirable chunk 
size for access to the FS iff set before, which isn't allways the case.

6. Spotting an abuse inside of the LVM header, introduced by the AS/390
people,
which seem to be the most confused about the difference between
blksize_size 
and hardsect_size anyway.

7. Well, adding some misspellings and bad english grammar to the
kernel's
comments...

I have added my personal tag, where I think someone looking at
the code could need some possible contact for further hand-holding.

Please apply, it's all for the better :-).

diff -urN linux/drivers/block/ll_rw_blk.c new/drivers/block/ll_rw_blk.c
--- linux/drivers/block/ll_rw_blk.c Thu Apr 12 21:15:52 2001
+++ new/drivers/block/ll_rw_blk.c   Mon Apr 30 23:16:03 2001
@@ -85,25 +85,21 @@
 int * blk_size[MAX_BLKDEV];
 
 /*
- * blksize_size contains the size of all block-devices:
+ * blksize_size contains the block size of all block-devices:
  *
  * blksize_size[MAJOR][MINOR]
  *
- * if (!blksize_size[MAJOR]) then 1024 bytes is assumed.
+ * Access to this array should happen through the get_blksize_size() function.
+ * If (!blksize_size[MAJOR]) then 1024 bytes is assumed.
  */
 int * blksize_size[MAX_BLKDEV];
 
 /*
  * hardsect_size contains the size of the hardware sector of a device.
  *
- * hardsect_size[MAJOR][MINOR]
- *
- * if (!hardsect_size[MAJOR])
- * then 512 bytes is assumed.
- * else
- * sector_size is hardsect_size[MAJOR][MINOR]
- * This is currently set by some scsi devices and read by the msdos fs driver.
- * Other uses may appear later.
+ * Access to this array should happen through the get_hardsect_size() function.
+ * The default value is assumed to be 512 unless specified differently by the
+ * corresponding low-level driver.
  */
 int * hardsect_size[MAX_BLKDEV];
 
@@ -992,22 +988,14 @@
 
 void ll_rw_block(int rw, int nr, struct buffer_head * bhs[])
 {
-   unsigned int major;
-   int correct_size;
+   ssize_t correct_size;
int i;
 
if (!nr)
return;
 
-   major = MAJOR(bhs[0]-b_dev);
-
/* Determine correct block size for this device. */
-   correct_size = BLOCK_SIZE;
-   if (blksize_size[major]) {
-   i = blksize_size[major][MINOR(bhs[0]-b_dev)];
-   if (i)
-   correct_size = i;
-   }
+   correct_size = get_blksize_size(bhs[0]-b_dev);
 
/* Verify requested block sizes. */
for (i = 0; i  nr; i++) {
diff -urN linux/drivers/block/loop.c new/drivers/block/loop.c
--- linux/drivers/block/loop.c  Thu Apr 12 04:05:14 2001
+++ new/drivers/block/loop.cMon Apr 30 23:30:17 2001
@@ -272,22 +272,10 @@
return desc.error;
 }
 
-static inline int loop_get_bs(struct loop_device *lo)
-{
-   int bs = 0;
-
-   if (blksize_size[MAJOR(lo-lo_device)])
-   bs = blksize_size[MAJOR(lo-lo_device)][MINOR(lo-lo_device)];
-   if (!bs)
-   bs = BLOCK_SIZE;
-
-   return bs;
-}
-
 static inline unsigned long loop_get_iv(struct loop_device *lo,
unsigned long sector)
 {
-   int bs = loop_get_bs(lo);
+   int bs = get_blksize_size(lo-lo_device);
unsigned long offset, IV;
 
IV = sector / (bs  9) + lo-lo_offset / bs;
@@ -306,9 +294,9 @@
pos = ((loff_t) bh-b_rsector  9) + lo-lo_offset;
 
if (rw == WRITE)
-   ret = lo_send(lo, bh, loop_get_bs(lo), pos);
+   ret = lo_send(lo, bh, get_blksize_size(lo-lo_device), pos);
else
-   ret = lo_receive(lo, bh, loop_get_bs(lo), pos);
+   ret = lo_receive(lo, bh, get_blksize_size(lo-lo_device), pos);
 
return ret;
 }
@@ -650,12 +638,7 @@
lo-old_gfp_mask = inode-i_mapping-gfp_mask;
inode-i_mapping-gfp_mask = GFP_BUFFER;
 
-   bs = 0;
-   if (blksize_size[MAJOR(inode-i_rdev)])
-   bs = blksize_size[MAJOR(inode-i_rdev)][MINOR(inode-i_rdev)];
-   if (!bs)
-   bs = BLOCK_SIZE;
-
+   bs = get_blksize_size(inode-i_rdev);
set_blocksize(dev, bs);
 
lo-lo_bh