From: Jeff Layton <jlayton@redhat.com>
To: David Howells <dhowells@redhat.com>, linux-cachefs@redhat.com
Cc: ceph-devel@vger.kernel.org,
Anna Schumaker <anna.schumaker@netapp.com>,
Steve French <sfrench@samba.org>,
Dominique Martinet <asmadeus@codewreck.org>,
David Wysochanski <dwysocha@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>,
Jeffle Xu <jefflexu@linux.alibaba.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org,
linux-cifs@vger.kernel.org, v9fs-developer@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 12/20] ceph: Make ceph_init_request() check caps on readahead
Date: Thu, 10 Mar 2022 12:34:34 -0500 [thread overview]
Message-ID: <dd054c962818716e718bd9b446ee5322ca097675.camel@redhat.com> (raw)
In-Reply-To: <164692907694.2099075.10081819855690054094.stgit@warthog.procyon.org.uk>
On Thu, 2022-03-10 at 16:17 +0000, David Howells wrote:
> Move the caps check from ceph_readahead() to ceph_init_request(),
> conditional on the origin being NETFS_READAHEAD so that in a future patch,
> ceph can point its ->readahead() vector directly at netfs_readahead().
>
> Changes
> =======
> ver #3)
> - Split from the patch to add a netfs inode context[1].
> - Need to store the caps got in rreq->netfs_priv for later freeing.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: ceph-devel@vger.kernel.org
> cc: linux-cachefs@redhat.com
> Link: https://lore.kernel.org/r/8af0d47f17d89c06bbf602496dd845f2b0bf25b3.camel@kernel.org/ [1]
> ---
>
> fs/ceph/addr.c | 69 +++++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 41 insertions(+), 28 deletions(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 9189257476f8..6d056db41f50 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -354,6 +354,45 @@ static void ceph_netfs_issue_read(struct netfs_io_subrequest *subreq)
> dout("%s: result %d\n", __func__, err);
> }
>
> +static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
> +{
> + struct inode *inode = rreq->inode;
> + int got = 0, want = CEPH_CAP_FILE_CACHE;
> + int ret = 0;
> +
> + if (file) {
> + struct ceph_rw_context *rw_ctx;
> + struct ceph_file_info *fi = file->private_data;
> +
> + rw_ctx = ceph_find_rw_context(fi);
> + if (rw_ctx)
> + return 0;
> + }
> +
> + if (rreq->origin != NETFS_READAHEAD)
> + return 0;
> +
^^^
I think you should move this check above the if (file) block above it.
We don't need to anything at all if we're not in readahead.
> + /*
> + * readahead callers do not necessarily hold Fcb caps
> + * (e.g. fadvise, madvise).
> + */
> + ret = ceph_try_get_caps(inode, CEPH_CAP_FILE_RD, want, true, &got);
> + if (ret < 0) {
> + dout("start_read %p, error getting cap\n", inode);
> + return ret;
> + }
> +
> + if (!(got & want)) {
> + dout("start_read %p, no cache cap\n", inode);
> + return -EACCES;
> + }
> + if (ret == 0)
> + return -EACCES;
> +
> + rreq->netfs_priv = (void *)(uintptr_t)got;
> + return 0;
> +}
> +
> static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
> {
> struct inode *inode = mapping->host;
> @@ -365,7 +404,7 @@ static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
> }
>
> static const struct netfs_request_ops ceph_netfs_read_ops = {
> - .is_cache_enabled = ceph_is_cache_enabled,
> + .init_request = ceph_init_request,
> .begin_cache_operation = ceph_begin_cache_operation,
> .issue_read = ceph_netfs_issue_read,
> .expand_readahead = ceph_netfs_expand_readahead,
> @@ -393,33 +432,7 @@ static int ceph_readpage(struct file *file, struct page *subpage)
>
> static void ceph_readahead(struct readahead_control *ractl)
> {
> - struct inode *inode = file_inode(ractl->file);
> - struct ceph_file_info *fi = ractl->file->private_data;
> - struct ceph_rw_context *rw_ctx;
> - int got = 0;
> - int ret = 0;
> -
> - if (ceph_inode(inode)->i_inline_version != CEPH_INLINE_NONE)
> - return;
> -
> - rw_ctx = ceph_find_rw_context(fi);
> - if (!rw_ctx) {
> - /*
> - * readahead callers do not necessarily hold Fcb caps
> - * (e.g. fadvise, madvise).
> - */
> - int want = CEPH_CAP_FILE_CACHE;
> -
> - ret = ceph_try_get_caps(inode, CEPH_CAP_FILE_RD, want, true, &got);
> - if (ret < 0)
> - dout("start_read %p, error getting cap\n", inode);
> - else if (!(got & want))
> - dout("start_read %p, no cache cap\n", inode);
> -
> - if (ret <= 0)
> - return;
> - }
> - netfs_readahead(ractl, &ceph_netfs_read_ops, (void *)(uintptr_t)got);
> + netfs_readahead(ractl, &ceph_netfs_read_ops, NULL);
> }
>
> #ifdef CONFIG_CEPH_FSCACHE
>
>
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2022-03-10 17:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 16:13 [PATCH v3 00/20] netfs: Prep for write helpers David Howells
2022-03-10 16:14 ` [PATCH v3 01/20] fscache: export fscache_end_operation() David Howells
2022-03-10 16:15 ` [PATCH v3 02/20] netfs: Generate enums from trace symbol mapping lists David Howells
2022-03-10 16:15 ` [PATCH v3 03/20] netfs: Rename netfs_read_*request to netfs_io_*request David Howells
2022-03-10 16:15 ` [PATCH v3 04/20] netfs: Finish off rename of netfs_read_request to netfs_io_request David Howells
2022-03-10 16:15 ` [PATCH v3 05/20] netfs: Split netfs_io_* object handling out David Howells
2022-03-10 16:16 ` [PATCH v3 06/20] netfs: Adjust the netfs_rreq tracepoint slightly David Howells
2022-03-10 16:16 ` [PATCH v3 07/20] netfs: Trace refcounting on the netfs_io_request struct David Howells
2022-03-10 16:16 ` [PATCH v3 08/20] netfs: Trace refcounting on the netfs_io_subrequest struct David Howells
2022-03-10 16:17 ` [PATCH v3 09/20] netfs: Adjust the netfs_failure tracepoint to indicate non-subreq lines David Howells
2022-03-10 16:17 ` [PATCH v3 10/20] netfs: Refactor arguments for netfs_alloc_read_request David Howells
2022-03-10 16:17 ` [PATCH v3 11/20] netfs: Change ->init_request() to return an error code David Howells
2022-03-10 16:17 ` [PATCH v3 12/20] ceph: Make ceph_init_request() check caps on readahead David Howells
2022-03-10 17:34 ` Jeff Layton [this message]
2022-03-11 13:49 ` David Howells
2022-03-11 13:54 ` Jeff Layton
2022-03-10 16:18 ` [PATCH v3 13/20] netfs: Add a netfs inode context David Howells
2022-03-10 17:52 ` Jeff Layton
2022-03-10 16:18 ` [PATCH v3 14/20] netfs: Add a function to consolidate beginning a read David Howells
2022-03-10 17:55 ` Jeff Layton
2022-03-10 16:18 ` [PATCH v3 15/20] netfs: Prepare to split read_helper.c David Howells
2022-03-10 16:19 ` [PATCH v3 16/20] netfs: Rename read_helper.c to io.c David Howells
2022-03-10 16:19 ` [PATCH v3 17/20] netfs: Split fs/netfs/read_helper.c David Howells
2022-03-10 16:20 ` [PATCH v3 18/20] netfs: Split some core bits out into their own file David Howells
2022-03-10 16:20 ` [PATCH v3 19/20] netfs: Keep track of the actual remote file size David Howells
2022-03-10 16:20 ` [PATCH v3 20/20] afs: Maintain netfs_i_context::remote_i_size David Howells
2022-03-11 14:23 ` [PATCH v3 00/20] netfs: Prep for write helpers Jeff Layton
2022-03-12 8:13 ` Dominique Martinet
2022-03-16 9:06 ` [PATCH v3 13/20] netfs: Add a netfs inode context David Howells
2022-03-18 9:18 ` [PATCH v4 " David Howells
2022-03-18 13:56 ` Jeff Layton
2022-03-18 14:48 ` David Howells
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=dd054c962818716e718bd9b446ee5322ca097675.camel@redhat.com \
--to=jlayton@redhat.com \
--cc=anna.schumaker@netapp.com \
--cc=asmadeus@codewreck.org \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=dwysocha@redhat.com \
--cc=idryomov@gmail.com \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=sfrench@samba.org \
--cc=torvalds@linux-foundation.org \
--cc=v9fs-developer@lists.sourceforge.net \
/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).