@@ -264,64 +264,46 @@ struct rds_message *rds_message_map_pages(unsigned long *page_addrs, unsigned in
264
264
return rm ;
265
265
}
266
266
267
- int rds_message_copy_from_user (struct rds_message * rm , struct iovec * first_iov ,
268
- size_t total_len )
267
+ int rds_message_copy_from_user (struct rds_message * rm , struct iov_iter * from )
269
268
{
270
269
unsigned long to_copy ;
271
- unsigned long iov_off ;
272
270
unsigned long sg_off ;
273
- struct iovec * iov ;
274
271
struct scatterlist * sg ;
275
272
int ret = 0 ;
276
273
277
- rm -> m_inc .i_hdr .h_len = cpu_to_be32 (total_len );
274
+ rm -> m_inc .i_hdr .h_len = cpu_to_be32 (iov_iter_count ( from ) );
278
275
279
276
/*
280
277
* now allocate and copy in the data payload.
281
278
*/
282
279
sg = rm -> data .op_sg ;
283
- iov = first_iov ;
284
- iov_off = 0 ;
285
280
sg_off = 0 ; /* Dear gcc, sg->page will be null from kzalloc. */
286
281
287
- while (total_len ) {
282
+ while (iov_iter_count ( from ) ) {
288
283
if (!sg_page (sg )) {
289
- ret = rds_page_remainder_alloc (sg , total_len ,
284
+ ret = rds_page_remainder_alloc (sg , iov_iter_count ( from ) ,
290
285
GFP_HIGHUSER );
291
286
if (ret )
292
- goto out ;
287
+ return ret ;
293
288
rm -> data .op_nents ++ ;
294
289
sg_off = 0 ;
295
290
}
296
291
297
- while (iov_off == iov -> iov_len ) {
298
- iov_off = 0 ;
299
- iov ++ ;
300
- }
301
-
302
- to_copy = min (iov -> iov_len - iov_off , sg -> length - sg_off );
303
- to_copy = min_t (size_t , to_copy , total_len );
304
-
305
- rdsdebug ("copying %lu bytes from user iov [%p, %zu] + %lu to "
306
- "sg [%p, %u, %u] + %lu\n" ,
307
- to_copy , iov -> iov_base , iov -> iov_len , iov_off ,
308
- (void * )sg_page (sg ), sg -> offset , sg -> length , sg_off );
292
+ to_copy = min_t (unsigned long , iov_iter_count (from ),
293
+ sg -> length - sg_off );
309
294
310
- ret = rds_page_copy_from_user ( sg_page ( sg ), sg -> offset + sg_off ,
311
- iov -> iov_base + iov_off ,
312
- to_copy );
313
- if (ret )
314
- goto out ;
295
+ rds_stats_add ( s_copy_from_user , to_copy );
296
+ ret = copy_page_from_iter ( sg_page ( sg ), sg -> offset + sg_off ,
297
+ to_copy , from );
298
+ if (ret != to_copy )
299
+ return - EFAULT ;
315
300
316
- iov_off += to_copy ;
317
- total_len -= to_copy ;
318
301
sg_off += to_copy ;
319
302
320
303
if (sg_off == sg -> length )
321
304
sg ++ ;
322
305
}
323
306
324
- out :
325
307
return ret ;
326
308
}
327
309
0 commit comments