From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 45/55] scsi-disk: remove cluster_size
Date: Mon, 31 Oct 2011 14:30:20 +0100 [thread overview]
Message-ID: <1320067830-12093-46-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1320067830-12093-1-git-send-email-kwolf@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
This field is redundant, and having it makes it more complicated
to share reqops between the upcoming scsi-block and scsi-generic.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/scsi-disk.c | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 8a05031..f89e6c5 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -65,9 +65,6 @@ typedef struct SCSIDiskReq {
struct SCSIDiskState
{
SCSIDevice qdev;
- /* The qemu block layer uses a fixed 512 byte sector size.
- This is the number of 512 byte blocks in a single scsi sector. */
- int cluster_size;
uint32_t removable;
uint64_t max_lba;
bool media_changed;
@@ -854,7 +851,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
bdrv_get_geometry_hint(bdrv, &cylinders, &heads, &secs);
p[4] = heads & 0xff;
p[5] = secs & 0xff;
- p[6] = s->cluster_size * 2;
+ p[6] = s->qdev.blocksize >> 8;
p[8] = (cylinders >> 8) & 0xff;
p[9] = cylinders & 0xff;
/* Write precomp start cylinder, disabled */
@@ -983,7 +980,7 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf)
} else { /* MODE_SENSE_10 */
outbuf[7] = 8; /* Block descriptor length */
}
- nb_sectors /= s->cluster_size;
+ nb_sectors /= (s->qdev.blocksize / 512);
if (nb_sectors > 0xffffff) {
nb_sectors = 0;
}
@@ -993,7 +990,7 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf)
p[3] = nb_sectors & 0xff;
p[4] = 0; /* reserved */
p[5] = 0; /* bytes 5-7 are the sector size in bytes */
- p[6] = s->cluster_size * 2;
+ p[6] = s->qdev.blocksize >> 8;
p[7] = 0;
p += 8;
}
@@ -1044,7 +1041,7 @@ static int scsi_disk_emulate_read_toc(SCSIRequest *req, uint8_t *outbuf)
start_track = req->cmd.buf[6];
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1);
- nb_sectors /= s->cluster_size;
+ nb_sectors /= s->qdev.blocksize / 512;
switch (format) {
case 0:
toclen = cdrom_read_toc(nb_sectors, outbuf, msf, start_track);
@@ -1179,7 +1176,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
if ((req->cmd.buf[8] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
}
- nb_sectors /= s->cluster_size;
+ nb_sectors /= s->qdev.blocksize / 512;
/* Returned value is the address of the last sector. */
nb_sectors--;
/* Remember the new size for read/write sanity checking. */
@@ -1194,7 +1191,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
outbuf[3] = nb_sectors & 0xff;
outbuf[4] = 0;
outbuf[5] = 0;
- outbuf[6] = s->cluster_size * 2;
+ outbuf[6] = s->qdev.blocksize >> 8;
outbuf[7] = 0;
buflen = 8;
break;
@@ -1234,7 +1231,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
if ((req->cmd.buf[14] & 1) == 0 && req->cmd.lba) {
goto illegal_request;
}
- nb_sectors /= s->cluster_size;
+ nb_sectors /= s->qdev.blocksize / 512;
/* Returned value is the address of the last sector. */
nb_sectors--;
/* Remember the new size for read/write sanity checking. */
@@ -1249,7 +1246,7 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
outbuf[7] = nb_sectors & 0xff;
outbuf[8] = 0;
outbuf[9] = 0;
- outbuf[10] = s->cluster_size * 2;
+ outbuf[10] = s->qdev.blocksize >> 8;
outbuf[11] = 0;
outbuf[12] = 0;
outbuf[13] = get_physical_block_exp(&s->qdev.conf);
@@ -1356,8 +1353,8 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
if (r->req.cmd.lba > s->max_lba) {
goto illegal_lba;
}
- r->sector = r->req.cmd.lba * s->cluster_size;
- r->sector_count = len * s->cluster_size;
+ r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512);
+ r->sector_count = len * (s->qdev.blocksize / 512);
break;
case WRITE_6:
case WRITE_10:
@@ -1373,8 +1370,8 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
if (r->req.cmd.lba > s->max_lba) {
goto illegal_lba;
}
- r->sector = r->req.cmd.lba * s->cluster_size;
- r->sector_count = len * s->cluster_size;
+ r->sector = r->req.cmd.lba * (s->qdev.blocksize / 512);
+ r->sector_count = len * (s->qdev.blocksize / 512);
break;
case MODE_SELECT:
DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer);
@@ -1417,8 +1414,9 @@ static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf)
goto fail;
}
- rc = bdrv_discard(s->qdev.conf.bs, r->req.cmd.lba * s->cluster_size,
- len * s->cluster_size);
+ rc = bdrv_discard(s->qdev.conf.bs,
+ r->req.cmd.lba * (s->qdev.blocksize / 512),
+ len * (s->qdev.blocksize / 512));
if (rc < 0) {
/* XXX: better error code ?*/
goto fail;
@@ -1460,7 +1458,7 @@ static void scsi_disk_reset(DeviceState *dev)
scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET));
bdrv_get_geometry(s->qdev.conf.bs, &nb_sectors);
- nb_sectors /= s->cluster_size;
+ nb_sectors /= s->qdev.blocksize / 512;
if (nb_sectors) {
nb_sectors--;
}
@@ -1561,7 +1559,6 @@ static int scsi_initfn(SCSIDevice *dev, uint8_t scsi_type)
error_report("scsi-disk: Unhandled SCSI type %02x", scsi_type);
return -1;
}
- s->cluster_size = s->qdev.blocksize / 512;
bdrv_set_buffer_alignment(s->qdev.conf.bs, s->qdev.blocksize);
s->qdev.type = scsi_type;
--
1.7.6.4
next prev parent reply other threads:[~2011-10-31 13:28 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-31 13:29 [Qemu-devel] [PULL 00/55] Block patches Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 01/55] iSCSI block driver Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 02/55] Documentation: Add iSCSI section Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 03/55] Teach block/vdi about "discarded" (no longer allocated) blocks Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 04/55] qcow2: fix some errors and typo in qcow2.txt Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 05/55] block: Remove dead code Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 06/55] block: Fix bdrv_open use after free Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 07/55] qcow: Fix bdrv_write_compressed error handling Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 08/55] ide: Fix off-by-one error in array index check Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 09/55] vmdk: Fix use of uninitialised value Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 10/55] vmdk: Improve error handling Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 11/55] vmdk: Fix possible segfaults Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 12/55] Documentation: Describe NBD URL syntax Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 13/55] block: fix qcow2_co_flush deadlock Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 14/55] qemu-io: delete bs instead of leaking it Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 15/55] block: set bs->read_only before .bdrv_open() Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 16/55] block: reinitialize across bdrv_close()/bdrv_open() Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 17/55] Documentation: Add syntax for using sheepdog devices Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 18/55] scsi: pass correct sense code for ENOMEDIUM Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 19/55] atapi/scsi: unify definitions for MMC Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 20/55] atapi: move GESN definitions to scsi-defs.h Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 21/55] atapi: cleanup/fix mode sense results Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 22/55] scsi: notify the device when unit attention is reported Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 23/55] scsi-disk: report media changed via unit attention sense codes Kevin Wolf
2011-10-31 13:29 ` [Qemu-devel] [PATCH 24/55] scsi-disk: fix coding style issues (braces) Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 25/55] scsi-disk: add stubs for more MMC commands Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 26/55] scsi-disk: store valid mode pages in a table Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 27/55] atapi/scsi-disk: make mode page values coherent between the two Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 28/55] scsi-disk: support DVD profile in GET CONFIGURATION Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 29/55] scsi-disk: support READ DVD STRUCTURE Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 30/55] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 31/55] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo) Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 32/55] qdev: switch children device list to QTAILQ Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 33/55] scsi: remove devs array from SCSIBus Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 34/55] scsi: implement REPORT LUNS for arbitrary LUNs Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 35/55] scsi: allow " Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 36/55] scsi: add channel to addressing Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 37/55] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0 Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 38/55] scsi-disk: fix retrying a flush Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 39/55] scsi-generic: drop SCSIGenericState Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 40/55] scsi-generic: remove scsi_req_fixup Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 41/55] scsi-generic: check ioctl statuses when SG_IO succeeds Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 42/55] scsi-generic: look at host status Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 43/55] scsi-generic: snoop READ CAPACITY commands to get block size Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 44/55] scsi-disk: do not duplicate BlockDriverState member Kevin Wolf
2011-10-31 13:30 ` Kevin Wolf [this message]
2011-10-31 13:30 ` [Qemu-devel] [PATCH 46/55] scsi-disk: small clean up to INQUIRY Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 47/55] scsi: move max_lba to SCSIDevice Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 48/55] scsi: make reqops const Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 49/55] scsi: export scsi_generic_reqops Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 50/55] scsi: pass cdb to alloc_req Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 51/55] scsi: do not call transfer_data after canceling a request Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 52/55] scsi-disk: bump SCSIRequest reference count until aio completion runs Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 53/55] scsi-generic: " Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 54/55] scsi: push request restart to SCSIDevice Kevin Wolf
2011-10-31 13:30 ` [Qemu-devel] [PATCH 55/55] scsi-disk: add scsi-block for device passthrough Kevin Wolf
2011-10-31 16:52 ` [Qemu-devel] [PULL 00/55] Block patches Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1320067830-12093-46-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).