block: pass block dev not num to read/write/erase()
This will allow the implementation to make use of data in the block_dev structure beyond the base device number. This will be useful so that eMMC block devices can encompass the HW partition ID rather than treating this out-of-band. Equally, the existence of the priv field is crying out for this patch to exist. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
@@ -76,10 +76,10 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
|
||||
if (byte_offset != 0) {
|
||||
int readlen;
|
||||
/* read first part which isn't aligned with start of sector */
|
||||
if (ext4fs_block_dev_desc->
|
||||
block_read(ext4fs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *) sec_buf) != 1) {
|
||||
if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
1, (void *)sec_buf)
|
||||
!= 1) {
|
||||
printf(" ** ext2fs_devread() read error **\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -101,18 +101,18 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
|
||||
ALLOC_CACHE_ALIGN_BUFFER(u8, p, ext4fs_block_dev_desc->blksz);
|
||||
|
||||
block_len = ext4fs_block_dev_desc->blksz;
|
||||
ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
|
||||
ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
1, (unsigned long *)p);
|
||||
1, (void *)p);
|
||||
memcpy(buf, p, byte_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
|
||||
part_info->start + sector,
|
||||
block_len >> log2blksz,
|
||||
(unsigned long *) buf) !=
|
||||
block_len >> log2blksz) {
|
||||
if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
block_len >> log2blksz,
|
||||
(void *)buf) !=
|
||||
block_len >> log2blksz) {
|
||||
printf(" ** %s read error - block\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
@@ -123,10 +123,10 @@ int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
if (byte_len != 0) {
|
||||
/* read rest of data which are not in whole sector */
|
||||
if (ext4fs_block_dev_desc->
|
||||
block_read(ext4fs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *) sec_buf) != 1) {
|
||||
if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
1, (void *)sec_buf)
|
||||
!= 1) {
|
||||
printf("* %s read error - last part\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,26 +82,26 @@ void put_ext4(uint64_t off, void *buf, uint32_t size)
|
||||
|
||||
if (remainder) {
|
||||
if (fs->dev_desc->block_read) {
|
||||
fs->dev_desc->block_read(fs->dev_desc->dev,
|
||||
fs->dev_desc->block_read(fs->dev_desc,
|
||||
startblock, 1, sec_buf);
|
||||
temp_ptr = sec_buf;
|
||||
memcpy((temp_ptr + remainder),
|
||||
(unsigned char *)buf, size);
|
||||
fs->dev_desc->block_write(fs->dev_desc->dev,
|
||||
fs->dev_desc->block_write(fs->dev_desc,
|
||||
startblock, 1, sec_buf);
|
||||
}
|
||||
} else {
|
||||
if (size >> log2blksz != 0) {
|
||||
fs->dev_desc->block_write(fs->dev_desc->dev,
|
||||
fs->dev_desc->block_write(fs->dev_desc,
|
||||
startblock,
|
||||
size >> log2blksz,
|
||||
(unsigned long *)buf);
|
||||
} else {
|
||||
fs->dev_desc->block_read(fs->dev_desc->dev,
|
||||
fs->dev_desc->block_read(fs->dev_desc,
|
||||
startblock, 1, sec_buf);
|
||||
temp_ptr = sec_buf;
|
||||
memcpy(temp_ptr, buf, size);
|
||||
fs->dev_desc->block_write(fs->dev_desc->dev,
|
||||
fs->dev_desc->block_write(fs->dev_desc,
|
||||
startblock, 1,
|
||||
(unsigned long *)sec_buf);
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
|
||||
if (!cur_dev || !cur_dev->block_read)
|
||||
return -1;
|
||||
|
||||
ret = cur_dev->block_read(cur_dev->dev,
|
||||
cur_part_info.start + block, nr_blocks, buf);
|
||||
ret = cur_dev->block_read(cur_dev, cur_part_info.start + block,
|
||||
nr_blocks, buf);
|
||||
|
||||
if (nr_blocks && ret == 0)
|
||||
return -1;
|
||||
|
||||
@@ -41,8 +41,7 @@ static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = cur_dev->block_write(cur_dev->dev,
|
||||
cur_part_info.start + block,
|
||||
ret = cur_dev->block_write(cur_dev, cur_part_info.start + block,
|
||||
nr_blocks, buf);
|
||||
if (nr_blocks && ret == 0)
|
||||
return -1;
|
||||
|
||||
@@ -59,9 +59,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
if (byte_offset != 0) {
|
||||
/* read first part which isn't aligned with start of sector */
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *)sec_buf) != 1) {
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
|
||||
part_info->start +
|
||||
sector,
|
||||
1, (void *)sec_buf)
|
||||
!= 1) {
|
||||
printf (" ** reiserfs_devread() read error\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -73,9 +75,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
/* read sector aligned part */
|
||||
block_len = byte_len & ~(SECTOR_SIZE-1);
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
|
||||
part_info->start + sector, block_len/SECTOR_SIZE,
|
||||
(unsigned long *)buf) != block_len/SECTOR_SIZE) {
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
block_len / SECTOR_SIZE,
|
||||
(void *)buf)
|
||||
!= block_len/SECTOR_SIZE) {
|
||||
printf (" ** reiserfs_devread() read error - block\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -85,9 +89,11 @@ int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
if ( byte_len != 0 ) {
|
||||
/* read rest of data which are not in whole sector */
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *)sec_buf) != 1) {
|
||||
if (reiserfs_block_dev_desc->block_read(reiserfs_block_dev_desc,
|
||||
part_info->start +
|
||||
sector,
|
||||
1, (void *)sec_buf)
|
||||
!= 1) {
|
||||
printf (" ** reiserfs_devread() read error - last part\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
28
fs/zfs/dev.c
28
fs/zfs/dev.c
@@ -55,9 +55,10 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
if (byte_offset != 0) {
|
||||
/* read first part which isn't aligned with start of sector */
|
||||
if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *)sec_buf) != 1) {
|
||||
if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
|
||||
part_info->start + sector, 1,
|
||||
(void *)sec_buf)
|
||||
!= 1) {
|
||||
printf(" ** zfs_devread() read error **\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -78,16 +79,18 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
|
||||
u8 p[SECTOR_SIZE];
|
||||
|
||||
block_len = SECTOR_SIZE;
|
||||
zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
|
||||
part_info->start + sector,
|
||||
1, (unsigned long *)p);
|
||||
zfs_block_dev_desc->block_read(zfs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
1, (void *)p);
|
||||
memcpy(buf, p, byte_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (zfs_block_dev_desc->block_read(zfs_block_dev_desc->dev,
|
||||
part_info->start + sector, block_len / SECTOR_SIZE,
|
||||
(unsigned long *) buf) != block_len / SECTOR_SIZE) {
|
||||
if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
block_len / SECTOR_SIZE,
|
||||
(void *)buf)
|
||||
!= block_len / SECTOR_SIZE) {
|
||||
printf(" ** zfs_devread() read error - block\n");
|
||||
return 1;
|
||||
}
|
||||
@@ -99,10 +102,9 @@ int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)
|
||||
|
||||
if (byte_len != 0) {
|
||||
/* read rest of data which are not in whole sector */
|
||||
if (zfs_block_dev_desc->
|
||||
block_read(zfs_block_dev_desc->dev,
|
||||
part_info->start + sector, 1,
|
||||
(unsigned long *) sec_buf) != 1) {
|
||||
if (zfs_block_dev_desc->block_read(zfs_block_dev_desc,
|
||||
part_info->start + sector,
|
||||
1, (void *)sec_buf) != 1) {
|
||||
printf(" ** zfs_devread() read error - last part\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user