Revision a32ef786

b/block-qcow2.c
1177 1177
    qcow_aio_read_cb(opaque, 0);
1178 1178
}
1179 1179

  
1180
static int qcow_schedule_bh(QEMUBHFunc *cb, QCowAIOCB *acb)
1181
{
1182
    if (acb->bh)
1183
        return -EIO;
1184

  
1185
    acb->bh = qemu_bh_new(cb, acb);
1186
    if (!acb->bh)
1187
        return -EIO;
1188

  
1189
    qemu_bh_schedule(acb->bh);
1190

  
1191
    return 0;
1192
}
1193

  
1180 1194
static void qcow_aio_read_cb(void *opaque, int ret)
1181 1195
{
1182 1196
    QCowAIOCB *acb = opaque;
......
1232 1246
                if (acb->hd_aiocb == NULL)
1233 1247
                    goto fail;
1234 1248
            } else {
1235
                if (acb->bh) {
1236
                    ret = -EIO;
1237
                    goto fail;
1238
                }
1239
                acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
1240
                if (!acb->bh) {
1241
                    ret = -EIO;
1249
                ret = qcow_schedule_bh(qcow_aio_read_bh, acb);
1250
                if (ret < 0)
1242 1251
                    goto fail;
1243
                }
1244
                qemu_bh_schedule(acb->bh);
1245 1252
            }
1246 1253
        } else {
1247 1254
            /* Note: in this case, no need to wait */
1248 1255
            memset(acb->buf, 0, 512 * acb->n);
1249
            if (acb->bh) {
1250
                ret = -EIO;
1251
                goto fail;
1252
            }
1253
            acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
1254
            if (!acb->bh) {
1255
                ret = -EIO;
1256
            ret = qcow_schedule_bh(qcow_aio_read_bh, acb);
1257
            if (ret < 0)
1256 1258
                goto fail;
1257
            }
1258
            qemu_bh_schedule(acb->bh);
1259 1259
        }
1260 1260
    } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
1261 1261
        /* add AIO support for compressed blocks ? */
......
1263 1263
            goto fail;
1264 1264
        memcpy(acb->buf,
1265 1265
               s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
1266
        if (acb->bh) {
1267
            ret = -EIO;
1268
            goto fail;
1269
        }
1270
        acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
1271
        if (!acb->bh) {
1272
            ret = -EIO;
1266
        ret = qcow_schedule_bh(qcow_aio_read_bh, acb);
1267
        if (ret < 0)
1273 1268
            goto fail;
1274
        }
1275
        qemu_bh_schedule(acb->bh);
1276 1269
    } else {
1277 1270
        if ((acb->cluster_offset & 511) != 0) {
1278 1271
            ret = -EIO;

Also available in: Unified diff