Skip to content

Commit 51de695

Browse files
OwenSmithkonradwilk
authored andcommitted
xen: Union the blkif_request request specific fields
Prepare for extending the block device ring to allow request specific fields, by moving the request specific fields for reads, writes and barrier requests to a union member. Acked-by: Jens Axboe <jaxboe@fusionio.com> Signed-off-by: Owen Smith <owen.smith@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent c56eb8f commit 51de695

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎drivers/block/xen-blkfront.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int blkif_queue_request(struct request *req)
281281
info->shadow[id].request = req;
282282

283283
ring_req->id = id;
284-
ring_req->sector_number = (blkif_sector_t)blk_rq_pos(req);
284+
ring_req->u.rw.sector_number = (blkif_sector_t)blk_rq_pos(req);
285285
ring_req->handle = info->handle;
286286

287287
ring_req->operation = rq_data_dir(req) ?
@@ -317,7 +317,7 @@ static int blkif_queue_request(struct request *req)
317317
rq_data_dir(req) );
318318

319319
info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
320-
ring_req->seg[i] =
320+
ring_req->u.rw.seg[i] =
321321
(struct blkif_request_segment) {
322322
.gref = ref,
323323
.first_sect = fsect,
@@ -615,7 +615,7 @@ static void blkif_completion(struct blk_shadow *s)
615615
{
616616
int i;
617617
for (i = 0; i < s->req.nr_segments; i++)
618-
gnttab_end_foreign_access(s->req.seg[i].gref, 0, 0UL);
618+
gnttab_end_foreign_access(s->req.u.rw.seg[i].gref, 0, 0UL);
619619
}
620620

621621
static irqreturn_t blkif_interrupt(int irq, void *dev_id)
@@ -932,7 +932,7 @@ static int blkif_recover(struct blkfront_info *info)
932932
/* Rewrite any grant references invalidated by susp/resume. */
933933
for (j = 0; j < req->nr_segments; j++)
934934
gnttab_grant_foreign_access_ref(
935-
req->seg[j].gref,
935+
req->u.rw.seg[j].gref,
936936
info->xbdev->otherend_id,
937937
pfn_to_mfn(info->shadow[req->id].frame[j]),
938938
rq_data_dir(info->shadow[req->id].request));

‎include/xen/interface/io/blkif.h‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ typedef uint64_t blkif_sector_t;
5151
*/
5252
#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
5353

54-
struct blkif_request {
55-
uint8_t operation; /* BLKIF_OP_??? */
56-
uint8_t nr_segments; /* number of segments */
57-
blkif_vdev_t handle; /* only for read/write requests */
58-
uint64_t id; /* private guest value, echoed in resp */
54+
struct blkif_request_rw {
5955
blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
6056
struct blkif_request_segment {
6157
grant_ref_t gref; /* reference to I/O buffer frame */
@@ -65,6 +61,16 @@ struct blkif_request {
6561
} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
6662
};
6763

64+
struct blkif_request {
65+
uint8_t operation; /* BLKIF_OP_??? */
66+
uint8_t nr_segments; /* number of segments */
67+
blkif_vdev_t handle; /* only for read/write requests */
68+
uint64_t id; /* private guest value, echoed in resp */
69+
union {
70+
struct blkif_request_rw rw;
71+
} u;
72+
};
73+
6874
struct blkif_response {
6975
uint64_t id; /* copied from request */
7076
uint8_t operation; /* copied from request */

0 commit comments

Comments
 (0)