@@ -728,7 +728,6 @@ static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data_cursor *cursor,
728728 it -> iter .bi_size = cursor -> resid ;
729729
730730 BUG_ON (cursor -> resid < bio_iter_len (it -> bio , it -> iter ));
731- cursor -> last_piece = cursor -> resid == bio_iter_len (it -> bio , it -> iter );
732731}
733732
734733static struct page * ceph_msg_data_bio_next (struct ceph_msg_data_cursor * cursor ,
@@ -754,10 +753,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
754753 cursor -> resid -= bytes ;
755754 bio_advance_iter (it -> bio , & it -> iter , bytes );
756755
757- if (!cursor -> resid ) {
758- BUG_ON (!cursor -> last_piece );
756+ if (!cursor -> resid )
759757 return false; /* no more data */
760- }
761758
762759 if (!bytes || (it -> iter .bi_size && it -> iter .bi_bvec_done &&
763760 page == bio_iter_page (it -> bio , it -> iter )))
@@ -770,9 +767,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
770767 it -> iter .bi_size = cursor -> resid ;
771768 }
772769
773- BUG_ON (cursor -> last_piece );
774770 BUG_ON (cursor -> resid < bio_iter_len (it -> bio , it -> iter ));
775- cursor -> last_piece = cursor -> resid == bio_iter_len (it -> bio , it -> iter );
776771 return true;
777772}
778773#endif /* CONFIG_BLOCK */
@@ -788,8 +783,6 @@ static void ceph_msg_data_bvecs_cursor_init(struct ceph_msg_data_cursor *cursor,
788783 cursor -> bvec_iter .bi_size = cursor -> resid ;
789784
790785 BUG_ON (cursor -> resid < bvec_iter_len (bvecs , cursor -> bvec_iter ));
791- cursor -> last_piece =
792- cursor -> resid == bvec_iter_len (bvecs , cursor -> bvec_iter );
793786}
794787
795788static struct page * ceph_msg_data_bvecs_next (struct ceph_msg_data_cursor * cursor ,
@@ -815,19 +808,14 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
815808 cursor -> resid -= bytes ;
816809 bvec_iter_advance (bvecs , & cursor -> bvec_iter , bytes );
817810
818- if (!cursor -> resid ) {
819- BUG_ON (!cursor -> last_piece );
811+ if (!cursor -> resid )
820812 return false; /* no more data */
821- }
822813
823814 if (!bytes || (cursor -> bvec_iter .bi_bvec_done &&
824815 page == bvec_iter_page (bvecs , cursor -> bvec_iter )))
825816 return false; /* more bytes to process in this segment */
826817
827- BUG_ON (cursor -> last_piece );
828818 BUG_ON (cursor -> resid < bvec_iter_len (bvecs , cursor -> bvec_iter ));
829- cursor -> last_piece =
830- cursor -> resid == bvec_iter_len (bvecs , cursor -> bvec_iter );
831819 return true;
832820}
833821
@@ -853,7 +841,6 @@ static void ceph_msg_data_pages_cursor_init(struct ceph_msg_data_cursor *cursor,
853841 BUG_ON (page_count > (int )USHRT_MAX );
854842 cursor -> page_count = (unsigned short )page_count ;
855843 BUG_ON (length > SIZE_MAX - cursor -> page_offset );
856- cursor -> last_piece = cursor -> page_offset + cursor -> resid <= PAGE_SIZE ;
857844}
858845
859846static struct page *
@@ -868,11 +855,7 @@ ceph_msg_data_pages_next(struct ceph_msg_data_cursor *cursor,
868855 BUG_ON (cursor -> page_offset >= PAGE_SIZE );
869856
870857 * page_offset = cursor -> page_offset ;
871- if (cursor -> last_piece )
872- * length = cursor -> resid ;
873- else
874- * length = PAGE_SIZE - * page_offset ;
875-
858+ * length = min_t (size_t , cursor -> resid , PAGE_SIZE - * page_offset );
876859 return data -> pages [cursor -> page_index ];
877860}
878861
@@ -897,8 +880,6 @@ static bool ceph_msg_data_pages_advance(struct ceph_msg_data_cursor *cursor,
897880
898881 BUG_ON (cursor -> page_index >= cursor -> page_count );
899882 cursor -> page_index ++ ;
900- cursor -> last_piece = cursor -> resid <= PAGE_SIZE ;
901-
902883 return true;
903884}
904885
@@ -928,7 +909,6 @@ ceph_msg_data_pagelist_cursor_init(struct ceph_msg_data_cursor *cursor,
928909 cursor -> resid = min (length , pagelist -> length );
929910 cursor -> page = page ;
930911 cursor -> offset = 0 ;
931- cursor -> last_piece = cursor -> resid <= PAGE_SIZE ;
932912}
933913
934914static struct page *
@@ -948,11 +928,7 @@ ceph_msg_data_pagelist_next(struct ceph_msg_data_cursor *cursor,
948928
949929 /* offset of first page in pagelist is always 0 */
950930 * page_offset = cursor -> offset & ~PAGE_MASK ;
951- if (cursor -> last_piece )
952- * length = cursor -> resid ;
953- else
954- * length = PAGE_SIZE - * page_offset ;
955-
931+ * length = min_t (size_t , cursor -> resid , PAGE_SIZE - * page_offset );
956932 return cursor -> page ;
957933}
958934
@@ -985,8 +961,6 @@ static bool ceph_msg_data_pagelist_advance(struct ceph_msg_data_cursor *cursor,
985961
986962 BUG_ON (list_is_last (& cursor -> page -> lru , & pagelist -> head ));
987963 cursor -> page = list_next_entry (cursor -> page , lru );
988- cursor -> last_piece = cursor -> resid <= PAGE_SIZE ;
989-
990964 return true;
991965}
992966
@@ -1044,8 +1018,7 @@ void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor,
10441018 * Indicate whether this is the last piece in this data item.
10451019 */
10461020struct page * ceph_msg_data_next (struct ceph_msg_data_cursor * cursor ,
1047- size_t * page_offset , size_t * length ,
1048- bool * last_piece )
1021+ size_t * page_offset , size_t * length )
10491022{
10501023 struct page * page ;
10511024
@@ -1074,8 +1047,6 @@ struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor,
10741047 BUG_ON (* page_offset + * length > PAGE_SIZE );
10751048 BUG_ON (!* length );
10761049 BUG_ON (* length > cursor -> resid );
1077- if (last_piece )
1078- * last_piece = cursor -> last_piece ;
10791050
10801051 return page ;
10811052}
@@ -1112,7 +1083,6 @@ void ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor, size_t bytes)
11121083 cursor -> total_resid -= bytes ;
11131084
11141085 if (!cursor -> resid && cursor -> total_resid ) {
1115- WARN_ON (!cursor -> last_piece );
11161086 cursor -> data ++ ;
11171087 __ceph_msg_data_cursor_init (cursor );
11181088 new_piece = true;
0 commit comments