All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libceph: fix last_piece calculation in ceph_msg_data_pages_advance
@ 2022-03-02 15:37 Jeff Layton
  2022-03-02 15:41 ` Alex Elder
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Layton @ 2022-03-02 15:37 UTC (permalink / raw)
  To: ceph-devel; +Cc: idryomov, xiubli

It's possible we'll have less than a page's worth of residual data, that
is stradding the last two pages in the array. That will make it
incorrectly set the last_piece boolean when it shouldn't.

Account for a non-zero cursor->page_offset when advancing.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 net/ceph/messenger.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d3bb656308b4..3f8453773cc8 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -894,10 +894,9 @@ static bool ceph_msg_data_pages_advance(struct ceph_msg_data_cursor *cursor,
 		return false;   /* no more data */
 
 	/* Move on to the next page; offset is already at 0 */
-
 	BUG_ON(cursor->page_index >= cursor->page_count);
 	cursor->page_index++;
-	cursor->last_piece = cursor->resid <= PAGE_SIZE;
+	cursor->last_piece = cursor->page_offset + cursor->resid <= PAGE_SIZE;
 
 	return true;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-02 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 15:37 [PATCH] libceph: fix last_piece calculation in ceph_msg_data_pages_advance Jeff Layton
2022-03-02 15:41 ` Alex Elder
2022-03-02 16:15   ` Jeff Layton
2022-03-02 17:03     ` Ilya Dryomov
2022-03-02 18:12       ` Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.