aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback/blkback.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-04-20 11:21:43 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-04-20 11:58:02 -0400
commit42c7841d171a2fe32005738dfebd724a90921496 (patch)
tree6cb19a9a61e98502eb7e3060f61781a6af016866 /drivers/block/xen-blkback/blkback.c
parent6cd0388cd600a51a8824dc5b34f1107b367b0cac (diff)
xen-blkback: Inline some of the functions that were moved from vbd/interface.c
Shuffling code around. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback/blkback.c')
-rw-r--r--drivers/block/xen-blkback/blkback.c78
1 files changed, 6 insertions, 72 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 63001fac9af2..806c2c947c63 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -170,75 +170,9 @@ static void free_req(struct pending_req *req)
170 * Routines for managing virtual block devices (vbds). 170 * Routines for managing virtual block devices (vbds).
171 */ 171 */
172 172
173#define vbd_sz(_v) ((_v)->bdev->bd_part ? \
174 (_v)->bdev->bd_part->nr_sects : \
175 get_capacity((_v)->bdev->bd_disk))
176 173
177unsigned long long vbd_size(struct vbd *vbd) 174static int vbd_translate(struct phys_req *req, struct blkif_st *blkif,
178{ 175 int operation)
179 return vbd_sz(vbd);
180}
181
182unsigned int vbd_info(struct vbd *vbd)
183{
184 return vbd->type | (vbd->readonly ? VDISK_READONLY : 0);
185}
186
187unsigned long vbd_secsize(struct vbd *vbd)
188{
189 return bdev_logical_block_size(vbd->bdev);
190}
191
192int vbd_create(struct blkif_st *blkif, blkif_vdev_t handle, unsigned major,
193 unsigned minor, int readonly, int cdrom)
194{
195 struct vbd *vbd;
196 struct block_device *bdev;
197
198 vbd = &blkif->vbd;
199 vbd->handle = handle;
200 vbd->readonly = readonly;
201 vbd->type = 0;
202
203 vbd->pdevice = MKDEV(major, minor);
204
205 bdev = blkdev_get_by_dev(vbd->pdevice, vbd->readonly ?
206 FMODE_READ : FMODE_WRITE, NULL);
207
208 if (IS_ERR(bdev)) {
209 DPRINTK("vbd_creat: device %08x could not be opened.\n",
210 vbd->pdevice);
211 return -ENOENT;
212 }
213
214 vbd->bdev = bdev;
215 vbd->size = vbd_size(vbd);
216
217 if (vbd->bdev->bd_disk == NULL) {
218 DPRINTK("vbd_creat: device %08x doesn't exist.\n",
219 vbd->pdevice);
220 vbd_free(vbd);
221 return -ENOENT;
222 }
223
224 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
225 vbd->type |= VDISK_CDROM;
226 if (vbd->bdev->bd_disk->flags & GENHD_FL_REMOVABLE)
227 vbd->type |= VDISK_REMOVABLE;
228
229 DPRINTK("Successful creation of handle=%04x (dom=%u)\n",
230 handle, blkif->domid);
231 return 0;
232}
233
234void vbd_free(struct vbd *vbd)
235{
236 if (vbd->bdev)
237 blkdev_put(vbd->bdev, vbd->readonly ? FMODE_READ : FMODE_WRITE);
238 vbd->bdev = NULL;
239}
240
241int vbd_translate(struct phys_req *req, struct blkif_st *blkif, int operation)
242{ 176{
243 struct vbd *vbd = &blkif->vbd; 177 struct vbd *vbd = &blkif->vbd;
244 int rc = -EACCES; 178 int rc = -EACCES;
@@ -257,13 +191,13 @@ int vbd_translate(struct phys_req *req, struct blkif_st *blkif, int operation)
257 return rc; 191 return rc;
258} 192}
259 193
260void vbd_resize(struct blkif_st *blkif) 194static void vbd_resize(struct blkif_st *blkif)
261{ 195{
262 struct vbd *vbd = &blkif->vbd; 196 struct vbd *vbd = &blkif->vbd;
263 struct xenbus_transaction xbt; 197 struct xenbus_transaction xbt;
264 int err; 198 int err;
265 struct xenbus_device *dev = blkback_xenbus(blkif->be); 199 struct xenbus_device *dev = blkback_xenbus(blkif->be);
266 unsigned long long new_size = vbd_size(vbd); 200 unsigned long long new_size = vbd_sz(vbd);
267 201
268 printk(KERN_INFO "VBD Resize: Domid: %d, Device: (%d, %d)\n", 202 printk(KERN_INFO "VBD Resize: Domid: %d, Device: (%d, %d)\n",
269 blkif->domid, MAJOR(vbd->pdevice), MINOR(vbd->pdevice)); 203 blkif->domid, MAJOR(vbd->pdevice), MINOR(vbd->pdevice));
@@ -276,7 +210,7 @@ again:
276 return; 210 return;
277 } 211 }
278 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu", 212 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
279 vbd_size(vbd)); 213 (unsigned long long)vbd_sz(vbd));
280 if (err) { 214 if (err) {
281 printk(KERN_WARNING "Error writing new size"); 215 printk(KERN_WARNING "Error writing new size");
282 goto abort; 216 goto abort;
@@ -344,7 +278,7 @@ int blkif_schedule(void *arg)
344 while (!kthread_should_stop()) { 278 while (!kthread_should_stop()) {
345 if (try_to_freeze()) 279 if (try_to_freeze())
346 continue; 280 continue;
347 if (unlikely(vbd->size != vbd_size(vbd))) 281 if (unlikely(vbd->size != vbd_sz(vbd)))
348 vbd_resize(blkif); 282 vbd_resize(blkif);
349 283
350 wait_event_interruptible( 284 wait_event_interruptible(