From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373981; cv=none; d=zohomail.com; s=zohoarc; b=LG5Wwo+TzLO49oUi9gpIJpPI9tgGBzQMbsc08B5W49io1OzK8+E3XKrD6NYlApEKtSjIe4BejM0yLIkoTuRzkwJtcaP15aHxnU4jUXDtOCCjvwM/xSny3hXviII5wu8tonF8BNC1tJXjchpUK0RbQHhZxHNzrLoPuufQkF20W0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373981; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/5yvAN4kT53e/nIfmuECRDsUp0kSLNj/hY2xN7GrUq4=; b=OZFv9xpuX0GjyQuvqDCsIr8JRBmZwbGob8wz7EBPHoZAwQIMkGpzZjCIA/vNWFhQRu6eIosSSEbFe9yHCwCcO8d6QmNji/p+84EqoO6QAjleVO58rW26PlJAHOyul22XWRmeYDvYhyQ4OGSIH9VK9wsY98XKnrbMuOpA1LAtvXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162137398197677.36252104727646; Tue, 18 May 2021 14:39:41 -0700 (PDT) Received: from localhost ([::1]:42558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7RE-0006X9-VS for importer@patchew.org; Tue, 18 May 2021 17:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Ng-00077J-AT for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nb-0007Oi-E6 for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:00 -0400 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-411-Jfm69jm7OXOoBgsrWHXmyQ-1; Tue, 18 May 2021 17:35:51 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0135FCB6 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9EB460C04; Tue, 18 May 2021 21:35:46 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 5F097223D99; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/5yvAN4kT53e/nIfmuECRDsUp0kSLNj/hY2xN7GrUq4=; b=TLol5U/8wnnB/yB7KAvFiySnOpwiHeTiHFLSNO5Wb105+GwfPayAKl7uQM4vzm2UHlh5Gj unsLKbMYdschOLlJA6yOery4iIk6SKYMFNMWBbDjajQIVfJCeNhnqYShMfypysdnxhh986 zkudylWWD9qkMBpB78WFvr679sUzKg0= X-MC-Unique: Jfm69jm7OXOoBgsrWHXmyQ-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 1/7] virtiofsd: Check for EINTR in preadv() and retry Date: Tue, 18 May 2021 17:35:32 -0400 Message-Id: <20210518213538.693422-2-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We don't seem to check for EINTR and retry. There are other places in code where we check for EINTR. So lets add a check. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 9efdbd8ffd..755d7fb25c 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -421,6 +421,9 @@ int virtio_send_data_iov(struct fuse_session *se, struc= t fuse_chan *ch, =20 if (ret =3D=3D -1) { ret =3D errno; + if (ret =3D=3D EINTR) { + continue; + } fuse_log(FUSE_LOG_DEBUG, "%s: preadv failed (%m) len=3D%zd\n", __func__, len); goto err; --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373989; cv=none; d=zohomail.com; s=zohoarc; b=bbUHb33iiMgKf0+lMjQjQ9TtNTQjj35oBFwL+7it8tPhFi/TIiR++RedVPCoB6e0vUAfSLGat+P5VYQm70qPmVfNj0YO+eEXx6q9Gc8aiGq5dWiTt8XRp3v5qUa9H0dst13Oyyf5dfRgLVNrFten51Erjqkc5+iKZSJxJg85SEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373989; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EflinHozY16ONlMhPaLwjNG+o4Ob6GnaBxxbpep4Ojo=; b=OUM9dfr2aKDT1k6PIpISDkTJHJzpEJt0NPPyBWHyvYIgptBq3RBA1sXwKI47JulaRXh+y9+1ixF4zBIo6Vg3EX+i23TMU9zWASL0x6kQGBCxY5WAFp4AeXITzXsgbJsbk3KtqKOLdBTmRU02MQ2etLoR0XyXDpbXXgjsFsZwovs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621373989239789.495128032113; Tue, 18 May 2021 14:39:49 -0700 (PDT) Received: from localhost ([::1]:43346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7RM-000757-8k for importer@patchew.org; Tue, 18 May 2021 17:39:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nf-000760-Px for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nb-0007Oe-D8 for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:59 -0400 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-363-eJwLE8caM8ihbGpW93XBgg-1; Tue, 18 May 2021 17:35:51 -0400 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 3BDFE180FD62 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA4A1100AE43; Tue, 18 May 2021 21:35:46 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 62B75225FCE; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EflinHozY16ONlMhPaLwjNG+o4Ob6GnaBxxbpep4Ojo=; b=E0B2em7ipNJ9Ui0y08t3NhuVrwizeGMadRDNKSkMa4dPmcnUcBFW1ezoylaw5YqFf6uxDo GKK5fO1aikXx5tnznVIOwNeMVlSDtk/aeGUQcrdWZ5vcDtBI1N3COFl9LWAqiqTu0ycHvX uPWH4YBIsTrY8xaSEAr4+PA0vLV6U3U= X-MC-Unique: eJwLE8caM8ihbGpW93XBgg-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 2/7] virtiofsd: Get rid of unreachable code in read Date: Tue, 18 May 2021 17:35:33 -0400 Message-Id: <20210518213538.693422-3-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" pvreadv() can return following. - error - 0 in case of EOF - short read We seem to handle all the cases already. We are retrying read in case of short read. So another check for short read seems like dead code. Get rid of it. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 755d7fb25c..28e2974d1a 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -446,11 +446,6 @@ int virtio_send_data_iov(struct fuse_session *se, stru= ct fuse_chan *ch, in_sg_left); break; } - if (ret !=3D len) { - fuse_log(FUSE_LOG_DEBUG, "%s: ret!=3Dlen\n", __func__); - ret =3D EIO; - goto err; - } in_sg_left -=3D ret; len -=3D ret; } while (in_sg_left); --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373876; cv=none; d=zohomail.com; s=zohoarc; b=aFEcJN5Vt+45WhEaT8DSMNcBl8upxcv6UFI90M8iMvaT26ta8V7K1dQVJHq2PXT+8hRmEgQ6Mpbo2Ios0a+4z7bO+Y2c1NX3bmydsQF/fo3dVD+yJWg5qWThJgTI8Z+VxhlM/Uxim3gk6EvDYURbNHnft5baG7yCaTfDJEnDjqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373876; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zh9ddEMVe0cvJYMbA2aLZHBcCUYjRQqS6U2FtHGIOr4=; b=K5/Qf9lvSRcp7zPK/NBlbliN9/EHYnKjtF8f+QNaHrpgjRAdti/p7oJfCfD+E0mYBcf5loMk6GvN9qZVkhjbX4qWhHPlsaY6hABheG1uylE8cTm56+ovqwIrAwAHQR2Uo4iF0bd5oiXDiRie1gWC8rixEm+YUhAizVwpJRBKNSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621373876655133.83453585155246; Tue, 18 May 2021 14:37:56 -0700 (PDT) Received: from localhost ([::1]:35090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7PW-0001aH-Ed for importer@patchew.org; Tue, 18 May 2021 17:37:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nf-00074S-3r for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Na-0007P1-Mp for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:58 -0400 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-480-iHVHuCpIMZenw7xmgE2jQw-1; Tue, 18 May 2021 17:35:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A24A4180FD64 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBB9D18534; Tue, 18 May 2021 21:35:46 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 678C2225FCF; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zh9ddEMVe0cvJYMbA2aLZHBcCUYjRQqS6U2FtHGIOr4=; b=LtxqkQ7RZH3N8PMzx73dYhuU1mPB+eo9npJ444AL1yOX6jYTuGfQRcRAE1gmuB7TiFdCxf QlKh7QJK/5+GQNwB2XIL7hsLA5pAFl3+YilbpV//RAtwO20voE+rOD6YXfEcoys5PJ0z0L 4/p+tte4fe7Ma9WTWzcVb+tucrabLFU= X-MC-Unique: iHVHuCpIMZenw7xmgE2jQw-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 3/7] virtiofsd: Use iov_discard_front() to skip bytes Date: Tue, 18 May 2021 17:35:34 -0400 Message-Id: <20210518213538.693422-4-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" There are places where we need to skip few bytes from front of the iovec array. We have our own custom code for that. Looks like iov_discard_front() can do same thing. So use that helper instead. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 28e2974d1a..09674f2e90 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -389,23 +389,15 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, memcpy(in_sg_cpy, in_sg, sizeof(struct iovec) * in_num); /* These get updated as we skip */ struct iovec *in_sg_ptr =3D in_sg_cpy; - int in_sg_cpy_count =3D in_num; + unsigned int in_sg_cpy_count =3D in_num; =20 /* skip over parts of in_sg that contained the header iov */ size_t skip_size =3D iov_len; =20 size_t in_sg_left =3D 0; do { - while (skip_size !=3D 0 && in_sg_cpy_count) { - if (skip_size >=3D in_sg_ptr[0].iov_len) { - skip_size -=3D in_sg_ptr[0].iov_len; - in_sg_ptr++; - in_sg_cpy_count--; - } else { - in_sg_ptr[0].iov_len -=3D skip_size; - in_sg_ptr[0].iov_base +=3D skip_size; - break; - } + if (skip_size !=3D 0) { + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } =20 int i; --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373874; cv=none; d=zohomail.com; s=zohoarc; b=Gm0SXyJVuuBu/u+HbYlPjDLmgySdRh4veYEH5niE6Fz+9A35xI/CfTdVSocHysTpE5Whac/Ih+8dxua/7reWwXJ/uFOMHu7GPCSCAg756Vwm9EdmKLFHppgYOzJ0vQf1XVhxTEOoaFEO1MmCv4p3ZKAaBATr6GPw8qvVIRzUboE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373874; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e+uyz+LzW+o6MLjH9sq2rwmARVo14wdKYEgIBggWlgI=; b=feeNbqj7EAskxmsI5UDCyeWKLrjdSb2SGN6cS4mixQ49tOYwUr28wONFt7Kb7u8CXXzA+uU6saiVNS/DYB8zgfX+bvU58ccP1qLzD/Tnzcs+DHyg/4P8w7SwbRfjfZ0bJXTAOoN/WZy3Tp0OaddIJQB+bm/ii1jSM43HKIzIoLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621373874369425.83598993580415; Tue, 18 May 2021 14:37:54 -0700 (PDT) Received: from localhost ([::1]:34930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7PV-0001TH-5G for importer@patchew.org; Tue, 18 May 2021 17:37:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Ne-00071b-0v for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23310) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Na-0007P5-Ji for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:57 -0400 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-411-sDg8ueV7P9qg_42sOFBdiA-1; Tue, 18 May 2021 17:35:52 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90E49801107 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id F27A860855; Tue, 18 May 2021 21:35:46 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 6C86A225FD0; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e+uyz+LzW+o6MLjH9sq2rwmARVo14wdKYEgIBggWlgI=; b=jVq1RV3OhTWA5CNkK1UJxc5xSA8+Q6KTyRaFK4MFxa+/NgmpPDfotGS/DD3V3Uh1d+DV5P Hr4ZSoc4icQ+cYDqc/gb0BAtd/MziwyQR2P7u9c4AtF7wEra9TICDBrpY6+ePaACScxQSq gExUgcA29snb/LXVuEV0x7dv0ac3apo= X-MC-Unique: sDg8ueV7P9qg_42sOFBdiA-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 4/7] virtiofsd: get rid of in_sg_left variable Date: Tue, 18 May 2021 17:35:35 -0400 Message-Id: <20210518213538.693422-5-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" in_sg_left seems to be being used primarly for debugging purpose. It is keeping track of how many bytes are left in the scatter list we are reading into. We already have another variable "len" which keeps track how many bytes are left to be read. And in_sg_left is greater than or equal to len. We have already ensured that in the beginning of function. if (in_len < tosend_len) { fuse_log(FUSE_LOG_ERR, "%s: elem %d too small for data len %zd\n", __func__, elem->index, tosend_len); ret =3D E2BIG; goto err; } So in_sg_left seems like a redundant variable. It probably was useful for debugging when code was being developed. Get rid of it. It helps simplify this function. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 09674f2e90..ed5146d7a6 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -394,20 +394,16 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, /* skip over parts of in_sg that contained the header iov */ size_t skip_size =3D iov_len; =20 - size_t in_sg_left =3D 0; do { if (skip_size !=3D 0) { iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); } =20 - int i; - for (i =3D 0, in_sg_left =3D 0; i < in_sg_cpy_count; i++) { - in_sg_left +=3D in_sg_ptr[i].iov_len; - } fuse_log(FUSE_LOG_DEBUG, "%s: after skip skip_size=3D%zd in_sg_cpy_count=3D%d " - "in_sg_left=3D%zd\n", - __func__, skip_size, in_sg_cpy_count, in_sg_left); + "len remaining=3D%zd\n", __func__, skip_size, in_sg_cpy_c= ount, + len); + ret =3D preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos); =20 @@ -434,13 +430,12 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, } if (!ret) { /* EOF case? */ - fuse_log(FUSE_LOG_DEBUG, "%s: !ret in_sg_left=3D%zd\n", __func= __, - in_sg_left); + fuse_log(FUSE_LOG_DEBUG, "%s: !ret len remaining=3D%zd\n", __f= unc__, + len); break; } - in_sg_left -=3D ret; len -=3D ret; - } while (in_sg_left); + } while (len); =20 /* Need to fix out->len on EOF */ if (len) { --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621374152; cv=none; d=zohomail.com; s=zohoarc; b=FYWsA+ivvw8ulDmzydtJwIvlPQk7dB1DP4PWkVcZXD0x/pokPOAQ7TnqOGc/ll8yIFSBcgzbGXYdHI4FjHZCsVj9E90o3n0/J1/wyX2Q8+gsfB9GjUyZKSwmiteOeeY9dk3nQSVWDBy1pOX1SNFsamVLzUM2stjHu2L1U577pnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621374152; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9OYGtNtPHDdV664HpKsVq0lYNOOW4zefDKfQp7oxbnU=; b=QcuqEg+q07iyZWShQNooXoOq+27K9ujXbZKqfr6ryYMCJTcx9CTd7ve/Lxsl9KD0a+TPABqvU3WF/OYLGemZD518pnAProG890fmaOlKnaFb2HYo+7O2kVyQpdTkQ1rVj7MZSb+6NAkJ0RoIbBoOGG85Rjzl5f1k/FcJ8zOccHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621374152677468.37540563168034; Tue, 18 May 2021 14:42:32 -0700 (PDT) Received: from localhost ([::1]:47718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7Tz-0001ir-GU for importer@patchew.org; Tue, 18 May 2021 17:42:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Ng-00077i-EO for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42200) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nd-0007RQ-9c for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:00 -0400 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-592-aD0d19B5PdmqRNqs6uPAcQ-1; Tue, 18 May 2021 17:35:55 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 432A6180FD60 for ; Tue, 18 May 2021 21:35:54 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD9842C01E; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 7213A225FD1; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9OYGtNtPHDdV664HpKsVq0lYNOOW4zefDKfQp7oxbnU=; b=VzujDYqnewntKHqKlOTYmI6CdeJ68+m0OSyi3P7lhZkmmh36lplTPVruDpWyNtO+5/Al0i mZfc0+4Q4i66nOyfjgVYjz9OQG6IPMY5kl6fDaRhlt0DP77zwOF1Q+cq6gCcj7hZpR7QfS 2RX3dL3atdNenvAMA6BC6/zTZlGC96c= X-MC-Unique: aD0d19B5PdmqRNqs6uPAcQ-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 5/7] virtiofsd: Simplify skip byte logic Date: Tue, 18 May 2021 17:35:36 -0400 Message-Id: <20210518213538.693422-6-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We need to skip bytes in two cases. a. Before we start reading into in_sg, we need to skip iov_len bytes in the beginning which typically will have fuse_out_header. b. If preadv() does a short read, then we need to retry preadv() with remainig bytes and skip the bytes preadv() read in short read. For case a, there is no reason that skipping logic be inside the while loop. Move it outside. And only retain logic "b" inside while loop. Also get rid of variable "skip_size". Looks like we can do without it. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index ed5146d7a6..49c7dd788a 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -392,17 +392,11 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, unsigned int in_sg_cpy_count =3D in_num; =20 /* skip over parts of in_sg that contained the header iov */ - size_t skip_size =3D iov_len; + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, iov_len); =20 do { - if (skip_size !=3D 0) { - iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, skip_size); - } - - fuse_log(FUSE_LOG_DEBUG, - "%s: after skip skip_size=3D%zd in_sg_cpy_count=3D%d " - "len remaining=3D%zd\n", __func__, skip_size, in_sg_cpy_c= ount, - len); + fuse_log(FUSE_LOG_DEBUG, "%s: in_sg_cpy_count=3D%d len remaining= =3D%zd\n", + __func__, in_sg_cpy_count, len); =20 ret =3D preadv(buf->buf[0].fd, in_sg_ptr, in_sg_cpy_count, buf->buf[0].pos); @@ -421,7 +415,7 @@ int virtio_send_data_iov(struct fuse_session *se, struc= t fuse_chan *ch, if (ret < len && ret) { fuse_log(FUSE_LOG_DEBUG, "%s: ret < len\n", __func__); /* Skip over this much next time around */ - skip_size =3D ret; + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, ret); buf->buf[0].pos +=3D ret; len -=3D ret; =20 --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373882; cv=none; d=zohomail.com; s=zohoarc; b=LQHQB+RA/Jj/ypL0iwnos2Lb0+7m6JC15fm+BY5YJ2JdsK5HfmUFInAiJBRWLiOqtMAEwJIXRpHR4FYh/6y8WI4/hpViprvO7/cjhlxjy0i5tuhqXSCaDyONkElXiuxXmEc2Ka4OPIdjyitTz43Lj0q3CqY391Gnb9JGETvG1HI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PVgeimCCcOQj7T5eutXoLku08t2SLftmtHcuX7Bb/uU=; b=hybPjDHgl49/uLZW51niVh3Ml8L+wlQI8uy5TLISz5wOKhsqs1uZDFDQq7EuI3PW9EcikdTB8zS4QMyCtNWIFOQPHMAkoOq82LmC6MyC5CvuqQyLyjTpH6iECcB90KS4X5rYhYBXNwHw+D9OIvIfKPf4ic+UwDrsH7RWRa1VOCQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621373882865874.3593547038586; Tue, 18 May 2021 14:38:02 -0700 (PDT) Received: from localhost ([::1]:35856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7Pd-00024l-OE for importer@patchew.org; Tue, 18 May 2021 17:38:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Ne-00074E-W7 for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Na-0007Ol-Hu for qemu-devel@nongnu.org; Tue, 18 May 2021 17:35:58 -0400 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-395-amLbHgASPUKz6mp4Lbndwg-1; Tue, 18 May 2021 17:35:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D08C3180FD65 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADF295E273; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 7740B225FD2; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PVgeimCCcOQj7T5eutXoLku08t2SLftmtHcuX7Bb/uU=; b=Ocj72HspF2zqZwra2HrJgCi84t/zM498u64CN4oX+jO9fH2C45jo0McC/Tjaabi7uYl4JR r+Rrh47PUY97MSrpmYRUIJ+9n6y7J6r+mgYL3vPomCET4JRuH7whGOwZZ5r1Cm+hodpruJ WH+TMDbbE+EUP+SMtgAALJklr49DQ0M= X-MC-Unique: amLbHgASPUKz6mp4Lbndwg-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 6/7] virtiofsd: Check EOF before short read Date: Tue, 18 May 2021 17:35:37 -0400 Message-Id: <20210518213538.693422-7-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In virtio_send_data_iov() we are checking first for short read and then EOF condition. Change the order. Basically check for error and EOF first and last remaining piece is short ready which will lead to retry automatically at the end of while loop. Just that it is little simpler to read to the code. There is no need to call "continue" and also one less call of "len-=3Dret". Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 49c7dd788a..99f91c9d87 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -410,25 +410,24 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, __func__, len); goto err; } - fuse_log(FUSE_LOG_DEBUG, "%s: preadv ret=3D%d len=3D%zd\n", __func= __, - ret, len); - if (ret < len && ret) { - fuse_log(FUSE_LOG_DEBUG, "%s: ret < len\n", __func__); - /* Skip over this much next time around */ - iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, ret); - buf->buf[0].pos +=3D ret; - len -=3D ret; =20 - /* Lets do another read */ - continue; - } if (!ret) { /* EOF case? */ fuse_log(FUSE_LOG_DEBUG, "%s: !ret len remaining=3D%zd\n", __f= unc__, len); break; } + fuse_log(FUSE_LOG_DEBUG, "%s: preadv ret=3D%d len=3D%zd\n", __func= __, + ret, len); + len -=3D ret; + /* Short read. Retry reading remaining bytes */ + if (len) { + fuse_log(FUSE_LOG_DEBUG, "%s: ret < len\n", __func__); + /* Skip over this much next time around */ + iov_discard_front(&in_sg_ptr, &in_sg_cpy_count, ret); + buf->buf[0].pos +=3D ret; + } } while (len); =20 /* Need to fix out->len on EOF */ --=20 2.25.4 From nobody Wed May 15 21:21:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621373980; cv=none; d=zohomail.com; s=zohoarc; b=mXfuPHmJtPLxfWLRWiHu/5mwGwInwpNwf82SMTIamIp4RSbNBhJWQSO96dQa4wZhNikV5f0nNifQEEo5pq7K8/PfVmgbmnb2j1IOkq95SSnOjllbW9O1esknDvkBdRQbb1Td9lCve/OMSkPqdtbfuFh6QH3aDHrxGoFrv731GVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621373980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CXaWsSp3fcTJyBQkg69rL3L7w9meW01k9sgY/cTMKM4=; b=oCuhfnCIh88QJliTpJX+LsA5/zXaTdDNKAMTen3U5rwPn8Y8HuMuourGIDDZYd9VN7h7h4DfDZCk3aEk+BCGaMlruQ8tEHnfNTeo65atecoFrZblpzA+Ub1WtQR03CcAQiKlQgoBpwoVMhV60cHB4g2TlWQgowNqBEX5L+P4I88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162137398091166.04484316862329; Tue, 18 May 2021 14:39:40 -0700 (PDT) Received: from localhost ([::1]:42468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lj7RD-0006TP-TB for importer@patchew.org; Tue, 18 May 2021 17:39:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nh-0007CH-L2 for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lj7Nb-0007Of-AW for qemu-devel@nongnu.org; Tue, 18 May 2021 17:36:01 -0400 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-545-AD9UqbBVMVKwDc0pAHSR1w-1; Tue, 18 May 2021 17:35:51 -0400 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 C88EE107ACE3 for ; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-77.rdu2.redhat.com [10.10.114.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id A786110074E0; Tue, 18 May 2021 21:35:50 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id 7BFFA225FD3; Tue, 18 May 2021 17:35:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621373753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CXaWsSp3fcTJyBQkg69rL3L7w9meW01k9sgY/cTMKM4=; b=fuUePIyiKigsfkCt85kN1oWJdYgt989TWCWdGVngXjn5Z3oQKL6JwUASQATT2o5PR040cA ftyDxT3JAMgPpYi+QBJc9lMU0BKLpx6qksejLicVmJ6UywmPagzlmsLzXp9DeH/bdr7sRz VSX1sZQHilyWzpIPhY4e4AUBD38xt48= X-MC-Unique: AD9UqbBVMVKwDc0pAHSR1w-1 From: Vivek Goyal To: qemu-devel@nongnu.org, virtio-fs@redhat.com Subject: [PATCH v2 7/7] virtiofsd: Set req->reply_sent right after sending reply Date: Tue, 18 May 2021 17:35:38 -0400 Message-Id: <20210518213538.693422-8-vgoyal@redhat.com> In-Reply-To: <20210518213538.693422-1-vgoyal@redhat.com> References: <20210518213538.693422-1-vgoyal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vgoyal@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=vgoyal@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.374, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ckuehl@redhat.com, dgilbert@redhat.com, vgoyal@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" There is no reason to set it in label "err". We should be able to set it right after sending reply. It is easier to read. Also got rid of label "err" because now only thing it was doing was return a code. We can return from the error location itself and no need to first jump to label "err". Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Vivek Goyal --- tools/virtiofsd/fuse_virtio.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tools/virtiofsd/fuse_virtio.c b/tools/virtiofsd/fuse_virtio.c index 99f91c9d87..fa4aff9b0e 100644 --- a/tools/virtiofsd/fuse_virtio.c +++ b/tools/virtiofsd/fuse_virtio.c @@ -366,14 +366,12 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, if (in_len < sizeof(struct fuse_out_header)) { fuse_log(FUSE_LOG_ERR, "%s: elem %d too short for out_header\n", __func__, elem->index); - ret =3D E2BIG; - goto err; + return E2BIG; } if (in_len < tosend_len) { fuse_log(FUSE_LOG_ERR, "%s: elem %d too small for data len %zd\n", __func__, elem->index, tosend_len); - ret =3D E2BIG; - goto err; + return E2BIG; } =20 /* TODO: Limit to 'len' */ @@ -408,7 +406,7 @@ int virtio_send_data_iov(struct fuse_session *se, struc= t fuse_chan *ch, } fuse_log(FUSE_LOG_DEBUG, "%s: preadv failed (%m) len=3D%zd\n", __func__, len); - goto err; + return ret; } =20 if (!ret) { @@ -438,21 +436,14 @@ int virtio_send_data_iov(struct fuse_session *se, str= uct fuse_chan *ch, out_sg->len =3D tosend_len; } =20 - ret =3D 0; - vu_dispatch_rdlock(qi->virtio_dev); pthread_mutex_lock(&qi->vq_lock); vu_queue_push(dev, q, elem, tosend_len); vu_queue_notify(dev, q); pthread_mutex_unlock(&qi->vq_lock); vu_dispatch_unlock(qi->virtio_dev); - -err: - if (ret =3D=3D 0) { - req->reply_sent =3D true; - } - - return ret; + req->reply_sent =3D true; + return 0; } =20 static __thread bool clone_fs_called; --=20 2.25.4