From: David Howells <dhowells@redhat.com>
To: Viacheslav Dubeyko <slava@dubeyko.com>,
Alex Markuze <amarkuze@redhat.com>
Cc: David Howells <dhowells@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>,
Jeff Layton <jlayton@kernel.org>,
Dongsheng Yang <dongsheng.yang@easystack.cn>,
ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 26/35] ceph: Kill ceph_rw_context
Date: Thu, 13 Mar 2025 23:33:18 +0000 [thread overview]
Message-ID: <20250313233341.1675324-27-dhowells@redhat.com> (raw)
In-Reply-To: <20250313233341.1675324-1-dhowells@redhat.com>
With all invokers of readahead:
- read() and co.
- splice()
- fadvise(POSIX_FADV_WILLNEED)
- madvise(MADV_WILLNEED)
- fault-in
now getting the FILE_CACHE cap or the LAZYIO cap and holding it across
readahead invocation, there's no need for the ceph_rw_context. It can be
assumed that we have one or other cap - and apparently it doesn't matter
which as we don't actually check rw_ctx->caps.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Viacheslav Dubeyko <slava@dubeyko.com>
cc: Alex Markuze <amarkuze@redhat.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: ceph-devel@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
fs/ceph/addr.c | 19 +++++++------------
fs/ceph/file.c | 13 +------------
fs/ceph/super.h | 47 -----------------------------------------------
3 files changed, 8 insertions(+), 71 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 7c89cafcb91a..27f27ab24446 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -473,18 +473,16 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
if (!priv)
return -ENOMEM;
+ /*
+ * If we are doing readahead triggered by a read, fault-in or
+ * MADV/FADV_WILLNEED, someone higher up the stack must be holding the
+ * FILE_CACHE and/or LAZYIO caps.
+ */
if (file) {
- struct ceph_rw_context *rw_ctx;
- struct ceph_file_info *fi = file->private_data;
-
priv->file_ra_pages = file->f_ra.ra_pages;
priv->file_ra_disabled = file->f_mode & FMODE_RANDOM;
-
- rw_ctx = ceph_find_rw_context(fi);
- if (rw_ctx) {
- rreq->netfs_priv = priv;
- return 0;
- }
+ rreq->netfs_priv = priv;
+ return 0;
}
/*
@@ -1982,10 +1980,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf)
if ((got & (CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO)) ||
!ceph_has_inline_data(ci)) {
- CEPH_DEFINE_RW_CONTEXT(rw_ctx, got);
- ceph_add_rw_context(fi, &rw_ctx);
ret = filemap_fault(vmf);
- ceph_del_rw_context(fi, &rw_ctx);
doutc(cl, "%llx.%llx %llu drop cap refs %s ret %x\n",
ceph_vinop(inode), off, ceph_cap_string(got), ret);
} else
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index b876cecbaba5..4512215cccc6 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -229,8 +229,6 @@ static int ceph_init_file_info(struct inode *inode, struct file *file,
ceph_get_fmode(ci, fmode, 1);
fi->fmode = fmode;
- spin_lock_init(&fi->rw_contexts_lock);
- INIT_LIST_HEAD(&fi->rw_contexts);
fi->filp_gen = READ_ONCE(ceph_inode_to_fs_client(inode)->filp_gen);
if ((file->f_mode & FMODE_WRITE) && ceph_has_inline_data(ci)) {
@@ -999,7 +997,6 @@ int ceph_release(struct inode *inode, struct file *file)
struct ceph_dir_file_info *dfi = file->private_data;
doutc(cl, "%p %llx.%llx dir file %p\n", inode,
ceph_vinop(inode), file);
- WARN_ON(!list_empty(&dfi->file_info.rw_contexts));
ceph_put_fmode(ci, dfi->file_info.fmode, 1);
@@ -1012,7 +1009,6 @@ int ceph_release(struct inode *inode, struct file *file)
struct ceph_file_info *fi = file->private_data;
doutc(cl, "%p %llx.%llx regular file %p\n", inode,
ceph_vinop(inode), file);
- WARN_ON(!list_empty(&fi->rw_contexts));
ceph_fscache_unuse_cookie(inode, file->f_mode & FMODE_WRITE);
ceph_put_fmode(ci, fi->fmode, 1);
@@ -2154,13 +2150,10 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
retry_op = READ_INLINE;
}
} else {
- CEPH_DEFINE_RW_CONTEXT(rw_ctx, got);
doutc(cl, "async %p %llx.%llx %llu~%u got cap refs on %s\n",
inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len,
ceph_cap_string(got));
- ceph_add_rw_context(fi, &rw_ctx);
ret = generic_file_read_iter(iocb, to);
- ceph_del_rw_context(fi, &rw_ctx);
}
doutc(cl, "%p %llx.%llx dropping cap refs on %s = %d\n",
@@ -2256,7 +2249,6 @@ static ssize_t ceph_splice_read(struct file *in, loff_t *ppos,
struct ceph_inode_info *ci = ceph_inode(inode);
ssize_t ret;
int want = 0, got = 0;
- CEPH_DEFINE_RW_CONTEXT(rw_ctx, 0);
dout("splice_read %p %llx.%llx %llu~%zu trying to get caps on %p\n",
inode, ceph_vinop(inode), *ppos, len, inode);
@@ -2291,10 +2283,7 @@ static ssize_t ceph_splice_read(struct file *in, loff_t *ppos,
dout("splice_read %p %llx.%llx %llu~%zu got cap refs on %s\n",
inode, ceph_vinop(inode), *ppos, len, ceph_cap_string(got));
- rw_ctx.caps = got;
- ceph_add_rw_context(fi, &rw_ctx);
ret = filemap_splice_read(in, ppos, pipe, len, flags);
- ceph_del_rw_context(fi, &rw_ctx);
dout("splice_read %p %llx.%llx dropping cap refs on %s = %zd\n",
inode, ceph_vinop(inode), ceph_cap_string(got), ret);
@@ -3177,7 +3166,7 @@ static int ceph_fadvise(struct file *file, loff_t offset, loff_t len, int advice
goto out;
}
- if ((got & want) == want) {
+ if (got & want) {
doutc(cl, "fadvise(WILLNEED) %p %llx.%llx %llu~%llu got cap refs on %s\n",
inode, ceph_vinop(inode), offset, len,
ceph_cap_string(got));
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index b072572e2cf4..14784ad86670 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -833,10 +833,6 @@ extern void change_auth_cap_ses(struct ceph_inode_info *ci,
struct ceph_file_info {
short fmode; /* initialized on open */
short flags; /* CEPH_F_* */
-
- spinlock_t rw_contexts_lock;
- struct list_head rw_contexts;
-
u32 filp_gen;
};
@@ -859,49 +855,6 @@ struct ceph_dir_file_info {
int dir_info_len;
};
-struct ceph_rw_context {
- struct list_head list;
- struct task_struct *thread;
- int caps;
-};
-
-#define CEPH_DEFINE_RW_CONTEXT(_name, _caps) \
- struct ceph_rw_context _name = { \
- .thread = current, \
- .caps = _caps, \
- }
-
-static inline void ceph_add_rw_context(struct ceph_file_info *cf,
- struct ceph_rw_context *ctx)
-{
- spin_lock(&cf->rw_contexts_lock);
- list_add(&ctx->list, &cf->rw_contexts);
- spin_unlock(&cf->rw_contexts_lock);
-}
-
-static inline void ceph_del_rw_context(struct ceph_file_info *cf,
- struct ceph_rw_context *ctx)
-{
- spin_lock(&cf->rw_contexts_lock);
- list_del(&ctx->list);
- spin_unlock(&cf->rw_contexts_lock);
-}
-
-static inline struct ceph_rw_context*
-ceph_find_rw_context(struct ceph_file_info *cf)
-{
- struct ceph_rw_context *ctx, *found = NULL;
- spin_lock(&cf->rw_contexts_lock);
- list_for_each_entry(ctx, &cf->rw_contexts, list) {
- if (ctx->thread == current) {
- found = ctx;
- break;
- }
- }
- spin_unlock(&cf->rw_contexts_lock);
- return found;
-}
-
struct ceph_readdir_cache_control {
struct folio *folio;
struct dentry **dentries;
next prev parent reply other threads:[~2025-03-13 23:35 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-13 23:32 [RFC PATCH 00/35] ceph, rbd, netfs: Make ceph fully use netfslib David Howells
2025-03-13 23:32 ` [RFC PATCH 01/35] ceph: Fix incorrect flush end position calculation David Howells
2025-03-13 23:32 ` [RFC PATCH 02/35] libceph: Rename alignment to offset David Howells
2025-03-14 19:04 ` Viacheslav Dubeyko
2025-03-14 20:01 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 03/35] libceph: Add a new data container type, ceph_databuf David Howells
2025-03-14 20:06 ` Viacheslav Dubeyko
2025-03-17 11:27 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 04/35] ceph: Convert ceph_mds_request::r_pagelist to a databuf David Howells
2025-03-14 22:27 ` slava
2025-03-17 11:52 ` David Howells
2025-03-20 20:34 ` Viacheslav Dubeyko
2025-03-20 22:01 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 05/35] libceph: Add functions to add ceph_databufs to requests David Howells
2025-03-13 23:32 ` [RFC PATCH 06/35] rbd: Use ceph_databuf for rbd_obj_read_sync() David Howells
2025-03-17 19:08 ` Viacheslav Dubeyko
2025-04-11 13:48 ` David Howells
2025-03-13 23:32 ` [RFC PATCH 07/35] libceph: Change ceph_osdc_call()'s reply to a ceph_databuf David Howells
2025-03-17 19:41 ` Viacheslav Dubeyko
2025-03-17 22:12 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 08/35] libceph: Unexport osd_req_op_cls_request_data_pages() David Howells
2025-03-13 23:33 ` [RFC PATCH 09/35] libceph: Remove osd_req_op_cls_response_data_pages() David Howells
2025-03-13 23:33 ` [RFC PATCH 10/35] libceph: Convert notify_id_pages to a ceph_databuf David Howells
2025-03-13 23:33 ` [RFC PATCH 11/35] ceph: Use ceph_databuf in DIO David Howells
2025-03-17 20:03 ` Viacheslav Dubeyko
2025-03-17 22:26 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 12/35] libceph: Bypass the messenger-v1 Tx loop for databuf/iter data blobs David Howells
2025-03-13 23:33 ` [RFC PATCH 13/35] rbd: Switch from using bvec_iter to iov_iter David Howells
2025-03-18 19:38 ` Viacheslav Dubeyko
2025-03-18 22:13 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 14/35] libceph: Remove bvec and bio data container types David Howells
2025-03-13 23:33 ` [RFC PATCH 15/35] libceph: Make osd_req_op_cls_init() use a ceph_databuf and map it David Howells
2025-03-13 23:33 ` [RFC PATCH 16/35] libceph: Convert req_page of ceph_osdc_call() to ceph_databuf David Howells
2025-03-13 23:33 ` [RFC PATCH 17/35] libceph, rbd: Use ceph_databuf encoding start/stop David Howells
2025-03-18 19:59 ` Viacheslav Dubeyko
2025-03-18 22:19 ` David Howells
2025-03-20 21:45 ` Viacheslav Dubeyko
2025-03-13 23:33 ` [RFC PATCH 18/35] libceph, rbd: Convert some page arrays to ceph_databuf David Howells
2025-03-18 20:02 ` Viacheslav Dubeyko
2025-03-18 22:25 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 19/35] libceph, ceph: Convert users of ceph_pagelist " David Howells
2025-03-18 20:09 ` Viacheslav Dubeyko
2025-03-18 22:27 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 20/35] libceph: Remove ceph_pagelist David Howells
2025-03-13 23:33 ` [RFC PATCH 21/35] libceph: Make notify code use ceph_databuf_enc_start/stop David Howells
2025-03-18 20:12 ` Viacheslav Dubeyko
2025-03-18 22:36 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 22/35] libceph, rbd: Convert ceph_osdc_notify() reply to ceph_databuf David Howells
2025-03-19 0:08 ` Viacheslav Dubeyko
2025-03-20 14:44 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 23/35] rbd: Use ceph_databuf_enc_start/stop() David Howells
2025-03-19 0:32 ` Viacheslav Dubeyko
2025-03-20 14:59 ` Why use plain numbers and totals rather than predef'd constants for RPC sizes? David Howells
2025-03-20 21:48 ` Viacheslav Dubeyko
2025-03-13 23:33 ` [RFC PATCH 24/35] ceph: Make ceph_calc_file_object_mapping() return size as size_t David Howells
2025-03-13 23:33 ` [RFC PATCH 25/35] ceph: Wrap POSIX_FADV_WILLNEED to get caps David Howells
2025-03-13 23:33 ` David Howells [this message]
2025-03-13 23:33 ` [RFC PATCH 27/35] netfs: Pass extra write context to write functions David Howells
2025-03-13 23:33 ` [RFC PATCH 28/35] netfs: Adjust group handling David Howells
2025-03-19 18:57 ` Viacheslav Dubeyko
2025-03-20 15:22 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 29/35] netfs: Allow fs-private data to be handed through to request alloc David Howells
2025-03-13 23:33 ` [RFC PATCH 30/35] netfs: Make netfs_page_mkwrite() use folio_mkwrite_check_truncate() David Howells
2025-03-13 23:33 ` [RFC PATCH 31/35] netfs: Fix netfs_unbuffered_read() to return ssize_t rather than int David Howells
2025-03-13 23:33 ` [RFC PATCH 32/35] netfs: Add some more RMW support for ceph David Howells
2025-03-19 19:14 ` Viacheslav Dubeyko
2025-03-20 15:25 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 33/35] ceph: Use netfslib [INCOMPLETE] David Howells
2025-03-19 19:54 ` Viacheslav Dubeyko
2025-03-20 15:38 ` David Howells
2025-03-13 23:33 ` [RFC PATCH 34/35] ceph: Enable multipage folios for ceph files David Howells
2025-03-13 23:33 ` [RFC PATCH 35/35] ceph: Remove old I/O API bits 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=20250313233341.1675324-27-dhowells@redhat.com \
--to=dhowells@redhat.com \
--cc=amarkuze@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dongsheng.yang@easystack.cn \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.