libceph: sparse-read misc fixes
v3 cover libceph: sparse-read misc fixes
From: Xiubo Li <[email protected]>
V3:
- Remove the WARN_ON_ONCE().
- Return -EREMOTEIO when the datalen and extents mismatch.
V2:
- Remove [1/3] patch from V1.
Xiubo Li (2):
libceph: save and covert sr_datalen to host-endian
libceph: check the data length when sparse-read finishes
include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.1
PATCH v3 1/2 libceph: save and covert sr_datalen to host-endian
From: Xiubo Li <[email protected]>
We need to save the real data length to determine exactly how many data we can parse later.
URL: https://tracker.ceph.com/issues/62081
--- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
include/linux/ceph/osd_client.h +2 -1
@@ -45,6 +45,7 @@ enum ceph_sparse_read_state {CEPH_SPARSE_READ_HDR =0 ,CEPH_SPARSE_READ_EXTENTS ,CEPH_SPARSE_READ_DATA_LEN , +CEPH_SPARSE_READ_DATA_PRE , CEPH_SPARSE_READ_DATA, };
@@ -64,7 +65,7 @@ struct ceph_sparse_read {u64 sr_req_len;/* orig request length */ u64 sr_pos;/* current pos in buffer */ int sr_index;/* current extent index */ -__le32 sr_datalen;/* length of actual data */ +u32 sr_datalen;/* length of actual data */ u32 sr_count;/* extent count in reply */ int sr_ext_len;/* length of extent array */ struct ceph_sparse_extent *sr_extent;/* extent array */
net/ceph/osd_client.c +6 -1
@@ -5911,8 +5911,13 @@ static int osd_sparse_read(struct ceph_connection *con,convert_extent_map (sr); ret =sizeof (sr->sr_datalen); *pbuf = (char *)&sr->sr_datalen; - sr->sr_state =CEPH_SPARSE_READ_DATA ; + sr->sr_state =CEPH_SPARSE_READ_DATA_PRE ;break ; +case CEPH_SPARSE_READ_DATA_PRE : +/* Convert sr_datalen to host-endian */ + sr->sr_datalen =le32_to_cpu ((__force __le32 )sr->sr_datalen); + sr->sr_state =CEPH_SPARSE_READ_DATA ; + fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { sr->sr_state =CEPH_SPARSE_READ_HDR ;
Signature · 1 line
2.39.1
PATCH v3 2/2 libceph: check the data length when sparse-read finishes
In reply to [email protected]From: Xiubo Li <[email protected]>
For sparse reading the real length of the data should equal to the total length from the extent array.
URL: https://tracker.ceph.com/issues/62081
--- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ceph/osd_client.c +8 -0
@@ -5920,6 +5920,12 @@ static int osd_sparse_read(struct ceph_connection *con, fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { +if (sr->sr_datalen && count) { +pr_warn_ratelimited ("%s: datalen and extents mismath, %d left\n" , + __func__, sr->sr_datalen); +return -EREMOTEIO ; + } + sr->sr_state =CEPH_SPARSE_READ_HDR ; goto next_op; }
@@ -5927,6 +5933,8 @@ static int osd_sparse_read(struct ceph_connection *con, eoff = sr->sr_extent[sr->sr_index].off; elen = sr->sr_extent[sr->sr_index].len; + sr->sr_datalen -= elen; +dout ("[%d] ext %d off 0x%llx len 0x%llx\n" , o->o_osd, sr->sr_index, eoff, elen);
Signature · 1 line
2.39.1
Ilya Dryomov
maintainerRe: [PATCH v3 2/2] libceph: check the data length when sparse-read finishes
Quoted 18 lines · On Mon, Nov 6, 2023 at 2:19 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
For sparse reading the real length of the data should equal to the total length from the extent array.
URL: https://tracker.ceph.com/issues/62081
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>--- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+)net/ceph/osd_client.c +0
-0
net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5926
Quoted 7 lines
net/ceph/osd_client.c +4
-0@@ -5920,6 +5920,12 @@ static int osd_sparse_read(struct ceph_connection *con, fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { +if (sr->sr_datalen && count) { +pr_warn_ratelimited ("%s: datalen and extents mismath, %d left\n" , + __func__, sr->sr_datalen); +return -EREMOTEIO ;
By returning EREMOTEIO here you have significantly changed the semantics (in v2 it was just a warning) but Jeff's Reviewed-by is retained. Has he acked the change?
Thanks,
Ilya
Re: [PATCH v3 2/2] libceph: check the data length when sparse-read finishes
Quoted 13 lines · Ilya Dryomov
Quoted 12 lines · On Mon, Nov 6, 2023 at 2:19 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
For sparse reading the real length of the data should equal to the total length from the extent array.
URL: https://tracker.ceph.com/issues/62081
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>--- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Quoted 15 lines
net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5926
Quoted 12 lines
net/ceph/osd_client.c +4
-0@@ -5920,6 +5920,12 @@ static int osd_sparse_read(struct ceph_connection *con, fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { +if (sr->sr_datalen && count) { +pr_warn_ratelimited ("%s: datalen and extents mismath, %d left\n" , + __func__, sr->sr_datalen); +return -EREMOTEIO ;By returning EREMOTEIO here you have significantly changed the semantics (in v2 it was just a warning) but Jeff's Reviewed-by is retained. Has he acked the change?
Oh, sorry I forgot to remove that.
Jeff, Please take a look here again.
Thanks
- Xiubo
Quoted 4 lines
Thanks,
Ilya
Re: [PATCH v3 2/2] libceph: check the data length when sparse-read finishes
Quoted 30 lines · Xiubo Li
Quoted 13 lines · Ilya Dryomov
Quoted 12 lines · On Mon, Nov 6, 2023 at 2:19 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
For sparse reading the real length of the data should equal to the total length from the extent array.
URL: https://tracker.ceph.com/issues/62081
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>--- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+)Quoted 15 lines
net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5926
Quoted 12 lines
net/ceph/osd_client.c +4
-0@@ -5920,6 +5920,12 @@ static int osd_sparse_read(struct ceph_connection *con, fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { +if (sr->sr_datalen && count) { +pr_warn_ratelimited ("%s: datalen and extents mismath, %d left\n" , + __func__, sr->sr_datalen); +return -EREMOTEIO ;By returning EREMOTEIO here you have significantly changed the semantics (in v2 it was just a warning) but Jeff's Reviewed-by is retained. Has he acked the change?
Quoted 9 lines
Oh, sorry I forgot to remove that.
Jeff, Please take a look here again.
Thanks
- Xiubo
Returning EREMOTEIO if the lengths don't match seems like a reasonable thing to do. You can retain the R-b.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH v3 2/2] libceph: check the data length when sparse-read finishes
Quoted 34 lines · Jeff Layton
Quoted 33 lines · Xiubo Li
Quoted 13 lines · Ilya Dryomov
Quoted 12 lines · On Mon, Nov 6, 2023 at 2:19 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
For sparse reading the real length of the data should equal to the total length from the extent array.
URL: https://tracker.ceph.com/issues/62081
Signed-off-by Xiubo Li <[email protected]>Reviewed-by Jeff Layton <[email protected]>--- net/ceph/osd_client.c | 8 ++++++++ 1 file changed, 8 insertions(+)Quoted 15 lines
net/ceph/osd_client.c static int osd_sparse_read(struct ceph_connection *con, · line 5926
Quoted 12 lines
net/ceph/osd_client.c +4
-0@@ -5920,6 +5920,12 @@ static int osd_sparse_read(struct ceph_connection *con, fallthrough;case CEPH_SPARSE_READ_DATA :if (sr->sr_index >= count) { +if (sr->sr_datalen && count) { +pr_warn_ratelimited ("%s: datalen and extents mismath, %d left\n" , + __func__, sr->sr_datalen); +return -EREMOTEIO ;By returning EREMOTEIO here you have significantly changed the semantics (in v2 it was just a warning) but Jeff's Reviewed-by is retained. Has he acked the change?
Oh, sorry I forgot to remove that.
Jeff, Please take a look here again.
Quoted 8 lines
Quoted 5 lines
Thanks
- Xiubo
Returning EREMOTEIO if the lengths don't match seems like a reasonable thing to do. You can retain the R-b.
Thanks Jeff.
- Xiubo