Skip to content

Commit 80bfa2f

Browse files
roygerkonradwilk
authored andcommitted
xen-blkif: drop struct blkif_request_segment_aligned
This was wrongly introduced in commit 402b27f, the only difference between blkif_request_segment_aligned and blkif_request_segment is that the former has a named padding, while both share the same memory layout. Also correct a few minor glitches in the description, including for it to no longer assume PAGE_SIZE == 4096. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> [Description fix by Jan Beulich] Signed-off-by: Jan Beulich <jbeulich@suse.com> Reported-by: Jan Beulich <jbeulich@suse.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Tested-by: Matt Rushton <mrushton@amazon.com> Cc: Matt Wilson <msw@amazon.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent c05f3e3 commit 80bfa2f

4 files changed

Lines changed: 19 additions & 25 deletions

File tree

‎drivers/block/xen-blkback/blkback.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static int xen_blkbk_parse_indirect(struct blkif_request *req,
847847
struct grant_page **pages = pending_req->indirect_pages;
848848
struct xen_blkif *blkif = pending_req->blkif;
849849
int indirect_grefs, rc, n, nseg, i;
850-
struct blkif_request_segment_aligned *segments = NULL;
850+
struct blkif_request_segment *segments = NULL;
851851

852852
nseg = pending_req->nr_pages;
853853
indirect_grefs = INDIRECT_PAGES(nseg);

‎drivers/block/xen-blkback/common.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
#define MAX_INDIRECT_SEGMENTS 256
5858

5959
#define SEGS_PER_INDIRECT_FRAME \
60-
(PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
60+
(PAGE_SIZE/sizeof(struct blkif_request_segment))
6161
#define MAX_INDIRECT_PAGES \
6262
((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
6363
#define INDIRECT_PAGES(_segs) \

‎drivers/block/xen-blkfront.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static DEFINE_SPINLOCK(minor_lock);
162162
#define DEV_NAME "xvd" /* name in /dev */
163163

164164
#define SEGS_PER_INDIRECT_FRAME \
165-
(PAGE_SIZE/sizeof(struct blkif_request_segment_aligned))
165+
(PAGE_SIZE/sizeof(struct blkif_request_segment))
166166
#define INDIRECT_GREFS(_segs) \
167167
((_segs + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
168168

@@ -393,7 +393,7 @@ static int blkif_queue_request(struct request *req)
393393
unsigned long id;
394394
unsigned int fsect, lsect;
395395
int i, ref, n;
396-
struct blkif_request_segment_aligned *segments = NULL;
396+
struct blkif_request_segment *segments = NULL;
397397

398398
/*
399399
* Used to store if we are able to queue the request by just using
@@ -550,7 +550,7 @@ static int blkif_queue_request(struct request *req)
550550
} else {
551551
n = i % SEGS_PER_INDIRECT_FRAME;
552552
segments[n] =
553-
(struct blkif_request_segment_aligned) {
553+
(struct blkif_request_segment) {
554554
.gref = ref,
555555
.first_sect = fsect,
556556
.last_sect = lsect };

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

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ typedef uint64_t blkif_sector_t;
113113
* it's less than the number provided by the backend. The indirect_grefs field
114114
* in blkif_request_indirect should be filled by the frontend with the
115115
* grant references of the pages that are holding the indirect segments.
116-
* This pages are filled with an array of blkif_request_segment_aligned
117-
* that hold the information about the segments. The number of indirect
118-
* pages to use is determined by the maximum number of segments
119-
* a indirect request contains. Every indirect page can contain a maximum
120-
* of 512 segments (PAGE_SIZE/sizeof(blkif_request_segment_aligned)),
121-
* so to calculate the number of indirect pages to use we have to do
122-
* ceil(indirect_segments/512).
116+
* These pages are filled with an array of blkif_request_segment that hold the
117+
* information about the segments. The number of indirect pages to use is
118+
* determined by the number of segments an indirect request contains. Every
119+
* indirect page can contain a maximum of
120+
* (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to
121+
* calculate the number of indirect pages to use we have to do
122+
* ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))).
123123
*
124124
* If a backend does not recognize BLKIF_OP_INDIRECT, it should *not*
125125
* create the "feature-max-indirect-segments" node!
@@ -135,13 +135,12 @@ typedef uint64_t blkif_sector_t;
135135

136136
#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8
137137

138-
struct blkif_request_segment_aligned {
139-
grant_ref_t gref; /* reference to I/O buffer frame */
140-
/* @first_sect: first sector in frame to transfer (inclusive). */
141-
/* @last_sect: last sector in frame to transfer (inclusive). */
142-
uint8_t first_sect, last_sect;
143-
uint16_t _pad; /* padding to make it 8 bytes, so it's cache-aligned */
144-
} __attribute__((__packed__));
138+
struct blkif_request_segment {
139+
grant_ref_t gref; /* reference to I/O buffer frame */
140+
/* @first_sect: first sector in frame to transfer (inclusive). */
141+
/* @last_sect: last sector in frame to transfer (inclusive). */
142+
uint8_t first_sect, last_sect;
143+
};
145144

146145
struct blkif_request_rw {
147146
uint8_t nr_segments; /* number of segments */
@@ -151,12 +150,7 @@ struct blkif_request_rw {
151150
#endif
152151
uint64_t id; /* private guest value, echoed in resp */
153152
blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
154-
struct blkif_request_segment {
155-
grant_ref_t gref; /* reference to I/O buffer frame */
156-
/* @first_sect: first sector in frame to transfer (inclusive). */
157-
/* @last_sect: last sector in frame to transfer (inclusive). */
158-
uint8_t first_sect, last_sect;
159-
} seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
153+
struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
160154
} __attribute__((__packed__));
161155

162156
struct blkif_request_discard {

0 commit comments

Comments
 (0)