From patchwork Wed Dec 12 19:40:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 10727017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B2A41759 for ; Wed, 12 Dec 2018 19:49:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CF7A2B816 for ; Wed, 12 Dec 2018 19:49:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 408FB2B835; Wed, 12 Dec 2018 19:49:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D2DB32B816 for ; Wed, 12 Dec 2018 19:49:17 +0000 (UTC) Received: from localhost ([::1]:47700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXAVR-0003qx-12 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Dec 2018 14:49:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXAMv-0005a5-RS for qemu-devel@nongnu.org; Wed, 12 Dec 2018 14:40:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXAMu-0007k0-NH for qemu-devel@nongnu.org; Wed, 12 Dec 2018 14:40:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gXAMq-0007eh-93; Wed, 12 Dec 2018 14:40:24 -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 D9A9A3082141; Wed, 12 Dec 2018 19:40:21 +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 5EA96608C8; Wed, 12 Dec 2018 19:40:19 +0000 (UTC) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 12 Dec 2018 20:40:08 +0100 Message-Id: <20181212194009.2951-4-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.42]); Wed, 12 Dec 2018 19:40:21 +0000 (UTC) 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 3/4] block/file-posix: 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Liu Yuan , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé --- block/file-posix.c | 25 ++++++------------------- block/trace-events | 7 +++++++ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 07bbdab953..cf90899a6e 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -102,19 +102,7 @@ #include #endif -//#define DEBUG_BLOCK - -#ifdef DEBUG_BLOCK -# define DEBUG_BLOCK_PRINT 1 -#else -# define DEBUG_BLOCK_PRINT 0 -#endif -#define DPRINTF(fmt, ...) \ -do { \ - if (DEBUG_BLOCK_PRINT) { \ - printf(fmt, ## __VA_ARGS__); \ - } \ -} while (0) +#include "trace.h" /* OS X does not have O_DSYNC */ #ifndef O_DSYNC @@ -1386,7 +1374,7 @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes) if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) { err = errno; - DPRINTF("cannot write zero range (%s)\n", strerror(errno)); + trace_file_xfs_write_zeroes(strerror(errno)); return -err; } @@ -1405,7 +1393,7 @@ static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes) if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) { err = errno; - DPRINTF("cannot punch hole (%s)\n", strerror(errno)); + trace_file_xfs_discard(strerror(errno)); return -err; } @@ -2798,7 +2786,7 @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator) /* If a match was found, leave the loop */ if (*mediaIterator != 0) { - DPRINTF("Matching using %s\n", matching_array[index]); + trace_file_FindEjectableOpticalMedia(matching_array[index]); mediaType = g_strdup(matching_array[index]); break; } @@ -2858,7 +2846,7 @@ static bool setup_cdrom(char *bsd_path, Error **errp) if (partition_found == false) { error_setg(errp, "Failed to find a working partition on disc"); } else { - DPRINTF("Using %s as optical disc\n", test_partition); + trace_file_setup_cdrom(test_partition); pstrcpy(bsd_path, MAXPATHLEN, test_partition); } return partition_found; @@ -2953,8 +2941,7 @@ static bool hdev_is_sg(BlockDriverState *bs) ret = ioctl(s->fd, SG_GET_SCSI_ID, &scsiid); if (ret >= 0) { - DPRINTF("SG device found: type=%d, version=%d\n", - scsiid.scsi_type, sg_version); + trace_file_hdev_is_sg(scsiid.scsi_type, sg_version); return true; } diff --git a/block/trace-events b/block/trace-events index 5b83280b02..49f31966e7 100644 --- a/block/trace-events +++ b/block/trace-events @@ -182,3 +182,10 @@ curl_open(const char *file) "opening %s" curl_open_size(uint64_t size) "size = %" PRIu64 curl_setup_preadv(uint64_t bytes, uint64_t start, const char *range) "reading %" PRIu64 " at %" PRIu64 " (%s)" curl_close(void) "close" + +# block/file-posix.c +file_xfs_write_zeroes(const char *error) "cannot write zero range (%s)" +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"