public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-fuse] update to tokio 1.0
Date: Tue, 12 Jan 2021 14:58:27 +0100	[thread overview]
Message-ID: <20210112135830.2798301-18-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20210112135830.2798301-1-f.gruenbichler@proxmox.com>

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 <f.gruenbichler@proxmox.com>
---
 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 <!nocheck>,
  librust-futures-0.3+default-dev <!nocheck>,
  librust-libc-0.2+default-dev <!nocheck>,
- librust-mio-0.6+default-dev (>= 0.6.21-~~) <!nocheck>,
- librust-tokio-0.2+default-dev <!nocheck>,
- librust-tokio-0.2+io-driver-dev <!nocheck>,
- librust-tokio-0.2+macros-dev <!nocheck>,
- librust-tokio-0.2+signal-dev <!nocheck>,
- librust-tokio-0.2+stream-dev <!nocheck>,
+ librust-tokio-1+default-dev <!nocheck>,
+ librust-tokio-1+macros-dev <!nocheck>,
+ librust-tokio-1+net-dev <!nocheck>,
+ librust-tokio-1+signal-dev <!nocheck>,
+ librust-tokio-stream-0.1+default-dev <!nocheck>,
  libfuse3-dev <!nocheck>
 Maintainer: Proxmox Support Team <support@proxmox.com>
 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<FuseData>,
-    fuse_fd: PollEvented<FuseFd>,
+    fuse_fd: AsyncFd<FuseFd>,
 }
 
 // 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





  parent reply	other threads:[~2021-01-12 13:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 13:58 [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 1/4] Cargo.toml: update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 2/4] update to rustyline 7 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 3/4] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox 4/4] tokio 1.0: drop TimeoutFutureExt Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 01/12] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 02/12] tokio 1.0: delay -> sleep Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 03/12] proxmox XXX: use tokio::time::timeout directly Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 04/12] tokio 1.0: AsyncRead/Seek with ReadBuf Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 05/12] tokio: adapt to 1.0 runtime changes Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 06/12] tokio: adapt to 1.0 process:Child changes Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 07/12] tokio 1.0: use ReceiverStream from tokio-stream Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 08/12] tokio 1.0: update to new tokio-openssl interface Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 09/12] tokio 1.0: update to new Signal interface Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 10/12] hyper: use new hyper::upgrade Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 11/12] examples: unify h2 examples Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()' Fabian Grünbichler
2021-01-12 13:58 ` Fabian Grünbichler [this message]
2021-01-12 13:58 ` [pbs-devel] [PATCH pxar 1/3] update to tokio 1.0 Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [RFC pxar 2/3] clippy: use matches! instead of match Fabian Grünbichler
2021-01-12 13:58 ` [pbs-devel] [RFC pxar 3/3] remove futures-io feature Fabian Grünbichler
2021-01-12 14:42   ` Wolfgang Bumiller
2021-01-12 14:52 ` [pbs-devel] [PATCH-SERIES 0/20] update to tokio 1.0 and friends Wolfgang Bumiller
2021-01-14 13:39   ` [pbs-devel] [PATCH proxmox 1/3] fix u2f example Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox-backup] proxmox XXX: adapt to moved ParameterSchema Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 2/3] move ParameterSchema from router to schema Fabian Grünbichler
2021-01-14 13:39     ` [pbs-devel] [PATCH proxmox 3/3] build: add autopkgtest target Fabian Grünbichler
2021-01-14 13:41   ` [pbs-devel] [PATCH pxar 1/2] fix example Fabian Grünbichler
2021-01-14 13:41     ` [pbs-devel] [PATCH pxar 2/2] build: fix --no-default-features Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210112135830.2798301-18-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal