From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, qemu-trivial@nongnu.org,
"Richard W.M. Jones" <rjones@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Liu Yuan" <namei.unix@gmail.com>,
"Max Reitz" <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/4] block/sheepdog: Convert from DPRINTF() macro to trace events
Date: Thu, 13 Dec 2018 10:21:29 +0100 [thread overview]
Message-ID: <270fb776-d977-77df-36c9-f77088b2ad04@redhat.com> (raw)
In-Reply-To: <20181212194009.2951-5-lvivier@redhat.com>
Hi Laurent,
On 12/12/18 8:40 PM, Laurent Vivier wrote:
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> 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"
>
> #define SD_PROTO_VER 0x01
>
> @@ -299,19 +300,6 @@ static inline size_t count_data_objs(const struct SheepdogInode *inode)
> (1UL << inode->block_size_shift));
> }
>
> -#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;
>
> @@ -750,7 +738,7 @@ static coroutine_fn void reconnect_to_sdog(void *opaque)
> Error *local_err = NULL;
> s->fd = 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 == SD_RES_INVALID_PARMS) {
> - DPRINTF("disable cache since the server doesn't support it\n");
> + trace_sd_aio_read_response();
> s->cache_flags = SD_FLAG_CMD_DIRECT;
> rsp.result = SD_RES_SUCCESS;
> }
> @@ -1639,7 +1627,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags,
> s->discard_supported = true;
>
> if (snap_id || tag[0]) {
> - DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid);
> + trace_sd_open(vid);
> s->is_snapshot = true;
> }
>
> @@ -2252,7 +2240,7 @@ static void sd_close(BlockDriverState *bs)
> unsigned int wlen, rlen = 0;
> int fd, ret;
>
> - DPRINTF("%s\n", s->name);
> + trace_sd_close(s->name);
>
> fd = connect_to_sdog(s, &local_err);
> if (fd < 0) {
> @@ -2429,7 +2417,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
> char *buf;
> bool deleted;
>
> - DPRINTF("%" PRIx32 " is snapshot.\n", s->inode.vdi_id);
> + trace_sd_create_branch_snapshot(s->inode.vdi_id);
>
> buf = g_malloc(SD_INODE_SIZE);
>
> @@ -2445,7 +2433,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
> goto out;
> }
>
> - DPRINTF("%" PRIx32 " is created.\n", vid);
> + trace_sd_create_branch_created(vid);
>
> fd = connect_to_sdog(s, &local_err);
> if (fd < 0) {
> @@ -2467,7 +2455,7 @@ static int sd_create_branch(BDRVSheepdogState *s)
>
> s->is_snapshot = false;
> ret = 0;
> - DPRINTF("%" PRIx32 " was newly created.\n", s->inode.vdi_id);
> + trace_sd_create_branch_new(s->inode.vdi_id);
>
> out:
> g_free(buf);
> @@ -2561,11 +2549,11 @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb)
> }
>
> 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 = vid_to_data_oid(inode->vdi_id, idx);
> - DPRINTF("new oid %" PRIx64 "\n", oid);
> + trace_sd_co_rw_vector_new(oid);
> }
>
> aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, create,
> @@ -2670,9 +2658,8 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
> SheepdogInode *inode;
> unsigned int datalen;
>
> - 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);
>
> 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, QEMUSnapshotInfo *sn_info)
> return -EINVAL;
> }
>
> - DPRINTF("%s %s\n", sn_info->name, sn_info->id_str);
> + trace_sd_snapshot_create(sn_info->name, sn_info->id_str);
>
> s->inode.vm_state_size = sn_info->vm_state_size;
> s->inode.vm_clock_nsec = sn_info->vm_clock_nsec;
> @@ -2726,8 +2713,8 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
> }
>
> 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);
>
> 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=%d, version=%d"
> +
> +# block/sheepdog.c
> +sd_reconnect_to_sdog(void) "Wait for connection to be established"
Can you use the 'sheepdog' prefix to avoid clashing with the 'sd' subsystem?
> +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."
We can drop the trailing dots.
> +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 *name, 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"
>
With 'sheepdog' prefix:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
prev parent reply other threads:[~2018-12-13 9:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 19:40 [Qemu-devel] [PATCH 0/4] block: Convert from DPRINTF() macro to trace event Laurent Vivier
2018-12-12 19:40 ` [Qemu-devel] [PATCH 1/4] block/ssh: Convert from DPRINTF() macro to trace events Laurent Vivier
2018-12-12 21:19 ` Richard W.M. Jones
2018-12-13 9:17 ` Philippe Mathieu-Daudé
2018-12-12 19:40 ` [Qemu-devel] [PATCH 2/4] block/curl: " Laurent Vivier
2018-12-12 21:20 ` Richard W.M. Jones
2018-12-13 9:23 ` Philippe Mathieu-Daudé
2018-12-12 19:40 ` [Qemu-devel] [PATCH 3/4] block/file-posix: " Laurent Vivier
2018-12-13 9:18 ` Philippe Mathieu-Daudé
2018-12-12 19:40 ` [Qemu-devel] [PATCH 4/4] block/sheepdog: " Laurent Vivier
2018-12-13 9:21 ` Philippe Mathieu-Daudé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=270fb776-d977-77df-36c9-f77088b2ad04@redhat.com \
--to=philmd@redhat.com \
--cc=f4bug@amsat.org \
--cc=kwolf@redhat.com \
--cc=lvivier@redhat.com \
--cc=mreitz@redhat.com \
--cc=namei.unix@gmail.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rjones@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).