Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105768
b: refs/heads/master
c: 066f4d8
h: refs/heads/master
v: v3
  • Loading branch information
Christian Borntraeger authored and Rusty Russell committed Jul 25, 2008
1 parent 8ad4822 commit ba6c542
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e962fa660d391fc9b90988e6538c94c858c099f9
refs/heads/master: 066f4d82a67f621ddd547bfa4b9c94631d8457b0
10 changes: 9 additions & 1 deletion trunk/drivers/block/virtio_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ static int virtblk_probe(struct virtio_device *vdev)
int err;
u64 cap;
u32 v;
u32 blk_size;

if (index_to_minor(index) >= 1 << MINORBITS)
return -ENOSPC;
Expand Down Expand Up @@ -290,6 +291,13 @@ static int virtblk_probe(struct virtio_device *vdev)
if (!err)
blk_queue_max_hw_segments(vblk->disk->queue, v);

/* Host can optionally specify the block size of the device */
err = virtio_config_val(vdev, VIRTIO_BLK_F_BLK_SIZE,
offsetof(struct virtio_blk_config, blk_size),
&blk_size);
if (!err)
blk_queue_hardsect_size(vblk->disk->queue, blk_size);

add_disk(vblk->disk);
return 0;

Expand Down Expand Up @@ -330,7 +338,7 @@ static struct virtio_device_id id_table[] = {

static unsigned int features[] = {
VIRTIO_BLK_F_BARRIER, VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO,
VIRTIO_BLK_F_GEOMETRY, VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE,
};

static struct virtio_driver virtio_blk = {
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/virtio_blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
#define VIRTIO_BLK_F_GEOMETRY 4 /* Legacy geometry available */
#define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
#define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/

struct virtio_blk_config
{
Expand All @@ -28,6 +29,8 @@ struct virtio_blk_config
__u8 heads;
__u8 sectors;
} geometry;
/* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */
__u32 blk_size;
} __attribute__((packed));

/* These two define direction. */
Expand Down

0 comments on commit ba6c542

Please sign in to comment.