static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)

{

    QEMUIOVector qiov;

    int noffsets;

    int i, ret;



    struct iovec iov = {

        .iov_base = table->offsets,

        .iov_len = s->header.cluster_size * s->header.table_size,

    };

    qemu_iovec_init_external(&qiov, &iov, 1);



    trace_qed_read_table(s, offset, table);



    ret = bdrv_preadv(s->bs->file, offset, &qiov);

    if (ret < 0) {

        goto out;

    }



    /* Byteswap offsets */

    qed_acquire(s);

    noffsets = qiov.size / sizeof(uint64_t);

    for (i = 0; i < noffsets; i++) {

        table->offsets[i] = le64_to_cpu(table->offsets[i]);

    }

    qed_release(s);



    ret = 0;

out:

    /* Completion */

    trace_qed_read_table_cb(s, table, ret);

    return ret;

}

static int qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table)

{

    QEMUIOVector qiov;

    int noffsets;

    int i, ret;



    struct iovec iov = {

        .iov_base = table->offsets,

        .iov_len = s->header.cluster_size * s->header.table_size,

    };

    qemu_iovec_init_external(&qiov, &iov, 1);



    trace_qed_read_table(s, offset, table);



    ret = bdrv_preadv(s->bs->file, offset, &qiov);

    if (ret < 0) {

        goto out;

    }



    

    qed_acquire(s);

    noffsets = qiov.size / sizeof(uint64_t);

    for (i = 0; i < noffsets; i++) {

        table->offsets[i] = le64_to_cpu(table->offsets[i]);

    }

    qed_release(s);



    ret = 0;

out:

    

    trace_qed_read_table_cb(s, table, ret);

    return ret;

}

static int FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1, QEDTable *VAR_2)

{

    QEMUIOVector qiov;

    int VAR_3;

    int VAR_4, VAR_5;



    struct iovec VAR_6 = {

        .iov_base = VAR_2->offsets,

        .iov_len = VAR_0->header.cluster_size * VAR_0->header.table_size,

    };

    qemu_iovec_init_external(&qiov, &VAR_6, 1);



    trace_qed_read_table(VAR_0, VAR_1, VAR_2);



    VAR_5 = bdrv_preadv(VAR_0->bs->file, VAR_1, &qiov);

    if (VAR_5 < 0) {

        goto out;

    }



    

    qed_acquire(VAR_0);

    VAR_3 = qiov.size / sizeof(uint64_t);

    for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

        VAR_2->offsets[VAR_4] = le64_to_cpu(VAR_2->offsets[VAR_4]);

    }

    qed_release(VAR_0);



    VAR_5 = 0;

out:

    

    trace_qed_read_table_cb(VAR_0, VAR_2, VAR_5);

    return VAR_5;

}

static int FUNC_0(BDRVQEDState *VAR_0, uint64_t VAR_1, QEDTable *VAR_2)
{ QEMUIOVector qiov; int VAR_3; int VAR_4, VAR_5; struct iovec VAR_6 = { .iov_base = VAR_2->offsets,
.iov_len = VAR_0->header.cluster_size * VAR_0->header.table_size,
}; qemu_iovec_init_external(&qiov, &VAR_6, 1); trace_qed_read_table(VAR_0, VAR_1, VAR_2); VAR_5 = bdrv_preadv(VAR_0->bs->file, VAR_1, &qiov); if (VAR_5 < 0) { goto out; } qed_acquire(VAR_0); VAR_3 = qiov.size / sizeof(uint64_t); for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { VAR_2->offsets[VAR_4] = le64_to_cpu(VAR_2->offsets[VAR_4]); } qed_release(VAR_0); VAR_5 = 0; out:
trace_qed_read_table_cb(VAR_0, VAR_2, VAR_5); return VAR_5; }