@@ -154,10 +154,9 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
154154EXPORT_SYMBOL (bio_integrity_add_page );
155155
156156static int bio_integrity_copy_user (struct bio * bio , struct bio_vec * bvec ,
157- int nr_vecs , unsigned int len ,
158- unsigned int direction )
157+ int nr_vecs , unsigned int len )
159158{
160- bool write = direction == ITER_SOURCE ;
159+ bool write = op_is_write ( bio_op ( bio )) ;
161160 struct bio_integrity_payload * bip ;
162161 struct iov_iter iter ;
163162 void * buf ;
@@ -168,7 +167,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
168167 return - ENOMEM ;
169168
170169 if (write ) {
171- iov_iter_bvec (& iter , direction , bvec , nr_vecs , len );
170+ iov_iter_bvec (& iter , ITER_SOURCE , bvec , nr_vecs , len );
172171 if (!copy_from_iter_full (buf , len , & iter )) {
173172 ret = - EFAULT ;
174173 goto free_buf ;
@@ -264,7 +263,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
264263 struct page * stack_pages [UIO_FASTIOV ], * * pages = stack_pages ;
265264 struct bio_vec stack_vec [UIO_FASTIOV ], * bvec = stack_vec ;
266265 size_t offset , bytes = iter -> count ;
267- unsigned int direction , nr_bvecs ;
266+ unsigned int nr_bvecs ;
268267 int ret , nr_vecs ;
269268 bool copy ;
270269
@@ -273,11 +272,6 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
273272 if (bytes >> SECTOR_SHIFT > queue_max_hw_sectors (q ))
274273 return - E2BIG ;
275274
276- if (bio_data_dir (bio ) == READ )
277- direction = ITER_DEST ;
278- else
279- direction = ITER_SOURCE ;
280-
281275 nr_vecs = iov_iter_npages (iter , BIO_MAX_VECS + 1 );
282276 if (nr_vecs > BIO_MAX_VECS )
283277 return - E2BIG ;
@@ -300,8 +294,7 @@ int bio_integrity_map_user(struct bio *bio, struct iov_iter *iter)
300294 copy = true;
301295
302296 if (copy )
303- ret = bio_integrity_copy_user (bio , bvec , nr_bvecs , bytes ,
304- direction );
297+ ret = bio_integrity_copy_user (bio , bvec , nr_bvecs , bytes );
305298 else
306299 ret = bio_integrity_init_user (bio , bvec , nr_bvecs , bytes );
307300 if (ret )
0 commit comments