Lines Matching refs:cursor
807 static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bio_cursor_init() argument
810 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_bio_cursor_init()
811 struct ceph_bio_iter *it = &cursor->bio_iter; in ceph_msg_data_bio_cursor_init()
813 cursor->resid = min_t(size_t, length, data->bio_length); in ceph_msg_data_bio_cursor_init()
815 if (cursor->resid < it->iter.bi_size) in ceph_msg_data_bio_cursor_init()
816 it->iter.bi_size = cursor->resid; in ceph_msg_data_bio_cursor_init()
818 BUG_ON(cursor->resid < bio_iter_len(it->bio, it->iter)); in ceph_msg_data_bio_cursor_init()
819 cursor->last_piece = cursor->resid == bio_iter_len(it->bio, it->iter); in ceph_msg_data_bio_cursor_init()
822 static struct page *ceph_msg_data_bio_next(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bio_next() argument
826 struct bio_vec bv = bio_iter_iovec(cursor->bio_iter.bio, in ceph_msg_data_bio_next()
827 cursor->bio_iter.iter); in ceph_msg_data_bio_next()
834 static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bio_advance() argument
837 struct ceph_bio_iter *it = &cursor->bio_iter; in ceph_msg_data_bio_advance()
840 BUG_ON(bytes > cursor->resid); in ceph_msg_data_bio_advance()
842 cursor->resid -= bytes; in ceph_msg_data_bio_advance()
845 if (!cursor->resid) { in ceph_msg_data_bio_advance()
846 BUG_ON(!cursor->last_piece); in ceph_msg_data_bio_advance()
857 if (cursor->resid < it->iter.bi_size) in ceph_msg_data_bio_advance()
858 it->iter.bi_size = cursor->resid; in ceph_msg_data_bio_advance()
861 BUG_ON(cursor->last_piece); in ceph_msg_data_bio_advance()
862 BUG_ON(cursor->resid < bio_iter_len(it->bio, it->iter)); in ceph_msg_data_bio_advance()
863 cursor->last_piece = cursor->resid == bio_iter_len(it->bio, it->iter); in ceph_msg_data_bio_advance()
868 static void ceph_msg_data_bvecs_cursor_init(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bvecs_cursor_init() argument
871 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_bvecs_cursor_init()
874 cursor->resid = min_t(size_t, length, data->bvec_pos.iter.bi_size); in ceph_msg_data_bvecs_cursor_init()
875 cursor->bvec_iter = data->bvec_pos.iter; in ceph_msg_data_bvecs_cursor_init()
876 cursor->bvec_iter.bi_size = cursor->resid; in ceph_msg_data_bvecs_cursor_init()
878 BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter)); in ceph_msg_data_bvecs_cursor_init()
879 cursor->last_piece = in ceph_msg_data_bvecs_cursor_init()
880 cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter); in ceph_msg_data_bvecs_cursor_init()
883 static struct page *ceph_msg_data_bvecs_next(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bvecs_next() argument
887 struct bio_vec bv = bvec_iter_bvec(cursor->data->bvec_pos.bvecs, in ceph_msg_data_bvecs_next()
888 cursor->bvec_iter); in ceph_msg_data_bvecs_next()
895 static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_bvecs_advance() argument
898 struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs; in ceph_msg_data_bvecs_advance()
899 struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter); in ceph_msg_data_bvecs_advance()
901 BUG_ON(bytes > cursor->resid); in ceph_msg_data_bvecs_advance()
902 BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter)); in ceph_msg_data_bvecs_advance()
903 cursor->resid -= bytes; in ceph_msg_data_bvecs_advance()
904 bvec_iter_advance(bvecs, &cursor->bvec_iter, bytes); in ceph_msg_data_bvecs_advance()
906 if (!cursor->resid) { in ceph_msg_data_bvecs_advance()
907 BUG_ON(!cursor->last_piece); in ceph_msg_data_bvecs_advance()
911 if (!bytes || (cursor->bvec_iter.bi_bvec_done && in ceph_msg_data_bvecs_advance()
912 page == bvec_iter_page(bvecs, cursor->bvec_iter))) in ceph_msg_data_bvecs_advance()
915 BUG_ON(cursor->last_piece); in ceph_msg_data_bvecs_advance()
916 BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter)); in ceph_msg_data_bvecs_advance()
917 cursor->last_piece = in ceph_msg_data_bvecs_advance()
918 cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter); in ceph_msg_data_bvecs_advance()
926 static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pages_cursor_init() argument
929 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_pages_cursor_init()
937 cursor->resid = min(length, data->length); in ceph_msg_data_pages_cursor_init()
939 cursor->page_offset = data->alignment & ~PAGE_MASK; in ceph_msg_data_pages_cursor_init()
940 cursor->page_index = 0; in ceph_msg_data_pages_cursor_init()
942 cursor->page_count = (unsigned short)page_count; in ceph_msg_data_pages_cursor_init()
943 BUG_ON(length > SIZE_MAX - cursor->page_offset); in ceph_msg_data_pages_cursor_init()
944 cursor->last_piece = cursor->page_offset + cursor->resid <= PAGE_SIZE; in ceph_msg_data_pages_cursor_init()
948 ceph_msg_data_pages_next(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pages_next() argument
951 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_pages_next()
955 BUG_ON(cursor->page_index >= cursor->page_count); in ceph_msg_data_pages_next()
956 BUG_ON(cursor->page_offset >= PAGE_SIZE); in ceph_msg_data_pages_next()
958 *page_offset = cursor->page_offset; in ceph_msg_data_pages_next()
959 if (cursor->last_piece) in ceph_msg_data_pages_next()
960 *length = cursor->resid; in ceph_msg_data_pages_next()
964 return data->pages[cursor->page_index]; in ceph_msg_data_pages_next()
967 static bool ceph_msg_data_pages_advance(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pages_advance() argument
970 BUG_ON(cursor->data->type != CEPH_MSG_DATA_PAGES); in ceph_msg_data_pages_advance()
972 BUG_ON(cursor->page_offset + bytes > PAGE_SIZE); in ceph_msg_data_pages_advance()
976 cursor->resid -= bytes; in ceph_msg_data_pages_advance()
977 cursor->page_offset = (cursor->page_offset + bytes) & ~PAGE_MASK; in ceph_msg_data_pages_advance()
978 if (!bytes || cursor->page_offset) in ceph_msg_data_pages_advance()
981 if (!cursor->resid) in ceph_msg_data_pages_advance()
986 BUG_ON(cursor->page_index >= cursor->page_count); in ceph_msg_data_pages_advance()
987 cursor->page_index++; in ceph_msg_data_pages_advance()
988 cursor->last_piece = cursor->resid <= PAGE_SIZE; in ceph_msg_data_pages_advance()
998 ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pagelist_cursor_init() argument
1001 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_pagelist_cursor_init()
1016 cursor->resid = min(length, pagelist->length); in ceph_msg_data_pagelist_cursor_init()
1017 cursor->page = page; in ceph_msg_data_pagelist_cursor_init()
1018 cursor->offset = 0; in ceph_msg_data_pagelist_cursor_init()
1019 cursor->last_piece = cursor->resid <= PAGE_SIZE; in ceph_msg_data_pagelist_cursor_init()
1023 ceph_msg_data_pagelist_next(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pagelist_next() argument
1026 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_pagelist_next()
1034 BUG_ON(!cursor->page); in ceph_msg_data_pagelist_next()
1035 BUG_ON(cursor->offset + cursor->resid != pagelist->length); in ceph_msg_data_pagelist_next()
1038 *page_offset = cursor->offset & ~PAGE_MASK; in ceph_msg_data_pagelist_next()
1039 if (cursor->last_piece) in ceph_msg_data_pagelist_next()
1040 *length = cursor->resid; in ceph_msg_data_pagelist_next()
1044 return cursor->page; in ceph_msg_data_pagelist_next()
1047 static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_pagelist_advance() argument
1050 struct ceph_msg_data *data = cursor->data; in ceph_msg_data_pagelist_advance()
1058 BUG_ON(cursor->offset + cursor->resid != pagelist->length); in ceph_msg_data_pagelist_advance()
1059 BUG_ON((cursor->offset & ~PAGE_MASK) + bytes > PAGE_SIZE); in ceph_msg_data_pagelist_advance()
1063 cursor->resid -= bytes; in ceph_msg_data_pagelist_advance()
1064 cursor->offset += bytes; in ceph_msg_data_pagelist_advance()
1066 if (!bytes || cursor->offset & ~PAGE_MASK) in ceph_msg_data_pagelist_advance()
1069 if (!cursor->resid) in ceph_msg_data_pagelist_advance()
1074 BUG_ON(list_is_last(&cursor->page->lru, &pagelist->head)); in ceph_msg_data_pagelist_advance()
1075 cursor->page = list_next_entry(cursor->page, lru); in ceph_msg_data_pagelist_advance()
1076 cursor->last_piece = cursor->resid <= PAGE_SIZE; in ceph_msg_data_pagelist_advance()
1089 static void __ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor) in __ceph_msg_data_cursor_init() argument
1091 size_t length = cursor->total_resid; in __ceph_msg_data_cursor_init()
1093 switch (cursor->data->type) { in __ceph_msg_data_cursor_init()
1095 ceph_msg_data_pagelist_cursor_init(cursor, length); in __ceph_msg_data_cursor_init()
1098 ceph_msg_data_pages_cursor_init(cursor, length); in __ceph_msg_data_cursor_init()
1102 ceph_msg_data_bio_cursor_init(cursor, length); in __ceph_msg_data_cursor_init()
1106 ceph_msg_data_bvecs_cursor_init(cursor, length); in __ceph_msg_data_cursor_init()
1113 cursor->need_crc = true; in __ceph_msg_data_cursor_init()
1118 struct ceph_msg_data_cursor *cursor = &msg->cursor; in ceph_msg_data_cursor_init() local
1124 cursor->total_resid = length; in ceph_msg_data_cursor_init()
1125 cursor->data = msg->data; in ceph_msg_data_cursor_init()
1127 __ceph_msg_data_cursor_init(cursor); in ceph_msg_data_cursor_init()
1135 static struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_next() argument
1141 switch (cursor->data->type) { in ceph_msg_data_next()
1143 page = ceph_msg_data_pagelist_next(cursor, page_offset, length); in ceph_msg_data_next()
1146 page = ceph_msg_data_pages_next(cursor, page_offset, length); in ceph_msg_data_next()
1150 page = ceph_msg_data_bio_next(cursor, page_offset, length); in ceph_msg_data_next()
1154 page = ceph_msg_data_bvecs_next(cursor, page_offset, length); in ceph_msg_data_next()
1165 BUG_ON(*length > cursor->resid); in ceph_msg_data_next()
1167 *last_piece = cursor->last_piece; in ceph_msg_data_next()
1176 static void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, in ceph_msg_data_advance() argument
1181 BUG_ON(bytes > cursor->resid); in ceph_msg_data_advance()
1182 switch (cursor->data->type) { in ceph_msg_data_advance()
1184 new_piece = ceph_msg_data_pagelist_advance(cursor, bytes); in ceph_msg_data_advance()
1187 new_piece = ceph_msg_data_pages_advance(cursor, bytes); in ceph_msg_data_advance()
1191 new_piece = ceph_msg_data_bio_advance(cursor, bytes); in ceph_msg_data_advance()
1195 new_piece = ceph_msg_data_bvecs_advance(cursor, bytes); in ceph_msg_data_advance()
1202 cursor->total_resid -= bytes; in ceph_msg_data_advance()
1204 if (!cursor->resid && cursor->total_resid) { in ceph_msg_data_advance()
1205 WARN_ON(!cursor->last_piece); in ceph_msg_data_advance()
1206 cursor->data++; in ceph_msg_data_advance()
1207 __ceph_msg_data_cursor_init(cursor); in ceph_msg_data_advance()
1210 cursor->need_crc = new_piece; in ceph_msg_data_advance()
1555 struct ceph_msg_data_cursor *cursor = &msg->cursor; in write_partial_message_data() local
1574 while (cursor->total_resid) { in write_partial_message_data()
1580 if (!cursor->resid) { in write_partial_message_data()
1581 ceph_msg_data_advance(cursor, 0); in write_partial_message_data()
1585 page = ceph_msg_data_next(cursor, &page_offset, &length, NULL); in write_partial_message_data()
1586 if (length == cursor->total_resid) in write_partial_message_data()
1596 if (do_datacrc && cursor->need_crc) in write_partial_message_data()
1598 ceph_msg_data_advance(cursor, (size_t)ret); in write_partial_message_data()
2313 struct ceph_msg_data_cursor *cursor = &msg->cursor; in read_partial_msg_data() local
2326 while (cursor->total_resid) { in read_partial_msg_data()
2327 if (!cursor->resid) { in read_partial_msg_data()
2328 ceph_msg_data_advance(cursor, 0); in read_partial_msg_data()
2332 page = ceph_msg_data_next(cursor, &page_offset, &length, NULL); in read_partial_msg_data()
2343 ceph_msg_data_advance(cursor, (size_t)ret); in read_partial_msg_data()
3158 con->out_skip += msg->cursor.total_resid; in ceph_msg_revoke()