All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ceph: clamp length of an OSD read to rsize mount option
@ 2021-04-23 19:43 Jeff Layton
  0 siblings, 0 replies; only message in thread
From: Jeff Layton @ 2021-04-23 19:43 UTC (permalink / raw)
  To: ceph-devel
  Cc: idryomov, xiublu, dhowells, linux-cachefs, linux-fsdevel, willy,
	lhenriques

There's a hard limit on how large a read we can do from the OSD, defined
as CEPH_MSG_MAX_DATA_LEN (currently, 64M). It's possible to create a
file that is backed by larger objects than that (and indeed, xfstest
ceph/001 does just that).

Ensure we clamp the final length of a read to the rsize, which defaults
to CEPH_MSG_MAX_DATA_LEN, but can be set lower.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/addr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

I think this version is more correct. Again, I'll plan to roll this into
the earlier patch that adds the clamp_length op.

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 9939100f9f9d..c1570fada3d8 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -205,6 +205,7 @@ static void ceph_netfs_expand_readahead(struct netfs_read_request *rreq)
 static bool ceph_netfs_clamp_length(struct netfs_read_subrequest *subreq)
 {
 	struct inode *inode = subreq->rreq->mapping->host;
+	struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
 	struct ceph_inode_info *ci = ceph_inode(inode);
 	u64 objno, objoff;
 	u32 xlen;
@@ -212,7 +213,7 @@ static bool ceph_netfs_clamp_length(struct netfs_read_subrequest *subreq)
 	/* Truncate the extent at the end of the current block */
 	ceph_calc_file_object_mapping(&ci->i_layout, subreq->start, subreq->len,
 				      &objno, &objoff, &xlen);
-	subreq->len = xlen;
+	subreq->len = min(xlen, fsc->mount_options->rsize);
 	return true;
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-23 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 19:43 [PATCH v2] ceph: clamp length of an OSD read to rsize mount option Jeff Layton

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.