Skip to content

Commit 187df76

Browse files
committed
libceph: fix breakage caused by multipage bvecs
A bvec can now consist of multiple physically contiguous pages. This means that bvec_iter_advance() can move to a different page while staying in the same bvec (i.e. ->bi_bvec_done != 0). The messenger works in terms of segments which can now be defined as the smaller of a bvec and a page. The "more bytes to process in this segment" condition holds only if bvec_iter_advance() leaves us in the same bvec _and_ in the same page. On next bvec (possibly in the same page) and on next page (possibly in the same bvec) we may need to set ->last_piece. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent 8c2ffd9 commit 187df76

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/ceph/messenger.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
840840
size_t bytes)
841841
{
842842
struct ceph_bio_iter *it = &cursor->bio_iter;
843+
struct page *page = bio_iter_page(it->bio, it->iter);
843844

844845
BUG_ON(bytes > cursor->resid);
845846
BUG_ON(bytes > bio_iter_len(it->bio, it->iter));
@@ -851,7 +852,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
851852
return false; /* no more data */
852853
}
853854

854-
if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done))
855+
if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done &&
856+
page == bio_iter_page(it->bio, it->iter)))
855857
return false; /* more bytes to process in this segment */
856858

857859
if (!it->iter.bi_size) {
@@ -899,6 +901,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
899901
size_t bytes)
900902
{
901903
struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs;
904+
struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter);
902905

903906
BUG_ON(bytes > cursor->resid);
904907
BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter));
@@ -910,7 +913,8 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
910913
return false; /* no more data */
911914
}
912915

913-
if (!bytes || cursor->bvec_iter.bi_bvec_done)
916+
if (!bytes || (cursor->bvec_iter.bi_bvec_done &&
917+
page == bvec_iter_page(bvecs, cursor->bvec_iter)))
914918
return false; /* more bytes to process in this segment */
915919

916920
BUG_ON(cursor->last_piece);

0 commit comments

Comments
 (0)