* [Qemu-devel] [PULL 1/2] sheepdog: cleanup repeated expression
2018-06-05 14:19 [Qemu-devel] [PULL 0/2] Block patches Jeff Cody
@ 2018-06-05 14:19 ` Jeff Cody
2018-06-05 14:19 ` [Qemu-devel] [PULL 2/2] sheepdog: remove huge BSS object Jeff Cody
2018-06-05 15:11 ` [Qemu-devel] [PULL 0/2] Block patches Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2018-06-05 14:19 UTC (permalink / raw)
To: qemu-block; +Cc: peter.maydell, jcody, qemu-devel, pbonzini
From: Paolo Bonzini <pbonzini@redhat.com>
The expression "SD_INODE_SIZE - sizeof(inode.data_vdi_id)" already has a macro
defined for the same value (though with a nicer definition using offsetof).
Replace it.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20180523160721.14018-2-pbonzini@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
---
block/sheepdog.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 2a5bc0a59a..cfc0e28aa5 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2335,7 +2335,7 @@ static int sd_truncate(BlockDriverState *bs, int64_t offset,
}
/* we don't need to update entire object */
- datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
+ datalen = SD_INODE_HEADER_SIZE;
s->inode.vdi_size = offset;
ret = write_object(fd, s->bs, (char *)&s->inode,
vid_to_vdi_oid(s->inode.vdi_id), s->inode.nr_copies,
@@ -2703,7 +2703,7 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
*/
strncpy(s->inode.tag, sn_info->name, sizeof(s->inode.tag));
/* we don't need to update entire object */
- datalen = SD_INODE_SIZE - sizeof(s->inode.data_vdi_id);
+ datalen = SD_INODE_HEADER_SIZE;
inode = g_malloc(datalen);
/* refresh inode. */
@@ -2989,7 +2989,7 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
/* we don't need to read entire object */
ret = read_object(fd, s->bs, (char *)&inode,
vid_to_vdi_oid(vid),
- 0, SD_INODE_SIZE - sizeof(inode.data_vdi_id), 0,
+ 0, SD_INODE_HEADER_SIZE, 0,
s->cache_flags);
if (ret) {
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PULL 2/2] sheepdog: remove huge BSS object
2018-06-05 14:19 [Qemu-devel] [PULL 0/2] Block patches Jeff Cody
2018-06-05 14:19 ` [Qemu-devel] [PULL 1/2] sheepdog: cleanup repeated expression Jeff Cody
@ 2018-06-05 14:19 ` Jeff Cody
2018-06-05 15:11 ` [Qemu-devel] [PULL 0/2] Block patches Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2018-06-05 14:19 UTC (permalink / raw)
To: qemu-block; +Cc: peter.maydell, jcody, qemu-devel, pbonzini
From: Paolo Bonzini <pbonzini@redhat.com>
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>
---
block/sheepdog.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index cfc0e28aa5..7b98725af7 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2938,13 +2938,14 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
QEMUSnapshotInfo *sn_tab = NULL;
unsigned wlen, rlen;
int found = 0;
- static SheepdogInode inode;
+ SheepdogInode *inode;
unsigned long *vdi_inuse;
unsigned int start_nr;
uint64_t hval;
uint32_t vid;
vdi_inuse = g_malloc(max);
+ inode = g_malloc(SD_INODE_HEADER_SIZE);
fd = connect_to_sdog(s, &local_err);
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 */
- ret = read_object(fd, s->bs, (char *)&inode,
+ ret = read_object(fd, s->bs, (char *)inode,
vid_to_vdi_oid(vid),
0, SD_INODE_HEADER_SIZE, 0,
s->cache_flags);
@@ -2996,17 +2997,17 @@ static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab)
continue;
}
- if (!strcmp(inode.name, s->name) && is_snapshot(&inode)) {
- sn_tab[found].date_sec = inode.snap_ctime >> 32;
- sn_tab[found].date_nsec = inode.snap_ctime & 0xffffffff;
- sn_tab[found].vm_state_size = inode.vm_state_size;
- sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec;
+ if (!strcmp(inode->name, s->name) && is_snapshot(inode)) {
+ sn_tab[found].date_sec = inode->snap_ctime >> 32;
+ sn_tab[found].date_nsec = inode->snap_ctime & 0xffffffff;
+ sn_tab[found].vm_state_size = inode->vm_state_size;
+ sn_tab[found].vm_clock_nsec = inode->vm_clock_nsec;
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,
- MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)),
- inode.tag);
+ MIN(sizeof(sn_tab[found].name), sizeof(inode->tag)),
+ inode->tag);
found++;
}
}
@@ -3016,6 +3017,7 @@ out:
*psn_tab = sn_tab;
g_free(vdi_inuse);
+ g_free(inode);
if (ret < 0) {
return ret;
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PULL 0/2] Block patches
2018-06-05 14:19 [Qemu-devel] [PULL 0/2] Block patches Jeff Cody
2018-06-05 14:19 ` [Qemu-devel] [PULL 1/2] sheepdog: cleanup repeated expression Jeff Cody
2018-06-05 14:19 ` [Qemu-devel] [PULL 2/2] sheepdog: remove huge BSS object Jeff Cody
@ 2018-06-05 15:11 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-06-05 15:11 UTC (permalink / raw)
To: Jeff Cody; +Cc: Qemu-block, QEMU Developers, Paolo Bonzini
On 5 June 2018 at 15:19, Jeff Cody <jcody@redhat.com> wrote:
> The following changes since commit 41feb5b955f0d7c9d071b2c5adbc404ae2895c7a:
>
> Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-3.0-pull-request' into staging (2018-06-05 10:38:33 +0100)
>
> are available in the git repository at:
>
> git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
>
> for you to fetch changes up to 68acc99f143b60ec4faa2903065b187d4d3c4bf3:
>
> sheepdog: remove huge BSS object (2018-06-05 10:15:12 -0400)
>
> ----------------------------------------------------------------
> Sheepdog patches
> ----------------------------------------------------------------
>
> Paolo Bonzini (2):
> sheepdog: cleanup repeated expression
> sheepdog: remove huge BSS object
>
> block/sheepdog.c | 28 +++++++++++++++-------------
> 1 file changed, 15 insertions(+), 13 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread