From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6940D67660 for ; Tue, 12 Jan 2021 14:58:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6764D26FE4 for ; Tue, 12 Jan 2021 14:58:48 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9223B26FD8 for ; Tue, 12 Jan 2021 14:58:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5A50A45637 for ; Tue, 12 Jan 2021 14:58:47 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Tue, 12 Jan 2021 14:58:27 +0100 Message-Id: <20210112135830.2798301-18-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210112135830.2798301-1-f.gruenbichler@proxmox.com> References: <20210112135830.2798301-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.224 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_NUMSUBJECT 0.5 Subject ends in numbers excluding current years RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [session.rs] Subject: [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0 X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jan 2021 13:58:48 -0000 PollEvented is no more (it's an internal API now, since tokio no longer wants to expose mio parts in its public API). Switch to AsyncFd, which provides similar mechanisms for non-blocking raw FDs and allows us to drop our own direct mio dependency as well. Signed-off-by: Fabian Grünbichler --- Cargo.toml | 7 +++++-- debian/control | 22 ++++++++++------------ src/fuse_fd.rs | 30 ------------------------------ src/session.rs | 14 ++++++-------- 4 files changed, 21 insertions(+), 52 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef3fa2b..0303522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,8 @@ exclude = [ "build", "debian" ] anyhow = "1.0" futures = "0.3" libc = "0.2" -mio = "0.6.21" -tokio = { version = "0.2", features = ["io-driver", "macros", "signal", "stream"] } +tokio = { version = "1.0", features = ["macros", "net", "signal"] } +tokio-stream = "0.1" + +[dev-dependencies] +tokio = { version = "1.0", features = ["rt-multi-thread"] } diff --git a/debian/control b/debian/control index 7e8c45d..4d20e04 100644 --- a/debian/control +++ b/debian/control @@ -9,12 +9,11 @@ Build-Depends: debhelper (>= 11), librust-anyhow-1+default-dev , librust-futures-0.3+default-dev , librust-libc-0.2+default-dev , - librust-mio-0.6+default-dev (>= 0.6.21-~~) , - librust-tokio-0.2+default-dev , - librust-tokio-0.2+io-driver-dev , - librust-tokio-0.2+macros-dev , - librust-tokio-0.2+signal-dev , - librust-tokio-0.2+stream-dev , + librust-tokio-1+default-dev , + librust-tokio-1+macros-dev , + librust-tokio-1+net-dev , + librust-tokio-1+signal-dev , + librust-tokio-stream-0.1+default-dev , libfuse3-dev Maintainer: Proxmox Support Team Standards-Version: 4.4.1 @@ -29,12 +28,11 @@ Depends: librust-anyhow-1+default-dev, librust-futures-0.3+default-dev, librust-libc-0.2+default-dev, - librust-mio-0.6+default-dev (>= 0.6.21-~~), - librust-tokio-0.2+default-dev, - librust-tokio-0.2+io-driver-dev, - librust-tokio-0.2+macros-dev, - librust-tokio-0.2+signal-dev, - librust-tokio-0.2+stream-dev, + librust-tokio-1+default-dev, + librust-tokio-1+macros-dev, + librust-tokio-1+net-dev, + librust-tokio-1+signal-dev, + librust-tokio-stream-0.1+default-dev, libfuse3-dev Provides: librust-proxmox-fuse+default-dev (= ${binary:Version}), diff --git a/src/fuse_fd.rs b/src/fuse_fd.rs index 68d9e79..0217689 100644 --- a/src/fuse_fd.rs +++ b/src/fuse_fd.rs @@ -3,10 +3,6 @@ use std::io; use std::os::unix::io::{AsRawFd, RawFd}; -use mio::event::Evented; -use mio::unix::EventedFd; -use mio::{Poll, PollOpt, Ready, Token}; - pub struct FuseFd { fd: RawFd, } @@ -38,29 +34,3 @@ impl AsRawFd for FuseFd { self.fd } } - -impl Evented for FuseFd { - fn register( - &self, - poll: &Poll, - token: Token, - interest: Ready, - opts: PollOpt, - ) -> io::Result<()> { - EventedFd(&self.fd).register(poll, token, interest, opts) - } - - fn reregister( - &self, - poll: &Poll, - token: Token, - interest: Ready, - opts: PollOpt, - ) -> io::Result<()> { - EventedFd(&self.fd).reregister(poll, token, interest, opts) - } - - fn deregister(&self, poll: &Poll) -> io::Result<()> { - EventedFd(&self.fd).deregister(poll) - } -} diff --git a/src/session.rs b/src/session.rs index 125492a..78f558d 100644 --- a/src/session.rs +++ b/src/session.rs @@ -12,7 +12,7 @@ use std::{io, mem}; use anyhow::{bail, format_err, Error}; use futures::ready; use futures::stream::{FusedStream, Stream}; -use tokio::io::PollEvented; +use tokio::io::unix::AsyncFd; use crate::fuse_fd::FuseFd; use crate::requests::{self, Request, RequestGuard}; @@ -610,7 +610,7 @@ impl FuseSession { bail!("failed to get fuse session file descriptor"); } - let fuse_fd = PollEvented::new(FuseFd::from_raw(fd)?)?; + let fuse_fd = AsyncFd::new(FuseFd::from_raw(fd)?)?; // disable mount guard self.mounted = false; @@ -650,7 +650,7 @@ unsafe impl Sync for SessionPtr {} pub struct Fuse { session: SessionPtr, fuse_data: Box, - fuse_fd: PollEvented, + fuse_fd: AsyncFd, } // We lose these via the raw session pointer: @@ -691,7 +691,7 @@ impl Stream for Fuse { return Poll::Ready(None); } - ready!(this.fuse_fd.poll_read_ready(cx, mio::Ready::readable()))?; + let mut ready_guard = ready!(this.fuse_fd.poll_read_ready(cx))?; let buf: &mut sys::FuseBuf = match Arc::get_mut(&mut this.fuse_data.fbuf) { Some(buf) => buf, @@ -705,10 +705,8 @@ impl Stream for Fuse { let rc = unsafe { sys::fuse_session_receive_buf(this.session.as_ptr(), Some(buf)) }; if rc == -libc::EAGAIN { - match this.fuse_fd.clear_read_ready(cx, mio::Ready::readable()) { - Ok(()) => continue, - Err(err) => return Poll::Ready(Some(Err(err))), - } + ready_guard.clear_ready(); + continue; } else if rc < 0 { return Poll::Ready(Some(Err(io::Error::from_raw_os_error(-rc)))); } else if rc == 0 { -- 2.20.1