Commit 88122933 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Konrad Rzeszutek Wilk

xen-blkback-porting

parent 4d05a28d
...@@ -39,8 +39,12 @@ ...@@ -39,8 +39,12 @@
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/freezer.h>
#include <xen/balloon.h> #include <xen/balloon.h>
#include <asm/hypervisor.h> #include <xen/events.h>
#include <xen/page.h>
#include <asm/xen/hypervisor.h>
#include <asm/xen/hypercall.h>
#include "common.h" #include "common.h"
/* /*
...@@ -106,7 +110,7 @@ static inline unsigned long vaddr(pending_req_t *req, int seg) ...@@ -106,7 +110,7 @@ static inline unsigned long vaddr(pending_req_t *req, int seg)
static int do_block_io_op(blkif_t *blkif); static int do_block_io_op(blkif_t *blkif);
static void dispatch_rw_block_io(blkif_t *blkif, static void dispatch_rw_block_io(blkif_t *blkif,
blkif_request_t *req, struct blkif_request *req,
pending_req_t *pending_req); pending_req_t *pending_req);
static void make_response(blkif_t *blkif, u64 id, static void make_response(blkif_t *blkif, u64 id,
unsigned short op, int st); unsigned short op, int st);
...@@ -153,7 +157,7 @@ static void unplug_queue(blkif_t *blkif) ...@@ -153,7 +157,7 @@ static void unplug_queue(blkif_t *blkif)
static void plug_queue(blkif_t *blkif, struct block_device *bdev) static void plug_queue(blkif_t *blkif, struct block_device *bdev)
{ {
request_queue_t *q = bdev_get_queue(bdev); struct request_queue *q = bdev_get_queue(bdev);
if (q == blkif->plug) if (q == blkif->plug)
return; return;
...@@ -268,13 +272,10 @@ static void __end_block_io_op(pending_req_t *pending_req, int error) ...@@ -268,13 +272,10 @@ static void __end_block_io_op(pending_req_t *pending_req, int error)
} }
} }
static int end_block_io_op(struct bio *bio, unsigned int done, int error) static void end_block_io_op(struct bio *bio, int error)
{ {
if (bio->bi_size != 0)
return 1;
__end_block_io_op(bio->bi_private, error); __end_block_io_op(bio->bi_private, error);
bio_put(bio); bio_put(bio);
return error;
} }
...@@ -288,7 +289,7 @@ static void blkif_notify_work(blkif_t *blkif) ...@@ -288,7 +289,7 @@ static void blkif_notify_work(blkif_t *blkif)
wake_up(&blkif->wq); wake_up(&blkif->wq);
} }
irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs) irqreturn_t blkif_be_int(int irq, void *dev_id)
{ {
blkif_notify_work(dev_id); blkif_notify_work(dev_id);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -302,8 +303,8 @@ irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs) ...@@ -302,8 +303,8 @@ irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs)
static int do_block_io_op(blkif_t *blkif) static int do_block_io_op(blkif_t *blkif)
{ {
blkif_back_rings_t *blk_rings = &blkif->blk_rings; union blkif_back_rings *blk_rings = &blkif->blk_rings;
blkif_request_t req; struct blkif_request req;
pending_req_t *pending_req; pending_req_t *pending_req;
RING_IDX rc, rp; RING_IDX rc, rp;
int more_to_do = 0; int more_to_do = 0;
...@@ -379,7 +380,7 @@ static int do_block_io_op(blkif_t *blkif) ...@@ -379,7 +380,7 @@ static int do_block_io_op(blkif_t *blkif)
} }
static void dispatch_rw_block_io(blkif_t *blkif, static void dispatch_rw_block_io(blkif_t *blkif,
blkif_request_t *req, struct blkif_request *req,
pending_req_t *pending_req) pending_req_t *pending_req)
{ {
extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]); extern void ll_rw_block(int rw, int nr, struct buffer_head * bhs[]);
...@@ -560,9 +561,9 @@ static void dispatch_rw_block_io(blkif_t *blkif, ...@@ -560,9 +561,9 @@ static void dispatch_rw_block_io(blkif_t *blkif,
static void make_response(blkif_t *blkif, u64 id, static void make_response(blkif_t *blkif, u64 id,
unsigned short op, int st) unsigned short op, int st)
{ {
blkif_response_t resp; struct blkif_response resp;
unsigned long flags; unsigned long flags;
blkif_back_rings_t *blk_rings = &blkif->blk_rings; union blkif_back_rings *blk_rings = &blkif->blk_rings;
int more_to_do = 0; int more_to_do = 0;
int notify; int notify;
...@@ -614,7 +615,8 @@ static int __init blkif_init(void) ...@@ -614,7 +615,8 @@ static int __init blkif_init(void)
{ {
int i, mmap_pages; int i, mmap_pages;
if (!is_running_on_xen()) printk(KERN_CRIT "***blkif_init\n");
if (!xen_pv_domain())
return -ENODEV; return -ENODEV;
mmap_pages = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST; mmap_pages = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
......
...@@ -40,8 +40,7 @@ ...@@ -40,8 +40,7 @@
#include <xen/evtchn.h> #include <xen/evtchn.h>
#include <asm/hypervisor.h> #include <asm/hypervisor.h>
#include <xen/blkif.h> #include <xen/blkif.h>
#include <xen/gnttab.h> #include <xen/grant_table.h>
#include <xen/driver_util.h>
#include <xen/xenbus.h> #include <xen/xenbus.h>
#define DPRINTK(_f, _a...) \ #define DPRINTK(_f, _a...) \
...@@ -66,7 +65,7 @@ typedef struct blkif_st { ...@@ -66,7 +65,7 @@ typedef struct blkif_st {
unsigned int irq; unsigned int irq;
/* Comms information. */ /* Comms information. */
enum blkif_protocol blk_protocol; enum blkif_protocol blk_protocol;
blkif_back_rings_t blk_rings; union blkif_back_rings blk_rings;
struct vm_struct *blk_ring_area; struct vm_struct *blk_ring_area;
/* The VBD attached to this interface. */ /* The VBD attached to this interface. */
struct vbd vbd; struct vbd vbd;
...@@ -79,7 +78,7 @@ typedef struct blkif_st { ...@@ -79,7 +78,7 @@ typedef struct blkif_st {
wait_queue_head_t wq; wait_queue_head_t wq;
struct task_struct *xenblkd; struct task_struct *xenblkd;
unsigned int waiting_reqs; unsigned int waiting_reqs;
request_queue_t *plug; struct request_queue *plug;
/* statistics */ /* statistics */
unsigned long st_print; unsigned long st_print;
...@@ -130,7 +129,7 @@ void blkif_interface_init(void); ...@@ -130,7 +129,7 @@ void blkif_interface_init(void);
void blkif_xenbus_init(void); void blkif_xenbus_init(void);
irqreturn_t blkif_be_int(int irq, void *dev_id, struct pt_regs *regs); irqreturn_t blkif_be_int(int irq, void *dev_id);
int blkif_schedule(void *arg); int blkif_schedule(void *arg);
int blkback_barrier(struct xenbus_transaction xbt, int blkback_barrier(struct xenbus_transaction xbt,
......
...@@ -31,10 +31,11 @@ ...@@ -31,10 +31,11 @@
*/ */
#include "common.h" #include "common.h"
#include <xen/evtchn.h> #include <xen/events.h>
#include <xen/grant_table.h>
#include <linux/kthread.h> #include <linux/kthread.h>
static kmem_cache_t *blkif_cachep; static struct kmem_cache *blkif_cachep;
blkif_t *blkif_alloc(domid_t domid) blkif_t *blkif_alloc(domid_t domid)
{ {
...@@ -107,22 +108,22 @@ int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn) ...@@ -107,22 +108,22 @@ int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
switch (blkif->blk_protocol) { switch (blkif->blk_protocol) {
case BLKIF_PROTOCOL_NATIVE: case BLKIF_PROTOCOL_NATIVE:
{ {
blkif_sring_t *sring; struct blkif_sring *sring;
sring = (blkif_sring_t *)blkif->blk_ring_area->addr; sring = (struct blkif_sring *)blkif->blk_ring_area->addr;
BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE); BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
break; break;
} }
case BLKIF_PROTOCOL_X86_32: case BLKIF_PROTOCOL_X86_32:
{ {
blkif_x86_32_sring_t *sring_x86_32; struct blkif_x86_32_sring *sring_x86_32;
sring_x86_32 = (blkif_x86_32_sring_t *)blkif->blk_ring_area->addr; sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring_area->addr;
BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE); BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
break; break;
} }
case BLKIF_PROTOCOL_X86_64: case BLKIF_PROTOCOL_X86_64:
{ {
blkif_x86_64_sring_t *sring_x86_64; struct blkif_x86_64_sring *sring_x86_64;
sring_x86_64 = (blkif_x86_64_sring_t *)blkif->blk_ring_area->addr; sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring_area->addr;
BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE); BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
break; break;
} }
...@@ -177,5 +178,5 @@ void blkif_free(blkif_t *blkif) ...@@ -177,5 +178,5 @@ void blkif_free(blkif_t *blkif)
void __init blkif_interface_init(void) void __init blkif_interface_init(void)
{ {
blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t), blkif_cachep = kmem_cache_create("blkif_cache", sizeof(blkif_t),
0, 0, NULL, NULL); 0, 0, NULL);
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "common.h" #include "common.h"
#define vbd_sz(_v) ((_v)->bdev->bd_part ? \ #define vbd_sz(_v) ((_v)->bdev->bd_part ? \
(_v)->bdev->bd_part->nr_sects : (_v)->bdev->bd_disk->capacity) (_v)->bdev->bd_part->nr_sects : get_capacity((_v)->bdev->bd_disk))
unsigned long long vbd_size(struct vbd *vbd) unsigned long long vbd_size(struct vbd *vbd)
{ {
...@@ -94,7 +94,7 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major, ...@@ -94,7 +94,7 @@ int vbd_create(blkif_t *blkif, blkif_vdev_t handle, unsigned major,
void vbd_free(struct vbd *vbd) void vbd_free(struct vbd *vbd)
{ {
if (vbd->bdev) if (vbd->bdev)
blkdev_put(vbd->bdev); blkdev_put(vbd->bdev, vbd->readonly ? FMODE_READ : FMODE_WRITE);
vbd->bdev = NULL; vbd->bdev = NULL;
} }
......
...@@ -238,8 +238,8 @@ static int blkback_probe(struct xenbus_device *dev, ...@@ -238,8 +238,8 @@ static int blkback_probe(struct xenbus_device *dev,
/* setup back pointer */ /* setup back pointer */
be->blkif->be = be; be->blkif->be = be;
err = xenbus_watch_path2(dev, dev->nodename, "physical-device", err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
&be->backend_watch, backend_changed); "%s/%s", dev->nodename, "physical-device");
if (err) if (err)
goto fail; goto fail;
...@@ -537,5 +537,6 @@ static struct xenbus_driver blkback = { ...@@ -537,5 +537,6 @@ static struct xenbus_driver blkback = {
void blkif_xenbus_init(void) void blkif_xenbus_init(void)
{ {
xenbus_register_backend(&blkback); /* XXX must_check */
(void)xenbus_register_backend(&blkback);
} }
...@@ -77,12 +77,11 @@ DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32 ...@@ -77,12 +77,11 @@ DEFINE_RING_TYPES(blkif_x86_32, struct blkif_x86_32_request, struct blkif_x86_32
DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response); DEFINE_RING_TYPES(blkif_x86_64, struct blkif_x86_64_request, struct blkif_x86_64_response);
union blkif_back_rings { union blkif_back_rings {
blkif_back_ring_t native; struct blkif_back_ring native;
blkif_common_back_ring_t common; struct blkif_common_back_ring common;
blkif_x86_32_back_ring_t x86_32; struct blkif_x86_32_back_ring x86_32;
blkif_x86_64_back_ring_t x86_64; struct blkif_x86_64_back_ring x86_64;
}; };
typedef union blkif_back_rings blkif_back_rings_t;
enum blkif_protocol { enum blkif_protocol {
BLKIF_PROTOCOL_NATIVE = 1, BLKIF_PROTOCOL_NATIVE = 1,
...@@ -90,7 +89,7 @@ enum blkif_protocol { ...@@ -90,7 +89,7 @@ enum blkif_protocol {
BLKIF_PROTOCOL_X86_64 = 3, BLKIF_PROTOCOL_X86_64 = 3,
}; };
static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_request_t *src) static void inline blkif_get_x86_32_req(struct blkif_request *dst, struct blkif_x86_32_request *src)
{ {
int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
dst->operation = src->operation; dst->operation = src->operation;
...@@ -105,7 +104,7 @@ static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque ...@@ -105,7 +104,7 @@ static void inline blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque
dst->seg[i] = src->seg[i]; dst->seg[i] = src->seg[i];
} }
static void inline blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_request_t *src) static void inline blkif_get_x86_64_req(struct blkif_request *dst, struct blkif_x86_64_request *src)
{ {
int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST; int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST;
dst->operation = src->operation; dst->operation = src->operation;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment