From nobody Fri Nov 7 00:46:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544644397702146.52155534094277; Wed, 12 Dec 2018 11:53:17 -0800 (PST) Received: from localhost ([::1]:47732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXAZI-000802-6b for importer@patchew.org; Wed, 12 Dec 2018 14:53:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXAMy-0005cW-2M for qemu-devel@nongnu.org; Wed, 12 Dec 2018 14:40:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXAMv-0007lr-S6 for qemu-devel@nongnu.org; Wed, 12 Dec 2018 14:40:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59266) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXAMr-0007hV-Tn; Wed, 12 Dec 2018 14:40:26 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D55E308ED44; Wed, 12 Dec 2018 19:40:25 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-204-190.brq.redhat.com [10.40.204.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46B38608C8; Wed, 12 Dec 2018 19:40:22 +0000 (UTC) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2018 20:40:09 +0100 Message-Id: <20181212194009.2951-5-lvivier@redhat.com> In-Reply-To: <20181212194009.2951-1-lvivier@redhat.com> References: <20181212194009.2951-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 12 Dec 2018 19:40:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] block/sheepdog: Convert from DPRINTF() macro to trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Laurent Vivier , qemu-block@nongnu.org, qemu-trivial@nongnu.org, "Richard W.M. Jones" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Liu Yuan , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/sheepdog.c | 47 +++++++++++++++++----------------------------- block/trace-events | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 0125df9d49..a5000d271b 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -28,6 +28,7 @@ #include "sysemu/block-backend.h" #include "qemu/bitops.h" #include "qemu/cutils.h" +#include "trace.h" =20 #define SD_PROTO_VER 0x01 =20 @@ -299,19 +300,6 @@ static inline size_t count_data_objs(const struct Shee= pdogInode *inode) (1UL << inode->block_size_shift)); } =20 -#undef DPRINTF -#ifdef DEBUG_SDOG -#define DEBUG_SDOG_PRINT 1 -#else -#define DEBUG_SDOG_PRINT 0 -#endif -#define DPRINTF(fmt, args...) \ - do { \ - if (DEBUG_SDOG_PRINT) { \ - fprintf(stderr, "%s %d: " fmt, __func__, __LINE__, ##args); \ - } \ - } while (0) - typedef struct SheepdogAIOCB SheepdogAIOCB; typedef struct BDRVSheepdogState BDRVSheepdogState; =20 @@ -750,7 +738,7 @@ static coroutine_fn void reconnect_to_sdog(void *opaque) Error *local_err =3D NULL; s->fd =3D get_sheep_fd(s, &local_err); if (s->fd < 0) { - DPRINTF("Wait for connection to be established\n"); + trace_sd_reconnect_to_sdog(); error_report_err(local_err); qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000000ULL); } @@ -847,7 +835,7 @@ static void coroutine_fn aio_read_response(void *opaque) break; case AIOCB_FLUSH_CACHE: if (rsp.result =3D=3D SD_RES_INVALID_PARMS) { - DPRINTF("disable cache since the server doesn't support it\n"); + trace_sd_aio_read_response(); s->cache_flags =3D SD_FLAG_CMD_DIRECT; rsp.result =3D SD_RES_SUCCESS; } @@ -1639,7 +1627,7 @@ static int sd_open(BlockDriverState *bs, QDict *optio= ns, int flags, s->discard_supported =3D true; =20 if (snap_id || tag[0]) { - DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid); + trace_sd_open(vid); s->is_snapshot =3D true; } =20 @@ -2252,7 +2240,7 @@ static void sd_close(BlockDriverState *bs) unsigned int wlen, rlen =3D 0; int fd, ret; =20 - DPRINTF("%s\n", s->name); + trace_sd_close(s->name); =20 fd =3D connect_to_sdog(s, &local_err); if (fd < 0) { @@ -2429,7 +2417,7 @@ static int sd_create_branch(BDRVSheepdogState *s) char *buf; bool deleted; =20 - DPRINTF("%" PRIx32 " is snapshot.\n", s->inode.vdi_id); + trace_sd_create_branch_snapshot(s->inode.vdi_id); =20 buf =3D g_malloc(SD_INODE_SIZE); =20 @@ -2445,7 +2433,7 @@ static int sd_create_branch(BDRVSheepdogState *s) goto out; } =20 - DPRINTF("%" PRIx32 " is created.\n", vid); + trace_sd_create_branch_created(vid); =20 fd =3D connect_to_sdog(s, &local_err); if (fd < 0) { @@ -2467,7 +2455,7 @@ static int sd_create_branch(BDRVSheepdogState *s) =20 s->is_snapshot =3D false; ret =3D 0; - DPRINTF("%" PRIx32 " was newly created.\n", s->inode.vdi_id); + trace_sd_create_branch_new(s->inode.vdi_id); =20 out: g_free(buf); @@ -2561,11 +2549,11 @@ static void coroutine_fn sd_co_rw_vector(SheepdogAI= OCB *acb) } =20 if (create) { - DPRINTF("update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld\= n", - inode->vdi_id, oid, - vid_to_data_oid(inode->data_vdi_id[idx], idx), idx); + trace_sd_co_rw_vector_update(inode->vdi_id, oid, + vid_to_data_oid(inode->data_vdi_id[idx],= idx), + idx); oid =3D vid_to_data_oid(inode->vdi_id, idx); - DPRINTF("new oid %" PRIx64 "\n", oid); + trace_sd_co_rw_vector_new(oid); } =20 aio_req =3D alloc_aio_req(s, acb, oid, len, offset, flags, create, @@ -2670,9 +2658,8 @@ static int sd_snapshot_create(BlockDriverState *bs, Q= EMUSnapshotInfo *sn_info) SheepdogInode *inode; unsigned int datalen; =20 - DPRINTF("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64= " " - "is_snapshot %d\n", sn_info->name, sn_info->id_str, - s->name, sn_info->vm_state_size, s->is_snapshot); + trace_sd_snapshot_create_info(sn_info->name, sn_info->id_str, s->name, + sn_info->vm_state_size, s->is_snapshot); =20 if (s->is_snapshot) { error_report("You can't create a snapshot of a snapshot VDI, " @@ -2681,7 +2668,7 @@ static int sd_snapshot_create(BlockDriverState *bs, Q= EMUSnapshotInfo *sn_info) return -EINVAL; } =20 - DPRINTF("%s %s\n", sn_info->name, sn_info->id_str); + trace_sd_snapshot_create(sn_info->name, sn_info->id_str); =20 s->inode.vm_state_size =3D sn_info->vm_state_size; s->inode.vm_clock_nsec =3D sn_info->vm_clock_nsec; @@ -2726,8 +2713,8 @@ static int sd_snapshot_create(BlockDriverState *bs, Q= EMUSnapshotInfo *sn_info) } =20 memcpy(&s->inode, inode, datalen); - DPRINTF("s->inode: name %s snap_id %x oid %x\n", - s->inode.name, s->inode.snap_id, s->inode.vdi_id); + trace_sd_snapshot_create_inode(s->inode.name, s->inode.snap_id, + s->inode.vdi_id); =20 cleanup: g_free(inode); diff --git a/block/trace-events b/block/trace-events index 49f31966e7..7a92d7b3db 100644 --- a/block/trace-events +++ b/block/trace-events @@ -189,3 +189,17 @@ file_xfs_discard(const char* error) "cannot punch hole= (%s)" file_FindEjectableOpticalMedia(const char *media) "Matching using %s" file_setup_cdrom(const char *partition) "Using %s as optical disc" file_hdev_is_sg(int type, int version) "SG device found: type=3D%d, versio= n=3D%d" + +# block/sheepdog.c +sd_reconnect_to_sdog(void) "Wait for connection to be established" +sd_aio_read_response(void) "disable cache since the server doesn't support= it" +sd_open(uint32_t vid) "0x%" PRIx32 " snapshot inode was open." +sd_close(const char *name) "%s" +sd_create_branch_snapshot(uint32_t vdi) "0x%" PRIx32 " is snapshot." +sd_create_branch_created(uint32_t vdi) "0x%" PRIx32 " is created." +sd_create_branch_new(uint32_t vdi) "0x%" PRIx32 " was newly created." +sd_co_rw_vector_update(uint32_t vdi, uint64_t oid, uint64_t data, long idx= ) "update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld" +sd_co_rw_vector_new(uint64_t oid) "new oid 0x%" PRIx64 +sd_snapshot_create_info(const char *sn_name, const char *id, const char *n= ame, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: name %s = vm_state_size %" PRId64 " " "is_snapshot %d" +sd_snapshot_create(const char *sn_name, const char *id) "%s %s" +sd_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s= ->inode: name %s snap_id 0x%x vdi 0x%x" --=20 2.19.2