aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/xen-blkback/common.h')
-rw-r--r--drivers/block/xen-blkback/common.h98
1 files changed, 81 insertions, 17 deletions
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index c4bd34063ecc..de09f525d6c1 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -62,13 +62,26 @@ struct blkif_common_response {
62 62
63/* i386 protocol version */ 63/* i386 protocol version */
64#pragma pack(push, 4) 64#pragma pack(push, 4)
65
66struct blkif_x86_32_request_rw {
67 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
68 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
69};
70
71struct blkif_x86_32_request_discard {
72 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
73 uint64_t nr_sectors;
74};
75
65struct blkif_x86_32_request { 76struct blkif_x86_32_request {
66 uint8_t operation; /* BLKIF_OP_??? */ 77 uint8_t operation; /* BLKIF_OP_??? */
67 uint8_t nr_segments; /* number of segments */ 78 uint8_t nr_segments; /* number of segments */
68 blkif_vdev_t handle; /* only for read/write requests */ 79 blkif_vdev_t handle; /* only for read/write requests */
69 uint64_t id; /* private guest value, echoed in resp */ 80 uint64_t id; /* private guest value, echoed in resp */
70 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 81 union {
71 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 82 struct blkif_x86_32_request_rw rw;
83 struct blkif_x86_32_request_discard discard;
84 } u;
72}; 85};
73struct blkif_x86_32_response { 86struct blkif_x86_32_response {
74 uint64_t id; /* copied from request */ 87 uint64_t id; /* copied from request */
@@ -78,13 +91,26 @@ struct blkif_x86_32_response {
78#pragma pack(pop) 91#pragma pack(pop)
79 92
80/* x86_64 protocol version */ 93/* x86_64 protocol version */
94
95struct blkif_x86_64_request_rw {
96 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
97 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
98};
99
100struct blkif_x86_64_request_discard {
101 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
102 uint64_t nr_sectors;
103};
104
81struct blkif_x86_64_request { 105struct blkif_x86_64_request {
82 uint8_t operation; /* BLKIF_OP_??? */ 106 uint8_t operation; /* BLKIF_OP_??? */
83 uint8_t nr_segments; /* number of segments */ 107 uint8_t nr_segments; /* number of segments */
84 blkif_vdev_t handle; /* only for read/write requests */ 108 blkif_vdev_t handle; /* only for read/write requests */
85 uint64_t __attribute__((__aligned__(8))) id; 109 uint64_t __attribute__((__aligned__(8))) id;
86 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ 110 union {
87 struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 111 struct blkif_x86_64_request_rw rw;
112 struct blkif_x86_64_request_discard discard;
113 } u;
88}; 114};
89struct blkif_x86_64_response { 115struct blkif_x86_64_response {
90 uint64_t __attribute__((__aligned__(8))) id; 116 uint64_t __attribute__((__aligned__(8))) id;
@@ -112,6 +138,11 @@ enum blkif_protocol {
112 BLKIF_PROTOCOL_X86_64 = 3, 138 BLKIF_PROTOCOL_X86_64 = 3,
113}; 139};
114 140
141enum blkif_backend_type {
142 BLKIF_BACKEND_PHY = 1,
143 BLKIF_BACKEND_FILE = 2,
144};
145
115struct xen_vbd { 146struct xen_vbd {
116 /* What the domain refers to this vbd as. */ 147 /* What the domain refers to this vbd as. */
117 blkif_vdev_t handle; 148 blkif_vdev_t handle;
@@ -137,6 +168,7 @@ struct xen_blkif {
137 unsigned int irq; 168 unsigned int irq;
138 /* Comms information. */ 169 /* Comms information. */
139 enum blkif_protocol blk_protocol; 170 enum blkif_protocol blk_protocol;
171 enum blkif_backend_type blk_backend_type;
140 union blkif_back_rings blk_rings; 172 union blkif_back_rings blk_rings;
141 struct vm_struct *blk_ring_area; 173 struct vm_struct *blk_ring_area;
142 /* The VBD attached to this interface. */ 174 /* The VBD attached to this interface. */
@@ -148,6 +180,9 @@ struct xen_blkif {
148 atomic_t refcnt; 180 atomic_t refcnt;
149 181
150 wait_queue_head_t wq; 182 wait_queue_head_t wq;
183 /* for barrier (drain) requests */
184 struct completion drain_complete;
185 atomic_t drain;
151 /* One thread per one blkif. */ 186 /* One thread per one blkif. */
152 struct task_struct *xenblkd; 187 struct task_struct *xenblkd;
153 unsigned int waiting_reqs; 188 unsigned int waiting_reqs;
@@ -158,6 +193,7 @@ struct xen_blkif {
158 int st_wr_req; 193 int st_wr_req;
159 int st_oo_req; 194 int st_oo_req;
160 int st_f_req; 195 int st_f_req;
196 int st_ds_req;
161 int st_rd_sect; 197 int st_rd_sect;
162 int st_wr_sect; 198 int st_wr_sect;
163 199
@@ -181,7 +217,7 @@ struct xen_blkif {
181 217
182struct phys_req { 218struct phys_req {
183 unsigned short dev; 219 unsigned short dev;
184 unsigned short nr_sects; 220 blkif_sector_t nr_sects;
185 struct block_device *bdev; 221 struct block_device *bdev;
186 blkif_sector_t sector_number; 222 blkif_sector_t sector_number;
187}; 223};
@@ -195,6 +231,8 @@ int xen_blkif_schedule(void *arg);
195int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt, 231int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
196 struct backend_info *be, int state); 232 struct backend_info *be, int state);
197 233
234int xen_blkbk_barrier(struct xenbus_transaction xbt,
235 struct backend_info *be, int state);
198struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be); 236struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be);
199 237
200static inline void blkif_get_x86_32_req(struct blkif_request *dst, 238static inline void blkif_get_x86_32_req(struct blkif_request *dst,
@@ -205,12 +243,25 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
205 dst->nr_segments = src->nr_segments; 243 dst->nr_segments = src->nr_segments;
206 dst->handle = src->handle; 244 dst->handle = src->handle;
207 dst->id = src->id; 245 dst->id = src->id;
208 dst->u.rw.sector_number = src->sector_number; 246 switch (src->operation) {
209 barrier(); 247 case BLKIF_OP_READ:
210 if (n > dst->nr_segments) 248 case BLKIF_OP_WRITE:
211 n = dst->nr_segments; 249 case BLKIF_OP_WRITE_BARRIER:
212 for (i = 0; i < n; i++) 250 case BLKIF_OP_FLUSH_DISKCACHE:
213 dst->u.rw.seg[i] = src->seg[i]; 251 dst->u.rw.sector_number = src->u.rw.sector_number;
252 barrier();
253 if (n > dst->nr_segments)
254 n = dst->nr_segments;
255 for (i = 0; i < n; i++)
256 dst->u.rw.seg[i] = src->u.rw.seg[i];
257 break;
258 case BLKIF_OP_DISCARD:
259 dst->u.discard.sector_number = src->u.discard.sector_number;
260 dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
261 break;
262 default:
263 break;
264 }
214} 265}
215 266
216static inline void blkif_get_x86_64_req(struct blkif_request *dst, 267static inline void blkif_get_x86_64_req(struct blkif_request *dst,
@@ -221,12 +272,25 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst,
221 dst->nr_segments = src->nr_segments; 272 dst->nr_segments = src->nr_segments;
222 dst->handle = src->handle; 273 dst->handle = src->handle;
223 dst->id = src->id; 274 dst->id = src->id;
224 dst->u.rw.sector_number = src->sector_number; 275 switch (src->operation) {
225 barrier(); 276 case BLKIF_OP_READ:
226 if (n > dst->nr_segments) 277 case BLKIF_OP_WRITE:
227 n = dst->nr_segments; 278 case BLKIF_OP_WRITE_BARRIER:
228 for (i = 0; i < n; i++) 279 case BLKIF_OP_FLUSH_DISKCACHE:
229 dst->u.rw.seg[i] = src->seg[i]; 280 dst->u.rw.sector_number = src->u.rw.sector_number;
281 barrier();
282 if (n > dst->nr_segments)
283 n = dst->nr_segments;
284 for (i = 0; i < n; i++)
285 dst->u.rw.seg[i] = src->u.rw.seg[i];
286 break;
287 case BLKIF_OP_DISCARD:
288 dst->u.discard.sector_number = src->u.discard.sector_number;
289 dst->u.discard.nr_sectors = src->u.discard.nr_sectors;
290 break;
291 default:
292 break;
293 }
230} 294}
231 295
232#endif /* __XEN_BLKIF__BACKEND__COMMON_H__ */ 296#endif /* __XEN_BLKIF__BACKEND__COMMON_H__ */