From patchwork Tue Oct 24 05:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 13433908 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8219A79C0 for ; Tue, 24 Oct 2023 05:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VTrJkZOk" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309F4B0 for ; Mon, 23 Oct 2023 22:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698123782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izi/oE5AQB0oUlSISfoJaQtMtXYXjE/JmvswKQsz1G0=; b=VTrJkZOklvBYXSZWnU2tLYGSTKoWkBHTkNykWLVp679X6oMvxikEewlPHZa1YKTP5pCbsz ED06f4etVk2UNqWRoZa7DJIDR8MvE1t3/8hSNt9lx0PnE0xiJGvnjRolsVAAN1mbk/fkjD qihDrkwCAa5/AFbnvfOIBwC5oM70IWI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-pw2uqqflMy-Q4zksMkaSvw-1; Tue, 24 Oct 2023 01:03:00 -0400 X-MC-Unique: pw2uqqflMy-Q4zksMkaSvw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1B4C628078CA; Tue, 24 Oct 2023 05:03:00 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A70425C0; Tue, 24 Oct 2023 05:02:57 +0000 (UTC) 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 Subject: [PATCH 1/3] libceph: do not decrease the data length more than once Date: Tue, 24 Oct 2023 13:00:37 +0800 Message-ID: <20231024050039.231143-2-xiubli@redhat.com> In-Reply-To: <20231024050039.231143-1-xiubli@redhat.com> References: <20231024050039.231143-1-xiubli@redhat.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 From: Xiubo Li No need to decrease the data length again if we need to read the left data. URL: https://tracker.ceph.com/issues/62081 Signed-off-by: Xiubo Li --- net/ceph/messenger_v2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c index d09a39ff2cf0..9e3f95d5e425 100644 --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -1966,7 +1966,6 @@ static int prepare_sparse_read_cont(struct ceph_connection *con) bv.bv_offset = 0; } set_in_bvec(con, &bv); - con->v2.data_len_remain -= bv.bv_len; return 0; } } else if (iov_iter_is_kvec(&con->v2.in_iter)) { From patchwork Tue Oct 24 05:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 13433909 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C58C79C6 for ; Tue, 24 Oct 2023 05:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZLNi/RP5" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22B9FD7B for ; Mon, 23 Oct 2023 22:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698123797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E0KQow/qMje6wifzRqHdFILoOHijhLL8PtlQwGXXptc=; b=ZLNi/RP5g0SRxu64B/Lwginbm9q54Kb44rtl61MlOKL/Eoy6COym+gW2qAdM8buLHKqSHZ ADu4M2hLXTjUxNpap5ctqfvYodCc9xi/gm3wDF/q5NxaqpWLrXSmUPhxKDrcVmp6658+zO j0ljEg4MW7ro3t6UsMzAzna9qu28Y7g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-nglan7v4PjKrW_r5dpUHag-1; Tue, 24 Oct 2023 01:03:03 -0400 X-MC-Unique: nglan7v4PjKrW_r5dpUHag-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65270802891; Tue, 24 Oct 2023 05:03:03 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB2D1143; Tue, 24 Oct 2023 05:03:00 +0000 (UTC) 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 Subject: [PATCH 2/3] libceph: save and covert sr_datalen to host-endian Date: Tue, 24 Oct 2023 13:00:38 +0800 Message-ID: <20231024050039.231143-3-xiubli@redhat.com> In-Reply-To: <20231024050039.231143-1-xiubli@redhat.com> References: <20231024050039.231143-1-xiubli@redhat.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 From: Xiubo Li 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 Signed-off-by: Xiubo Li Reviewed-by: Jeff Layton --- include/linux/ceph/osd_client.h | 3 ++- net/ceph/osd_client.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h index bf9823956758..f703fb8030de 100644 --- a/include/linux/ceph/osd_client.h +++ b/include/linux/ceph/osd_client.h @@ -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 */ diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index d3a759e052c8..800a2acec069 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -5912,8 +5912,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; From patchwork Tue Oct 24 05:00:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 13433910 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8119D5250 for ; Tue, 24 Oct 2023 05:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QzSLfhoE" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 547E21A4 for ; Mon, 23 Oct 2023 22:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698123807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y0jQsmxP+0JJXk1ftassBNI6/YPO3FyLbpWx9jswbms=; b=QzSLfhoELHYu9KWK8N8nFK/qOzpp6/rzIDEQl5qEloIJJg5dYc0YRmJhFvQY2gac+cBxFH YYTXI+IThlkLpm4JUhgVEJRZhWE2eE//6XuVwPnrEwvgwMyZhp4yYgwrC2+uvGVpTZtDl/ UjbL9Y9kwgl0hUvBeWBV9cQlW5vWvQY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-279-5RRrKIdWO0-HightyeaDWw-1; Tue, 24 Oct 2023 01:03:07 -0400 X-MC-Unique: 5RRrKIdWO0-HightyeaDWw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAA76185A78E; Tue, 24 Oct 2023 05:03:06 +0000 (UTC) Received: from li-a71a4dcc-35d1-11b2-a85c-951838863c8d.ibm.com.com (unknown [10.72.112.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12E4B25C0; Tue, 24 Oct 2023 05:03:03 +0000 (UTC) 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 Subject: [PATCH 3/3] libceph: check the data length when finishes Date: Tue, 24 Oct 2023 13:00:39 +0800 Message-ID: <20231024050039.231143-4-xiubli@redhat.com> In-Reply-To: <20231024050039.231143-1-xiubli@redhat.com> References: <20231024050039.231143-1-xiubli@redhat.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 From: Xiubo Li 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 Reviewed-by: Jeff Layton --- net/ceph/osd_client.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 800a2acec069..7af35106acaf 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -5921,6 +5921,13 @@ 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("sr_datalen %d sr_index %d count %d\n", + sr->sr_datalen, sr->sr_index, + count); + WARN_ON_ONCE(sr->sr_datalen); + } + sr->sr_state = CEPH_SPARSE_READ_HDR; goto next_op; } @@ -5928,6 +5935,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);