Skip to content

Commit

Permalink
block/iscsi: set max_transfer_length
Browse files Browse the repository at this point in the history
Copy the max_xfer_len from the BlockLimits VPD or use the
maximum value fitting in the CDB.

The helper function sector_limits_lun2qemu is introduced to convert
and cap the limits from the VPD to the maximum power of two fitting
in an integer; integer is the range for nb_sectors throughout
the block layer.

Signed-off-by: Peter Lieven <pl@kamp.de>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
plieven authored and stefanhaRH committed Nov 3, 2014
1 parent 2647fab commit 52f6fa1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions block/iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,12 +1447,25 @@ static void iscsi_close(BlockDriverState *bs)
memset(iscsilun, 0, sizeof(IscsiLun));
}

static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
static int sector_limits_lun2qemu(int64_t sector, IscsiLun *iscsilun)
{
IscsiLun *iscsilun = bs->opaque;
return MIN(sector_lun2qemu(sector, iscsilun), INT_MAX / 2 + 1);
}

static void iscsi_refresh_limits(BlockDriverState *bs, Error **errp)
{
/* We don't actually refresh here, but just return data queried in
* iscsi_open(): iscsi targets don't change their limits. */

IscsiLun *iscsilun = bs->opaque;
uint32_t max_xfer_len = iscsilun->use_16_for_rw ? 0xffffffff : 0xffff;

if (iscsilun->bl.max_xfer_len) {
max_xfer_len = MIN(max_xfer_len, iscsilun->bl.max_xfer_len);
}

bs->bl.max_transfer_length = sector_limits_lun2qemu(max_xfer_len, iscsilun);

if (iscsilun->lbp.lbpu) {
if (iscsilun->bl.max_unmap < 0xffffffff) {
bs->bl.max_discard = sector_lun2qemu(iscsilun->bl.max_unmap,
Expand Down

0 comments on commit 52f6fa1

Please sign in to comment.