[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 39/39] block/iscsi: handle failure on malloc of the a
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 39/39] block/iscsi: handle failure on malloc of the allocationmap |
Date: |
Tue, 30 Sep 2014 14:25:19 +0200 |
From: Peter Lieven <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/iscsi.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/block/iscsi.c b/block/iscsi.c
index 3c1b416..26bded3 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -317,6 +317,13 @@ static bool is_request_lun_aligned(int64_t sector_num, int
nb_sectors,
return 1;
}
+static unsigned long *iscsi_allocationmap_init(IscsiLun *iscsilun)
+{
+ return bitmap_try_new(DIV_ROUND_UP(sector_lun2qemu(iscsilun->num_blocks,
+ iscsilun),
+ iscsilun->cluster_sectors));
+}
+
static void iscsi_allocationmap_set(IscsiLun *iscsilun, int64_t sector_num,
int nb_sectors)
{
@@ -1403,9 +1410,10 @@ static int iscsi_open(BlockDriverState *bs, QDict
*options, int flags,
iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran *
iscsilun->block_size) >> BDRV_SECTOR_BITS;
if (iscsilun->lbprz && !(bs->open_flags & BDRV_O_NOCACHE)) {
- iscsilun->allocationmap =
- bitmap_new(DIV_ROUND_UP(bs->total_sectors,
- iscsilun->cluster_sectors));
+ iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
+ if (iscsilun->allocationmap == NULL) {
+ ret = -ENOMEM;
+ }
}
}
@@ -1498,10 +1506,7 @@ static int iscsi_truncate(BlockDriverState *bs, int64_t
offset)
if (iscsilun->allocationmap != NULL) {
g_free(iscsilun->allocationmap);
- iscsilun->allocationmap =
- bitmap_new(DIV_ROUND_UP(sector_lun2qemu(iscsilun->num_blocks,
- iscsilun),
- iscsilun->cluster_sectors));
+ iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun);
}
return 0;
--
1.8.3.1
- [Qemu-devel] [PULL 27/39] virtio-scsi: Two stages processing of cmd request, (continued)
- [Qemu-devel] [PULL 27/39] virtio-scsi: Two stages processing of cmd request, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 28/39] virtio-scsi: Batched prepare for cmd reqs, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 29/39] virtio-scsi: Call bdrv_io_plug/bdrv_io_unplug in cmd request handling, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 30/39] virtio-scsi: Process ".iothread" property, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 31/39] scsi: Drop scsi_req_abort, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 33/39] scsi: Unify request unref in scsi_req_cancel, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 32/39] scsi-generic: Handle canceled request in scsi_command_complete, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 34/39] scsi: Drop SCSIReqOps.cancel_io, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 35/39] scsi: Introduce scsi_req_cancel_complete, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 38/39] util: introduce bitmap_try_new, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 39/39] block/iscsi: handle failure on malloc of the allocationmap,
Paolo Bonzini <=
- [Qemu-devel] [PULL 36/39] scsi: Introduce scsi_req_cancel_async, Paolo Bonzini, 2014/09/30
- [Qemu-devel] [PULL 37/39] virtio-scsi: Handle TMF request cancellation asynchronously, Paolo Bonzini, 2014/09/30
- Re: [Qemu-devel] [PULL 00/39] SCSI changes for 2014-09-23, Peter Maydell, 2014/09/30