Skip to content

Commit

Permalink
libceph: remove MAX_EXTENTS check for sparse reads
Browse files Browse the repository at this point in the history
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.

[ idryomov: adjust error message ]

Link: https://tracker.ceph.com/issues/62081
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
lxbsz authored and idryomov committed Jan 15, 2024
1 parent f48e034 commit b79e4a0
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions net/ceph/osd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 extents\n",
__func__, count);
return -ENOMEM;
}
sr->sr_ext_len = count;
}
ret = count * sizeof(*sr->sr_extent);
Expand Down

0 comments on commit b79e4a0

Please sign in to comment.