CEPH-Devel archive mirror
 help / color / mirror / Atom feed
From: xiubli@redhat.com
To: ceph-devel@vger.kernel.org
Cc: idryomov@gmail.com, jlayton@kernel.org, vshankar@redhat.com,
	mchangir@redhat.com, Xiubo Li <xiubli@redhat.com>
Subject: [PATCH v2] libceph: increase the max extents check for sparse read
Date: Mon,  6 Nov 2023 09:03:00 +0800	[thread overview]
Message-ID: <20231106010300.247597-1-xiubli@redhat.com> (raw)

From: Xiubo Li <xiubli@redhat.com>

There is no any limit for the extent array size and it's possible
that we will hit 4096 limit just after a lot of random writes to
a file and then read with a large size. In this case the messager
will fail by reseting the connection and keeps resending the inflight
IOs infinitely.

Just increase the limit to a larger number and then warn it to
let user know that allocating memory could fail with this.

URL: https://tracker.ceph.com/issues/62081
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---

V2:
- Increase the MAX_EXTENTS instead of removing it.
- Do not return an errno when hit the limit.


 net/ceph/osd_client.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index c03d48bd3aff..050dc39065fb 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -5850,7 +5850,7 @@ static inline void convert_extent_map(struct ceph_sparse_read *sr)
 }
 #endif
 
-#define MAX_EXTENTS 4096
+#define MAX_EXTENTS (16*1024*1024)
 
 static int osd_sparse_read(struct ceph_connection *con,
 			   struct ceph_msg_data_cursor *cursor,
@@ -5883,14 +5883,13 @@ static int osd_sparse_read(struct ceph_connection *con,
 		if (count > 0) {
 			if (!sr->sr_extent || count > sr->sr_ext_len) {
 				/*
-				 * Apply a hard cap to the number of extents.
-				 * If we have more, assume something is wrong.
+				 * Warn if hits a hard cap to the number of extents.
+				 * Too many extents could make the following
+				 * kmalloc_array() fail.
 				 */
-				if (count > MAX_EXTENTS) {
-					dout("%s: OSD returned 0x%x extents in a single reply!\n",
-					     __func__, count);
-					return -EREMOTEIO;
-				}
+				if (count > MAX_EXTENTS)
+					pr_warn_ratelimited("%s: OSD returned 0x%x extents in a single reply!\n",
+							    __func__, count);
 
 				/* no extent array provided, or too short */
 				kfree(sr->sr_extent);
-- 
2.39.1


             reply	other threads:[~2023-11-06  1:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06  1:03 xiubli [this message]
2023-11-06 11:17 ` [PATCH v2] libceph: increase the max extents check for sparse read Jeff Layton
2023-11-06 11:46 ` Ilya Dryomov
2023-11-06 12:20   ` Xiubo Li
2023-11-06 12:35     ` Ilya Dryomov

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=20231106010300.247597-1-xiubli@redhat.com \
    --to=xiubli@redhat.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=mchangir@redhat.com \
    --cc=vshankar@redhat.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).