The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to stable@vger.kernel.org.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 23ee27dce30e7d3091d6c3143b79f48dab6f9a3e # <resolve conflicts, build, test, etc.> git commit -s git send-email --to 'stable@vger.kernel.org' --in-reply-to '2023072131-reflux-material-ce4e@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
23ee27dce30e ("ceph: add a dedicated private data for netfs rreq") 40a811012023 ("netfs: Rename the netfs_io_request cleanup op and give it an op pointer") bc899ee1c898 ("netfs: Add a netfs inode context") a5c9dc445139 ("ceph: Make ceph_init_request() check caps on readahead") 2de160417315 ("netfs: Change ->init_request() to return an error code") 663dfb65c3b3 ("netfs: Refactor arguments for netfs_alloc_read_request") de74023befa1 ("netfs: Trace refcounting on the netfs_io_request struct") 18b3ff9fe8b8 ("netfs: Adjust the netfs_rreq tracepoint slightly") 3a4a38e66d24 ("netfs: Split netfs_io_* object handling out") f18a378580a7 ("netfs: Finish off rename of netfs_read_request to netfs_io_request") 6a19114b8e7f ("netfs: Rename netfs_read_*request to netfs_io_*request") 5ac417d24c6c ("netfs: Generate enums from trace symbol mapping lists") 083db6fd3e73 ("ceph: uninline the data on a file opened for writing") 5b19f1eba459 ("ceph: make ceph_netfs_issue_op() handle inlined data") a25cedb4313d ("ceph: switch netfs read ops to use rreq->inode instead of rreq->mapping->host") 8205ae327e39 ("Merge tag '5.17-rc-part2-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 23ee27dce30e7d3091d6c3143b79f48dab6f9a3e Mon Sep 17 00:00:00 2001 From: Xiubo Li xiubli@redhat.com Date: Wed, 10 May 2023 19:55:46 +0800 Subject: [PATCH] ceph: add a dedicated private data for netfs rreq
We need to save the 'f_ra.ra_pages' to expand the readahead window later.
Cc: stable@vger.kernel.org Fixes: 49870056005c ("ceph: convert ceph_readpages to ceph_readahead") Link: https://lore.kernel.org/ceph-devel/20230504082510.247-1-sehuww@mail.scut.edu... Link: https://www.spinics.net/lists/ceph-users/msg76183.html Signed-off-by: Xiubo Li xiubli@redhat.com Reviewed-and-tested-by: Hu Weiwen sehuww@mail.scut.edu.cn Reviewed-by: Milind Changire mchangir@redhat.com Signed-off-by: Ilya Dryomov idryomov@gmail.com
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 6bb251a4d613..19c4f08454d2 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -362,18 +362,28 @@ 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; + struct ceph_netfs_request_data *priv; int ret = 0;
if (rreq->origin != NETFS_READAHEAD) return 0;
+ priv = kzalloc(sizeof(*priv), GFP_NOFS); + if (!priv) + return -ENOMEM; + 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) + if (rw_ctx) { + rreq->netfs_priv = priv; return 0; + } }
/* @@ -383,27 +393,40 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file) 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; + goto out; }
if (!(got & want)) { dout("start_read %p, no cache cap\n", inode); - return -EACCES; + ret = -EACCES; + goto out; + } + if (ret == 0) { + ret = -EACCES; + goto out; } - if (ret == 0) - return -EACCES;
- rreq->netfs_priv = (void *)(uintptr_t)got; - return 0; + priv->caps = got; + rreq->netfs_priv = priv; + +out: + if (ret < 0) + kfree(priv); + + return ret; }
static void ceph_netfs_free_request(struct netfs_io_request *rreq) { - struct ceph_inode_info *ci = ceph_inode(rreq->inode); - int got = (uintptr_t)rreq->netfs_priv; + struct ceph_netfs_request_data *priv = rreq->netfs_priv;
- if (got) - ceph_put_cap_refs(ci, got); + if (!priv) + return; + + if (priv->caps) + ceph_put_cap_refs(ceph_inode(rreq->inode), priv->caps); + kfree(priv); + rreq->netfs_priv = NULL; }
const struct netfs_request_ops ceph_netfs_ops = { diff --git a/fs/ceph/super.h b/fs/ceph/super.h index d24bf0db5234..3bfddf34d488 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -451,6 +451,19 @@ struct ceph_inode_info { unsigned long i_work_mask; };
+struct ceph_netfs_request_data { + int caps; + + /* + * Maximum size of a file readahead request. + * The fadvise could update the bdi's default ra_pages. + */ + unsigned int file_ra_pages; + + /* Set it if fadvise disables file readahead entirely */ + bool file_ra_disabled; +}; + static inline struct ceph_inode_info * ceph_inode(const struct inode *inode) {
linux-stable-mirror@lists.linaro.org