blkdev: allow for 16bit block counts
authorAlan Cox <alan@linux.intel.com>
Sun, 21 May 2017 21:16:41 +0000 (22:16 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 21 May 2017 21:16:41 +0000 (22:16 +0100)
On a 32bit system we can end up writing more than 256 blocks in a run when
we swap so blkdev needs to use 16bits for the block counter.

(We could make this a typedef for 8 v 16bit but it's not clear it matters
 enough)

Kernel/dev/blkdev.c
Kernel/dev/blkdev.h

index 74fc3a0..d78463d 100644 (file)
@@ -74,7 +74,8 @@ int blkdev_open(uint8_t minor, uint16_t flags)
 
 static int blkdev_transfer(uint8_t minor, uint8_t rawflag)
 {
-    uint8_t partition, n, count=0;
+    uint8_t partition, n;
+    uint16_t count = 0;
 
     /* we trust that blkdev_open() has already verified that this minor number is valid */
     blk_op.blkdev = &blkdev_table[minor >> 4];
index e709829..89c6320 100644 (file)
@@ -27,7 +27,7 @@ struct blkparam {
     uint8_t swap_page;                      /* page to pass to map_swap */
     blkdev_t *blkdev;                       /* active block device */
     uint32_t lba;                           /* LBA for first sectors to transfer */
-    uint8_t nblock;                         /* number of sectors to transfer */
+    uint16_t nblock;                        /* number of sectors to transfer */
     bool is_read;                           /* true: read sectors, false: write sectors */
 };
 /* macros that inline assembler code can use to access blkparam fields */