diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-08-07 17:30:24 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 01:33:52 -0500 |
commit | f38a5181d9f3e004b1f50f9d7e1f2a8492ce240a (patch) | |
tree | f9e4457ba8def6a8a066cd0b545bfa2b9fb60a47 /net | |
parent | feb261e2ee5d782c7e9c71fe1ef0828244a42cc1 (diff) |
ceph: Convert to immutable biovecs
Now that we've got a mechanism for immutable biovecs -
bi_iter.bi_bvec_done - we need to convert drivers to use primitives that
respect it instead of using the bvec array directly.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Sage Weil <sage@inktank.com>
Cc: ceph-devel@vger.kernel.org
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 4a5df7b1cc9f..18c039b95c22 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -777,13 +777,12 @@ static void ceph_msg_data_bio_cursor_init(struct ceph_msg_data_cursor *cursor, | |||
777 | 777 | ||
778 | bio = data->bio; | 778 | bio = data->bio; |
779 | BUG_ON(!bio); | 779 | BUG_ON(!bio); |
780 | BUG_ON(!bio->bi_vcnt); | ||
781 | 780 | ||
782 | cursor->resid = min(length, data->bio_length); | 781 | cursor->resid = min(length, data->bio_length); |
783 | cursor->bio = bio; | 782 | cursor->bio = bio; |
784 | cursor->vector_index = 0; | 783 | cursor->bvec_iter = bio->bi_iter; |
785 | cursor->vector_offset = 0; | 784 | cursor->last_piece = |
786 | cursor->last_piece = length <= bio->bi_io_vec[0].bv_len; | 785 | cursor->resid <= bio_iter_len(bio, cursor->bvec_iter); |
787 | } | 786 | } |
788 | 787 | ||
789 | static struct page *ceph_msg_data_bio_next(struct ceph_msg_data_cursor *cursor, | 788 | static struct page *ceph_msg_data_bio_next(struct ceph_msg_data_cursor *cursor, |
@@ -792,71 +791,63 @@ static struct page *ceph_msg_data_bio_next(struct ceph_msg_data_cursor *cursor, | |||
792 | { | 791 | { |
793 | struct ceph_msg_data *data = cursor->data; | 792 | struct ceph_msg_data *data = cursor->data; |
794 | struct bio *bio; | 793 | struct bio *bio; |
795 | struct bio_vec *bio_vec; | 794 | struct bio_vec bio_vec; |
796 | unsigned int index; | ||
797 | 795 | ||
798 | BUG_ON(data->type != CEPH_MSG_DATA_BIO); | 796 | BUG_ON(data->type != CEPH_MSG_DATA_BIO); |
799 | 797 | ||
800 | bio = cursor->bio; | 798 | bio = cursor->bio; |
801 | BUG_ON(!bio); | 799 | BUG_ON(!bio); |
802 | 800 | ||
803 | index = cursor->vector_index; | 801 | bio_vec = bio_iter_iovec(bio, cursor->bvec_iter); |
804 | BUG_ON(index >= (unsigned int) bio->bi_vcnt); | ||
805 | 802 | ||
806 | bio_vec = &bio->bi_io_vec[index]; | 803 | *page_offset = (size_t) bio_vec.bv_offset; |
807 | BUG_ON(cursor->vector_offset >= bio_vec->bv_len); | ||
808 | *page_offset = (size_t) (bio_vec->bv_offset + cursor->vector_offset); | ||
809 | BUG_ON(*page_offset >= PAGE_SIZE); | 804 | BUG_ON(*page_offset >= PAGE_SIZE); |
810 | if (cursor->last_piece) /* pagelist offset is always 0 */ | 805 | if (cursor->last_piece) /* pagelist offset is always 0 */ |
811 | *length = cursor->resid; | 806 | *length = cursor->resid; |
812 | else | 807 | else |
813 | *length = (size_t) (bio_vec->bv_len - cursor->vector_offset); | 808 | *length = (size_t) bio_vec.bv_len; |
814 | BUG_ON(*length > cursor->resid); | 809 | BUG_ON(*length > cursor->resid); |
815 | BUG_ON(*page_offset + *length > PAGE_SIZE); | 810 | BUG_ON(*page_offset + *length > PAGE_SIZE); |
816 | 811 | ||
817 | return bio_vec->bv_page; | 812 | return bio_vec.bv_page; |
818 | } | 813 | } |
819 | 814 | ||
820 | static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, | 815 | static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, |
821 | size_t bytes) | 816 | size_t bytes) |
822 | { | 817 | { |
823 | struct bio *bio; | 818 | struct bio *bio; |
824 | struct bio_vec *bio_vec; | 819 | struct bio_vec bio_vec; |
825 | unsigned int index; | ||
826 | 820 | ||
827 | BUG_ON(cursor->data->type != CEPH_MSG_DATA_BIO); | 821 | BUG_ON(cursor->data->type != CEPH_MSG_DATA_BIO); |
828 | 822 | ||
829 | bio = cursor->bio; | 823 | bio = cursor->bio; |
830 | BUG_ON(!bio); | 824 | BUG_ON(!bio); |
831 | 825 | ||
832 | index = cursor->vector_index; | 826 | bio_vec = bio_iter_iovec(bio, cursor->bvec_iter); |
833 | BUG_ON(index >= (unsigned int) bio->bi_vcnt); | ||
834 | bio_vec = &bio->bi_io_vec[index]; | ||
835 | 827 | ||
836 | /* Advance the cursor offset */ | 828 | /* Advance the cursor offset */ |
837 | 829 | ||
838 | BUG_ON(cursor->resid < bytes); | 830 | BUG_ON(cursor->resid < bytes); |
839 | cursor->resid -= bytes; | 831 | cursor->resid -= bytes; |
840 | cursor->vector_offset += bytes; | 832 | |
841 | if (cursor->vector_offset < bio_vec->bv_len) | 833 | bio_advance_iter(bio, &cursor->bvec_iter, bytes); |
834 | |||
835 | if (bytes < bio_vec.bv_len) | ||
842 | return false; /* more bytes to process in this segment */ | 836 | return false; /* more bytes to process in this segment */ |
843 | BUG_ON(cursor->vector_offset != bio_vec->bv_len); | ||
844 | 837 | ||
845 | /* Move on to the next segment, and possibly the next bio */ | 838 | /* Move on to the next segment, and possibly the next bio */ |
846 | 839 | ||
847 | if (++index == (unsigned int) bio->bi_vcnt) { | 840 | if (!cursor->bvec_iter.bi_size) { |
848 | bio = bio->bi_next; | 841 | bio = bio->bi_next; |
849 | index = 0; | 842 | cursor->bvec_iter = bio->bi_iter; |
850 | } | 843 | } |
851 | cursor->bio = bio; | 844 | cursor->bio = bio; |
852 | cursor->vector_index = index; | ||
853 | cursor->vector_offset = 0; | ||
854 | 845 | ||
855 | if (!cursor->last_piece) { | 846 | if (!cursor->last_piece) { |
856 | BUG_ON(!cursor->resid); | 847 | BUG_ON(!cursor->resid); |
857 | BUG_ON(!bio); | 848 | BUG_ON(!bio); |
858 | /* A short read is OK, so use <= rather than == */ | 849 | /* A short read is OK, so use <= rather than == */ |
859 | if (cursor->resid <= bio->bi_io_vec[index].bv_len) | 850 | if (cursor->resid <= bio_iter_len(bio, cursor->bvec_iter)) |
860 | cursor->last_piece = true; | 851 | cursor->last_piece = true; |
861 | } | 852 | } |
862 | 853 | ||