@@ -533,19 +533,20 @@ static unsigned long blkif_ring_get_request(struct blkfront_ring_info *rinfo,
533533 rinfo -> shadow [id ].status = REQ_WAITING ;
534534 rinfo -> shadow [id ].associated_id = NO_ASSOCIATED_ID ;
535535
536- ( * ring_req ) -> u .rw .id = id ;
536+ rinfo -> shadow [ id ]. req . u .rw .id = id ;
537537
538538 return id ;
539539}
540540
541541static int blkif_queue_discard_req (struct request * req , struct blkfront_ring_info * rinfo )
542542{
543543 struct blkfront_info * info = rinfo -> dev_info ;
544- struct blkif_request * ring_req ;
544+ struct blkif_request * ring_req , * final_ring_req ;
545545 unsigned long id ;
546546
547547 /* Fill out a communications ring structure. */
548- id = blkif_ring_get_request (rinfo , req , & ring_req );
548+ id = blkif_ring_get_request (rinfo , req , & final_ring_req );
549+ ring_req = & rinfo -> shadow [id ].req ;
549550
550551 ring_req -> operation = BLKIF_OP_DISCARD ;
551552 ring_req -> u .discard .nr_sectors = blk_rq_sectors (req );
@@ -556,8 +557,8 @@ static int blkif_queue_discard_req(struct request *req, struct blkfront_ring_inf
556557 else
557558 ring_req -> u .discard .flag = 0 ;
558559
559- /* Keep a private copy so we can reissue requests when recovering . */
560- rinfo -> shadow [ id ]. req = * ring_req ;
560+ /* Copy the request to the ring page . */
561+ * final_ring_req = * ring_req ;
561562
562563 return 0 ;
563564}
@@ -690,6 +691,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
690691{
691692 struct blkfront_info * info = rinfo -> dev_info ;
692693 struct blkif_request * ring_req , * extra_ring_req = NULL ;
694+ struct blkif_request * final_ring_req , * final_extra_ring_req = NULL ;
693695 unsigned long id , extra_id = NO_ASSOCIATED_ID ;
694696 bool require_extra_req = false;
695697 int i ;
@@ -734,7 +736,8 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
734736 }
735737
736738 /* Fill out a communications ring structure. */
737- id = blkif_ring_get_request (rinfo , req , & ring_req );
739+ id = blkif_ring_get_request (rinfo , req , & final_ring_req );
740+ ring_req = & rinfo -> shadow [id ].req ;
738741
739742 num_sg = blk_rq_map_sg (req -> q , req , rinfo -> shadow [id ].sg );
740743 num_grant = 0 ;
@@ -785,7 +788,9 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
785788 ring_req -> u .rw .nr_segments = num_grant ;
786789 if (unlikely (require_extra_req )) {
787790 extra_id = blkif_ring_get_request (rinfo , req ,
788- & extra_ring_req );
791+ & final_extra_ring_req );
792+ extra_ring_req = & rinfo -> shadow [extra_id ].req ;
793+
789794 /*
790795 * Only the first request contains the scatter-gather
791796 * list.
@@ -827,10 +832,10 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
827832 if (setup .segments )
828833 kunmap_atomic (setup .segments );
829834
830- /* Keep a private copy so we can reissue requests when recovering . */
831- rinfo -> shadow [ id ]. req = * ring_req ;
835+ /* Copy request(s) to the ring page . */
836+ * final_ring_req = * ring_req ;
832837 if (unlikely (require_extra_req ))
833- rinfo -> shadow [ extra_id ]. req = * extra_ring_req ;
838+ * final_extra_ring_req = * extra_ring_req ;
834839
835840 if (new_persistent_gnts )
836841 gnttab_free_grant_references (setup .gref_head );
0 commit comments