mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 01:50:43 +00:00
sheepdog: remove huge BSS object
block/sheepdog.o has a 4M static variable that is 90% of QEMU's whole .bss section. Replace it with a heap-allocated block, and make it smaller too since only the inode header is actually being used. bss size goes down from 4464280 to 269976. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20180523160721.14018-3-pbonzini@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
parent
03b036cc0c
commit
68acc99f14
@ -2938,13 +2938,14 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
|
|||||||
QEMUSnapshotInfo *sn_tab = NULL;
|
QEMUSnapshotInfo *sn_tab = NULL;
|
||||||
unsigned wlen, rlen;
|
unsigned wlen, rlen;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
static SheepdogInode inode;
|
SheepdogInode *inode;
|
||||||
unsigned long *vdi_inuse;
|
unsigned long *vdi_inuse;
|
||||||
unsigned int start_nr;
|
unsigned int start_nr;
|
||||||
uint64_t hval;
|
uint64_t hval;
|
||||||
uint32_t vid;
|
uint32_t vid;
|
||||||
|
|
||||||
vdi_inuse = g_malloc(max);
|
vdi_inuse = g_malloc(max);
|
||||||
|
inode = g_malloc(SD_INODE_HEADER_SIZE);
|
||||||
|
|
||||||
fd = connect_to_sdog(s, &local_err);
|
fd = connect_to_sdog(s, &local_err);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@ -2987,7 +2988,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* we don't need to read entire object */
|
/* we don't need to read entire object */
|
||||||
ret = read_object(fd, s->bs, (char *)&inode,
|
ret = read_object(fd, s->bs, (char *)inode,
|
||||||
vid_to_vdi_oid(vid),
|
vid_to_vdi_oid(vid),
|
||||||
0, SD_INODE_HEADER_SIZE, 0,
|
0, SD_INODE_HEADER_SIZE, 0,
|
||||||
s->cache_flags);
|
s->cache_flags);
|
||||||
@ -2996,17 +2997,17 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(inode.name, s->name) && is_snapshot(&inode)) {
|
if (!strcmp(inode->name, s->name) && is_snapshot(inode)) {
|
||||||
sn_tab[found].date_sec = inode.snap_ctime >> 32;
|
sn_tab[found].date_sec = inode->snap_ctime >> 32;
|
||||||
sn_tab[found].date_nsec = inode.snap_ctime & 0xffffffff;
|
sn_tab[found].date_nsec = inode->snap_ctime & 0xffffffff;
|
||||||
sn_tab[found].vm_state_size = inode.vm_state_size;
|
sn_tab[found].vm_state_size = inode->vm_state_size;
|
||||||
sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec;
|
sn_tab[found].vm_clock_nsec = inode->vm_clock_nsec;
|
||||||
|
|
||||||
snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str),
|
snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str),
|
||||||
"%" PRIu32, inode.snap_id);
|
"%" PRIu32, inode->snap_id);
|
||||||
pstrcpy(sn_tab[found].name,
|
pstrcpy(sn_tab[found].name,
|
||||||
MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)),
|
MIN(sizeof(sn_tab[found].name), sizeof(inode->tag)),
|
||||||
inode.tag);
|
inode->tag);
|
||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3016,6 +3017,7 @@ out:
|
|||||||
*psn_tab = sn_tab;
|
*psn_tab = sn_tab;
|
||||||
|
|
||||||
g_free(vdi_inuse);
|
g_free(vdi_inuse);
|
||||||
|
g_free(inode);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user