From patchwork Mon Jul 10 12:14:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9832833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5CD5660393 for ; Mon, 10 Jul 2017 12:21:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E016283AF for ; Mon, 10 Jul 2017 12:21:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4280328458; Mon, 10 Jul 2017 12:21:47 +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=-6.9 required=2.0 tests=BAYES_00,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 ADE6228469 for ; Mon, 10 Jul 2017 12:21:46 +0000 (UTC) Received: from localhost ([::1]:40502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUXhB-0006ec-RA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Jul 2017 08:21:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUXai-0001q7-7E for qemu-devel@nongnu.org; Mon, 10 Jul 2017 08:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUXag-0002jw-UU for qemu-devel@nongnu.org; Mon, 10 Jul 2017 08:15:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57132) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dUXaa-0002f3-AK; Mon, 10 Jul 2017 08:14:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FF55C045768; Mon, 10 Jul 2017 12:14:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4FF55C045768 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4FF55C045768 Received: from red.redhat.com (ovpn-121-60.rdu2.redhat.com [10.10.121.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F57F756AE; Mon, 10 Jul 2017 12:14:54 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 10 Jul 2017 07:14:33 -0500 Message-Id: <20170710121434.5047-11-eblake@redhat.com> In-Reply-To: <20170710121434.5047-1-eblake@redhat.com> References: <20170710121434.5047-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 10 Jul 2017 12:14:55 +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] [PULL 10/11] nbd: refactor tracing 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: Paolo Bonzini , Vladimir Sementsov-Ogievskiy , "open list:Network Block Dev..." Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vladimir Sementsov-Ogievskiy Reorganize traces: move, reword, add information, drop extra ones. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20170707152918.23086-10-vsementsov@virtuozzo.com> Signed-off-by: Eric Blake --- nbd/client.c | 3 --- nbd/server.c | 30 +++++++++--------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index 2125321..1ae4ff8 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -489,12 +489,10 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags, TRACE("Global flags are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; - TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } if (globalflags & NBD_FLAG_NO_ZEROES) { zeroes = false; - TRACE("Server supports no zeroes"); clientflags |= NBD_FLAG_C_NO_ZEROES; } /* client requested flags */ @@ -565,7 +563,6 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags, goto fail; } *size = be64_to_cpu(s); - TRACE("Size is %" PRIu64, *size); if (nbd_read(ioc, &oldflags, sizeof(oldflags), errp) < 0) { error_prepend(errp, "Failed to read export flags"); diff --git a/nbd/server.c b/nbd/server.c index c4d64fb..4bbce5f 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1000,6 +1000,10 @@ static int nbd_co_send_reply(NBDRequestData *req, NBDReply *reply, int len, int ret; g_assert(qemu_in_coroutine()); + + TRACE("Send reply: handle = %" PRIu64 ", error = %" PRIu32 ", len = %d", + reply->handle, reply->error, len); + qemu_co_mutex_lock(&client->send_lock); client->send_coroutine = qemu_coroutine_self(); @@ -1039,7 +1043,8 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, return -EIO; } - TRACE("Decoding type"); + TRACE("Decoding type: handle = %" PRIu64 ", type = %" PRIu16, + request->handle, request->type); if (request->type != NBD_CMD_WRITE) { /* No payload, we are ready to read the next request. */ @@ -1049,7 +1054,6 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, if (request->type == NBD_CMD_DISC) { /* Special case: we're going to disconnect without a reply, * whether or not flags, from, or len are bogus */ - TRACE("Request type is DISCONNECT"); return -EIO; } @@ -1076,13 +1080,14 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, } } if (request->type == NBD_CMD_WRITE) { - TRACE("Reading %" PRIu32 " byte(s)", request->len); - if (nbd_read(client->ioc, req->data, request->len, errp) < 0) { error_prepend(errp, "reading from socket failed: "); return -EIO; } req->complete = true; + + TRACE("Payload received: handle = %" PRIu64 ", len = %" PRIu32, + request->handle, request->len); } /* Sanity checks, part 2. */ @@ -1150,8 +1155,6 @@ static coroutine_fn void nbd_trip(void *opaque) switch (request.type) { case NBD_CMD_READ: - TRACE("Request type is READ"); - /* XXX: NBD Protocol only documents use of FUA with WRITE */ if (request.flags & NBD_CMD_FLAG_FUA) { ret = blk_co_flush(exp->blk); @@ -1171,20 +1174,14 @@ static coroutine_fn void nbd_trip(void *opaque) } reply_data_len = request.len; - TRACE("Read %" PRIu32" byte(s)", request.len); break; case NBD_CMD_WRITE: - TRACE("Request type is WRITE"); - if (exp->nbdflags & NBD_FLAG_READ_ONLY) { - TRACE("Server is read-only, return error"); reply.error = EROFS; break; } - TRACE("Writing to device"); - flags = 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |= BDRV_REQ_FUA; @@ -1198,16 +1195,12 @@ static coroutine_fn void nbd_trip(void *opaque) break; case NBD_CMD_WRITE_ZEROES: - TRACE("Request type is WRITE_ZEROES"); - if (exp->nbdflags & NBD_FLAG_READ_ONLY) { error_setg(&local_err, "Server is read-only, return error"); reply.error = EROFS; break; } - TRACE("Writing to device"); - flags = 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |= BDRV_REQ_FUA; @@ -1228,8 +1221,6 @@ static coroutine_fn void nbd_trip(void *opaque) abort(); case NBD_CMD_FLUSH: - TRACE("Request type is FLUSH"); - ret = blk_co_flush(exp->blk); if (ret < 0) { error_setg_errno(&local_err, -ret, "flush failed"); @@ -1238,7 +1229,6 @@ static coroutine_fn void nbd_trip(void *opaque) break; case NBD_CMD_TRIM: - TRACE("Request type is TRIM"); ret = blk_co_pdiscard(exp->blk, request.from + exp->dev_offset, request.len); if (ret < 0) { @@ -1274,8 +1264,6 @@ reply: goto disconnect; } - TRACE("Request/Reply complete"); - done: nbd_request_put(req); nbd_client_put(client);