Skip to contentSkip to conversation

libceph: remove the max extents check for sparse read

PATCH Superseded [email protected] 2 participants 3 messages Nov 7, 2023 Ceph common code (libceph)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 libceph: remove the max extents check for sparse read

From: Xiubo Li <[email protected]>

There is no any limit for the extent array size and it's possible that when reading with a large size contents the total number of extents will exceed 4096. Then the messager will fail by reseting the connection and keeps resending the inflight IOs infinitely.

URL: https://tracker.ceph.com/issues/62081

---

V3:
- Remove the max extents check and add one debug log.

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

 net/ceph/osd_client.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
net/ceph/osd_client.c +4 -13
index c03d48bd3aff..5f10ab76d0f3 100644
@@ -5850,8 +5850,6 @@ static inline void convert_extent_map(struct ceph_sparse_read *sr)
 }
 #endif
 
-#define MAX_EXTENTS 4096
-
 static int osd_sparse_read(struct ceph_connection *con,
 			   struct ceph_msg_data_cursor *cursor,
 			   char **pbuf)
@@ -5882,23 +5880,16 @@ 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.
-				 */
-				if (count > MAX_EXTENTS) {
-					dout("%s: OSD returned 0x%x extents in a single reply!\n",
-					     __func__, count);
-					return -EREMOTEIO;
-				}
-
 				/* no extent array provided, or too short */
 				kfree(sr->sr_extent);
 				sr->sr_extent = kmalloc_array(count,
 							      sizeof(*sr->sr_extent),
 							      GFP_NOIO);
-				if (!sr->sr_extent)
+				if (!sr->sr_extent) {
+					pr_err("%s: failed to allocate %u sparse read extents\n",
+					       __func__, count);
 					return -ENOMEM;
+				}
 				sr->sr_ext_len = count;
 			}
 			ret = count * sizeof(*sr->sr_extent);
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 51 lines · On Tue, Nov 7, 2023 at 2:47 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

There is no any limit for the extent array size and it's possible that when reading with a large size contents the total number of extents will exceed 4096. Then the messager will fail by reseting the connection and keeps resending the inflight IOs infinitely.

URL: https://tracker.ceph.com/issues/62081

---

V3:
- Remove the max extents check and add one debug log.

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

 net/ceph/osd_client.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
net/ceph/osd_client.c +0 -11
index c03d48bd3aff..5f10ab76d0f3 100644
@@ -5850,8 +5850,6 @@ static inline void convert_extent_map(struct ceph_sparse_read *sr)
 }
 #endif
 
-#define MAX_EXTENTS 4096
-
 static int osd_sparse_read(struct ceph_connection *con,
                           struct ceph_msg_data_cursor *cursor,
                           char **pbuf)
@@ -5882,23 +5880,16 @@ 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.
-                                */
-                               if (count > MAX_EXTENTS) {
-                                       dout("%s: OSD returned 0x%x extents in a single reply!\n",
-                                            __func__, count);
-                                       return -EREMOTEIO;
-                               }

net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5890

Quoted 10 lines
net/ceph/osd_client.c +3 -2
-
                                /* no extent array provided, or too short */
                                kfree(sr->sr_extent);
                                sr->sr_extent = kmalloc_array(count,
                                                              sizeof(*sr->sr_extent),
                                                              GFP_NOIO);
-                               if (!sr->sr_extent)
+                               if (!sr->sr_extent) {
+                                       pr_err("%s: failed to allocate %u sparse read extents\n",
+                                              __func__, count);

Hi Xiubo,

No need to include the function name: a) this is an error message as opposed to a debug message and b) such allocation is done only in one place anyway.

Otherwise LGTM!

Thanks,

Ilya

author
#2 lore raw
Quoted 63 lines · Ilya Dryomov
Quoted 50 lines · On Tue, Nov 7, 2023 at 2:47 AM <[email protected]> wrote:

From: Xiubo Li <[email protected]>

There is no any limit for the extent array size and it's possible that when reading with a large size contents the total number of extents will exceed 4096. Then the messager will fail by reseting the connection and keeps resending the inflight IOs infinitely.

URL: https://tracker.ceph.com/issues/62081

---

V3:
- Remove the max extents check and add one debug log.

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

  net/ceph/osd_client.c | 17 ++++-------------
  1 file changed, 4 insertions(+), 13 deletions(-)
net/ceph/osd_client.c +0 -11
index c03d48bd3aff..5f10ab76d0f3 100644
@@ -5850,8 +5850,6 @@ static inline void convert_extent_map(struct ceph_sparse_read *sr)
  }
  #endif
 
-#define MAX_EXTENTS 4096
-
  static int osd_sparse_read(struct ceph_connection *con,
                            struct ceph_msg_data_cursor *cursor,
                            char **pbuf)
@@ -5882,23 +5880,16 @@ 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.
-                                */
-                               if (count > MAX_EXTENTS) {
-                                       dout("%s: OSD returned 0x%x extents in a single reply!\n",
-                                            __func__, count);
-                                       return -EREMOTEIO;
-                               }

net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5890

Quoted 10 lines
net/ceph/osd_client.c +3 -2
-
                                 /* no extent array provided, or too short */
                                 kfree(sr->sr_extent);
                                 sr->sr_extent = kmalloc_array(count,
                                                               sizeof(*sr->sr_extent),
                                                               GFP_NOIO);
-                               if (!sr->sr_extent)
+                               if (!sr->sr_extent) {
+                                       pr_err("%s: failed to allocate %u sparse read extents\n",
+                                              __func__, count);

Hi Xiubo,

Quoted 3 lines

No need to include the function name: a) this is an error message as opposed to a debug message and b) such allocation is done only in one place anyway.

Okay, will remove it.

Thanks

- Xiubo

Quoted 6 lines

Otherwise LGTM!

Thanks,

Ilya