From: Boqun Feng <boqun.feng@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Benno Lossin" <benno.lossin@proton.me>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Wedson Almeida Filho" <wedsonaf@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Martijn Coenen" <maco@android.com>,
"Joel Fernandes" <joel@joelfernandes.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Suren Baghdasaryan" <surenb@google.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Daniel Xu" <dxu@dxuuu.xyz>,
"Martin Rodriguez Reboredo" <yakoyoku@gmail.com>,
"Trevor Gross" <tmgross@umich.edu>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-fsdevel@vger.kernel.org, "Kees Cook" <kees@kernel.org>
Subject: Re: [PATCH v8 3/8] rust: file: add Rust abstraction for `struct file`
Date: Tue, 6 Aug 2024 12:29:20 -0700 [thread overview]
Message-ID: <ZrJ5kORJHsITlxr6@boqun-archlinux> (raw)
In-Reply-To: <CAH5fLgi0MGUhbD0WV99NtU+08HCJG+LYMtx+Ca4gwfo9FR+hTw@mail.gmail.com>
On Tue, Aug 06, 2024 at 10:48:11AM +0200, Alice Ryhl wrote:
[...]
> > > + /// Returns the flags associated with the file.
> > > + ///
> > > + /// The flags are a combination of the constants in [`flags`].
> > > + #[inline]
> > > + pub fn flags(&self) -> u32 {
> > > + // This `read_volatile` is intended to correspond to a READ_ONCE call.
> > > + //
> > > + // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount.
> > > + //
> > > + // FIXME(read_once): Replace with `read_once` when available on the Rust side.
> >
> > Do you know the status of this?
>
> It's still unavailable.
>
I think with our own Atomic API, we can just use atomic_read() here:
yes, I know that to make this is not a UB, we need the C side to also do
atomic write on this `f_flags`, however, my reading of C code seems to
suggest that FS relies on writes to this field is atomic, therefore
unless someone is willing to convert all writes to `f_flags` in C into
a WRITE_ONCE(), nothing more we can do on Rust side. So using
atomic_read() is the correct thing to begin with.
Regards,
Boqun
> > > + unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() }
> > > + }
> > > +}
[...]
next prev parent reply other threads:[~2024-08-06 19:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 14:27 [PATCH v8 0/8] File abstractions needed by Rust Binder Alice Ryhl
2024-07-25 14:27 ` [PATCH v8 1/8] rust: types: add `NotThreadSafe` Alice Ryhl
2024-07-25 14:37 ` Peter Zijlstra
2024-07-25 15:09 ` Alice Ryhl
2024-07-25 15:30 ` Peter Zijlstra
2024-07-25 15:32 ` Alice Ryhl
2024-08-07 10:59 ` Gary Guo
2024-07-25 14:27 ` [PATCH v8 2/8] rust: task: add `Task::current_raw` Alice Ryhl
2024-08-07 14:41 ` Gary Guo
2024-07-25 14:27 ` [PATCH v8 3/8] rust: file: add Rust abstraction for `struct file` Alice Ryhl
2024-08-06 8:44 ` Benno Lossin
2024-08-06 8:48 ` Alice Ryhl
2024-08-06 19:29 ` Boqun Feng [this message]
2024-08-07 8:50 ` Alice Ryhl
2024-08-07 14:46 ` Boqun Feng
2024-08-07 21:59 ` Alice Ryhl
2024-08-08 16:04 ` Boqun Feng
2024-07-25 14:27 ` [PATCH v8 4/8] rust: cred: add Rust abstraction for `struct cred` Alice Ryhl
2024-08-07 14:53 ` Gary Guo
2024-07-25 14:27 ` [PATCH v8 5/8] rust: security: add abstraction for secctx Alice Ryhl
2024-08-07 14:57 ` Gary Guo
2024-07-25 14:27 ` [PATCH v8 6/8] rust: file: add `FileDescriptorReservation` Alice Ryhl
2024-08-07 15:04 ` Gary Guo
2024-07-25 14:27 ` [PATCH v8 7/8] rust: file: add `Kuid` wrapper Alice Ryhl
2024-07-25 14:27 ` [PATCH v8 8/8] rust: file: add abstraction for `poll_table` Alice Ryhl
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=ZrJ5kORJHsITlxr6@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=dan.j.williams@intel.com \
--cc=dxu@dxuuu.xyz \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=joel@joelfernandes.org \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maco@android.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=tkjos@android.com \
--cc=tmgross@umich.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=wedsonaf@gmail.com \
--cc=willy@infradead.org \
--cc=yakoyoku@gmail.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;
as well as URLs for NNTP newsgroup(s).