Re: [PATCH v4 28/39] netfs: Implement support for unbuffered/DIO read

From: David Howells
Date: Tue Dec 19 2023 - 10:47:03 EST


Jeff Layton <jlayton@xxxxxxxxxx> wrote:

> > +static int netfs_copy_xarray_to_iter(struct netfs_io_request *rreq,
> > + struct xarray *xa, struct iov_iter *dst,
> > + unsigned long long start, size_t avail)
> ...
> > + xas_for_each(&xas, folio, ULONG_MAX) {
> > + size_t offset;
> > +
> > + if (xas_retry(&xas, folio))
> > + continue;
> > +
> > + /* There shouldn't be a need to call xas_pause() as no one else
> > + * should be modifying the xarray we're iterating over.
> > + * Really, we only need the RCU readlock to keep lockdep happy
> > + * inside xas_for_each().
> > + */
> > + rcu_read_unlock();
> > +
>
> Are you sure it's still safe to access "folio" once you've dropped the
> rcu_read_lock? I wonder if you need to take a reference or something.
>
> I guess if this is a "private" xarray then nothing should be modifying
> it?

It is a private xarray in this case. The only reason I need the RCU read lock
is because the xarray code will complain if we're not holding it:-/.

Actually, I can probably excise the bounce buffer code for this series as
nothing in 9p or afs currently uses it. It's needed for content crypto - so
ceph will need it.

David