From nobody Sun Oct 5 21:10:51 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1499689336846332.84807756928797; Mon, 10 Jul 2017 05:22:16 -0700 (PDT) Received: from localhost ([::1]:40509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUXhe-0007Zz-Cs for importer@patchew.org; Mon, 10 Jul 2017 08:22:14 -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) 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) 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 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 =3D true; - TRACE("Server supports fixed new style"); clientflags |=3D NBD_FLAG_C_FIXED_NEWSTYLE; } if (globalflags & NBD_FLAG_NO_ZEROES) { zeroes =3D false; - TRACE("Server supports no zeroes"); clientflags |=3D 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 =3D 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, NB= DReply *reply, int len, int ret; g_assert(qemu_in_coroutine()); + + TRACE("Send reply: handle =3D %" PRIu64 ", error =3D %" PRIu32 ", len = =3D %d", + reply->handle, reply->error, len); + qemu_co_mutex_lock(&client->send_lock); client->send_coroutine =3D 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 =3D %" PRIu64 ", type =3D %" PRIu16, + request->handle, request->type); if (request->type !=3D 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 =3D=3D 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 *r= eq, NBDRequest *request, } } if (request->type =3D=3D 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 =3D true; + + TRACE("Payload received: handle =3D %" PRIu64 ", len =3D %" 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 =3D blk_co_flush(exp->blk); @@ -1171,20 +1174,14 @@ static coroutine_fn void nbd_trip(void *opaque) } reply_data_len =3D 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 =3D EROFS; break; } - TRACE("Writing to device"); - flags =3D 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |=3D 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 =3D EROFS; break; } - TRACE("Writing to device"); - flags =3D 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |=3D 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 =3D 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 =3D 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); --=20 2.9.4