diff mbox series

[RFC,1/5] libceph: allow ceph_msg_data_advance to advance more than a page

Message ID 20220215145041.26065-2-jlayton@kernel.org
State New
Headers show
Series libceph: add support for sparse reads to msgr2/crc | expand

Commit Message

Jeff Layton Feb. 15, 2022, 2:50 p.m. UTC
In later patches, we're going to need to advance deeper into the data
buffer in order to set up for a sparse read. Rename the existing
routine, and add a wrapper around it that successively calls it until it
has advanced far enougb.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 net/ceph/messenger.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d3bb656308b4..005dd1a5aced 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -1084,7 +1084,7 @@  struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor,
  * Returns true if the result moves the cursor on to the next piece
  * of the data item.
  */
-void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes)
+static void __ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes)
 {
 	bool new_piece;
 
@@ -1120,6 +1120,16 @@  void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes)
 	cursor->need_crc = new_piece;
 }
 
+void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes)
+{
+	while (bytes) {
+		size_t cur = min(bytes, PAGE_SIZE);
+
+		__ceph_msg_data_advance(cursor, cur);
+		bytes -= cur;
+	}
+}
+
 u32 ceph_crc32c_page(u32 crc, struct page *page, unsigned int page_offset,
 		     unsigned int length)
 {