[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/4] block: image fragmentation statistics for q
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 2/4] block: image fragmentation statistics for qed |
Date: |
Mon, 12 Mar 2012 12:58:53 +0000 |
On Wed, Mar 7, 2012 at 9:22 AM, Dong Xu Wang <address@hidden> wrote:
> + for (i = 0; i < table_noffsets; i++) {
> + l2_offset = s->l1_table->offsets[i];
> + if (l2_offset == 0) {
if (qed_offset_is_unalloc_cluster(l2_offset)) {
> + continue;
> + }
> + ret = bdrv_pread(bs->file, l2_offset, table, size);
> + if (ret < 0) {
> + qemu_vfree(table);
> + return ret;
> + }
> + for (j = 0; j < size/sizeof(uint64_t); j++) {
> + uint64_t *offset = (uint64_t *)(table + j);
No need to cast, table is already uint64_t*.
Since you don't write to the offset, I would just do:
uint64_t offset = table[j];
> + if (*offset < cluster_size) {
> + continue;
> + }
if (!qed_check_cluster_offset(s, offset)) {
continue;
}
We will skip unallocated clusters and zero clusters.
Stefan
Re: [Qemu-devel] [PATCH 1/4] block: add image fragmentation statistics to qemu-img, Stefan Hajnoczi, 2012/03/12