From patchwork Fri Jun 18 13:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 12331447 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBD4CC48BDF for ; Fri, 18 Jun 2021 13:36:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4FF46124C for ; Fri, 18 Jun 2021 13:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233983AbhFRNiG (ORCPT ); Fri, 18 Jun 2021 09:38:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20829 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233934AbhFRNhw (ORCPT ); Fri, 18 Jun 2021 09:37:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624023343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xNf5vH386FO3DWWUo5p1LYSZTTqClAjh9OQpi5Mkgi4=; b=Jq91v4f5UvacvR7GsMM3sLv0iITkFirI8IMr63spbaUwOEoQcLmFdzhGwpatYlhq2BEqY/ f9av+XeK1deI7PTB3BD0rHfLLR1U46vN7I+x/J+W8ImTdgEu7uZD19yEMICtw5L2caXhw6 yEQnHeWIltGV4ENKA8ibeP4o3tbfmq4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-14-bIgTEk-2MLa1Sv1-0Ih9yA-1; Fri, 18 Jun 2021 09:35:39 -0400 X-MC-Unique: bIgTEk-2MLa1Sv1-0Ih9yA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E391100C661; Fri, 18 Jun 2021 13:35:38 +0000 (UTC) Received: from steredhat.lan (ovpn-115-127.ams2.redhat.com [10.36.115.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7A9410023B5; Fri, 18 Jun 2021 13:35:34 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Arseny Krasnov , kvm@vger.kernel.org, Stefano Garzarella , Jakub Kicinski , virtualization@lists.linux-foundation.org, "David S. Miller" , Stefan Hajnoczi , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] vsock: rename vsock_has_data() Date: Fri, 18 Jun 2021 15:35:24 +0200 Message-Id: <20210618133526.300347-2-sgarzare@redhat.com> In-Reply-To: <20210618133526.300347-1-sgarzare@redhat.com> References: <20210618133526.300347-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org vsock_has_data() is used only by STREAM and SEQPACKET sockets, so let's rename it to vsock_connectible_has_data(), using the same nomenclature (connectible) used in other functions after the introduction of SEQPACKET. Signed-off-by: Stefano Garzarella --- net/vmw_vsock/af_vsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 67954afef4e1..de8249483081 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -860,7 +860,7 @@ s64 vsock_stream_has_data(struct vsock_sock *vsk) } EXPORT_SYMBOL_GPL(vsock_stream_has_data); -static s64 vsock_has_data(struct vsock_sock *vsk) +static s64 vsock_connectible_has_data(struct vsock_sock *vsk) { struct sock *sk = sk_vsock(vsk); @@ -1880,7 +1880,7 @@ static int vsock_wait_data(struct sock *sk, struct wait_queue_entry *wait, err = 0; transport = vsk->transport; - while ((data = vsock_has_data(vsk)) == 0) { + while ((data = vsock_connectible_has_data(vsk)) == 0) { prepare_to_wait(sk_sleep(sk), wait, TASK_INTERRUPTIBLE); if (sk->sk_err != 0 || From patchwork Fri Jun 18 13:35:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 12331449 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2DCEC48BDF for ; Fri, 18 Jun 2021 13:36:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC90361261 for ; Fri, 18 Jun 2021 13:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234052AbhFRNiQ (ORCPT ); Fri, 18 Jun 2021 09:38:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53191 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233947AbhFRNiB (ORCPT ); Fri, 18 Jun 2021 09:38:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624023351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dXqmNJYdW4k2bFeB+YFnzlxYcdTW1K7N5BohB9KAzV0=; b=D8omukd5nmfJ9xmsKEfKEkzPsgssNyuZul6yINq6hxaac56oQNiDtmUHt1AxDfP5YH2lZu tpYB+LVHmoAbrRYpDPcsLE293+59oN+DUMouz7gc6oKHnVKSFBgNAFHOFJh0xRvQmB51bA 3M4CeBOs/us7LWHaGtIpoqin/GYEo6c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-wOd1bvkeOcuyxnn8SmCVng-1; Fri, 18 Jun 2021 09:35:48 -0400 X-MC-Unique: wOd1bvkeOcuyxnn8SmCVng-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43348CC623; Fri, 18 Jun 2021 13:35:47 +0000 (UTC) Received: from steredhat.lan (ovpn-115-127.ams2.redhat.com [10.36.115.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE7571000324; Fri, 18 Jun 2021 13:35:38 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Arseny Krasnov , kvm@vger.kernel.org, Stefano Garzarella , Jakub Kicinski , virtualization@lists.linux-foundation.org, "David S. Miller" , Stefan Hajnoczi , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] vsock: rename vsock_wait_data() Date: Fri, 18 Jun 2021 15:35:25 +0200 Message-Id: <20210618133526.300347-3-sgarzare@redhat.com> In-Reply-To: <20210618133526.300347-1-sgarzare@redhat.com> References: <20210618133526.300347-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org vsock_wait_data() is used only by STREAM and SEQPACKET sockets, so let's rename it to vsock_connectible_wait_data(), using the same nomenclature (connectible) used in other functions after the introduction of SEQPACKET. Signed-off-by: Stefano Garzarella --- net/vmw_vsock/af_vsock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index de8249483081..21ccf450e249 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1866,10 +1866,11 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, return err; } -static int vsock_wait_data(struct sock *sk, struct wait_queue_entry *wait, - long timeout, - struct vsock_transport_recv_notify_data *recv_data, - size_t target) +static int vsock_connectible_wait_data(struct sock *sk, + struct wait_queue_entry *wait, + long timeout, + struct vsock_transport_recv_notify_data *recv_data, + size_t target) { const struct vsock_transport *transport; struct vsock_sock *vsk; @@ -1967,7 +1968,8 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg, while (1) { ssize_t read; - err = vsock_wait_data(sk, &wait, timeout, &recv_data, target); + err = vsock_connectible_wait_data(sk, &wait, timeout, + &recv_data, target); if (err <= 0) break; @@ -2022,7 +2024,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); - err = vsock_wait_data(sk, &wait, timeout, NULL, 0); + err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0); if (err <= 0) goto out; From patchwork Fri Jun 18 13:35:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 12331451 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0571C48BE8 for ; Fri, 18 Jun 2021 13:36:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B57C66124C for ; Fri, 18 Jun 2021 13:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233972AbhFRNiX (ORCPT ); Fri, 18 Jun 2021 09:38:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48778 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233974AbhFRNiG (ORCPT ); Fri, 18 Jun 2021 09:38:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624023356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFwIb7IPOZRbP1IQ9mV70O4nT0A/GjnYdmBaTej5bMs=; b=OtXPGHi93k4blZndryJDUl/FOCz+P2EaC/6Zcx+IYAmim04WcfRnqlk28ITz19vPDhB5/h flrE7PV3Z/DiBeCCOoUOqJafa9eMB5yGupguA/N2ptaYJpimlIKVDpyPZN7hyVTeHKaF+i LTLFDW6BUdRtdnQ0CzqzYX6NeCkDBl8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-12QN6s9jMYqyi6bKQyOXnw-1; Fri, 18 Jun 2021 09:35:55 -0400 X-MC-Unique: 12QN6s9jMYqyi6bKQyOXnw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B98A8100C666; Fri, 18 Jun 2021 13:35:53 +0000 (UTC) Received: from steredhat.lan (ovpn-115-127.ams2.redhat.com [10.36.115.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id B17261000324; Fri, 18 Jun 2021 13:35:47 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Arseny Krasnov , kvm@vger.kernel.org, Stefano Garzarella , Jakub Kicinski , virtualization@lists.linux-foundation.org, "David S. Miller" , Stefan Hajnoczi , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] vsock/virtio: remove redundant `copy_failed` variable Date: Fri, 18 Jun 2021 15:35:26 +0200 Message-Id: <20210618133526.300347-4-sgarzare@redhat.com> In-Reply-To: <20210618133526.300347-1-sgarzare@redhat.com> References: <20210618133526.300347-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When memcpy_to_msg() fails in virtio_transport_seqpacket_do_dequeue(), we already set `dequeued_len` with the negative error value returned by memcpy_to_msg(). So we can directly check `dequeued_len` value instead of using a dedicated flag variable to skip the copy path for the rest of fragments. Signed-off-by: Stefano Garzarella --- net/vmw_vsock/virtio_transport_common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 23704a6bc437..f014ccfdd9c2 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -413,7 +413,6 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, struct virtio_vsock_pkt *pkt; int dequeued_len = 0; size_t user_buf_len = msg_data_left(msg); - bool copy_failed = false; bool msg_ready = false; spin_lock_bh(&vvs->rx_lock); @@ -426,7 +425,7 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, while (!msg_ready) { pkt = list_first_entry(&vvs->rx_queue, struct virtio_vsock_pkt, list); - if (!copy_failed) { + if (dequeued_len >= 0) { size_t pkt_len; size_t bytes_to_copy; @@ -443,11 +442,9 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk, err = memcpy_to_msg(msg, pkt->buf, bytes_to_copy); if (err) { - /* Copy of message failed, set flag to skip - * copy path for rest of fragments. Rest of + /* Copy of message failed. Rest of * fragments will be freed without copy. */ - copy_failed = true; dequeued_len = err; } else { user_buf_len -= bytes_to_copy;