1 /* Xenbus code for blkif backend
2 Copyright (C) 2005 Rusty Russell <rusty@rustcorp.com.au>
3 Copyright (C) 2005 XenSource Ltd
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
18 #include <linux/module.h>
19 #include <linux/kthread.h>
20 #include <xen/events.h>
21 #include <xen/grant_table.h>
25 struct xenbus_device *dev;
26 struct xen_blkif *blkif;
27 struct xenbus_watch backend_watch;
33 static struct kmem_cache *xen_blkif_cachep;
34 static void connect(struct backend_info *);
35 static int connect_ring(struct backend_info *);
36 static void backend_changed(struct xenbus_watch *, const char **,
38 static void xen_blkif_free(struct xen_blkif *blkif);
39 static void xen_vbd_free(struct xen_vbd *vbd);
41 struct xenbus_device *xen_blkbk_xenbus(struct backend_info *be)
47 * The last request could free the device from softirq context and
48 * xen_blkif_free() can sleep.
50 static void xen_blkif_deferred_free(struct work_struct *work)
52 struct xen_blkif *blkif;
54 blkif = container_of(work, struct xen_blkif, free_work);
55 xen_blkif_free(blkif);
58 static int blkback_name(struct xen_blkif *blkif, char *buf)
60 char *devpath, *devname;
61 struct xenbus_device *dev = blkif->be->dev;
63 devpath = xenbus_read(XBT_NIL, dev->nodename, "dev", NULL);
65 return PTR_ERR(devpath);
67 devname = strstr(devpath, "/dev/");
69 devname += strlen("/dev/");
73 snprintf(buf, TASK_COMM_LEN, "blkback.%d.%s", blkif->domid, devname);
79 static void xen_update_blkif_status(struct xen_blkif *blkif)
82 char name[TASK_COMM_LEN];
84 /* Not ready to connect? */
85 if (!blkif->irq || !blkif->vbd.bdev)
88 /* Already connected? */
89 if (blkif->be->dev->state == XenbusStateConnected)
92 /* Attempt to connect: exit if we fail to. */
94 if (blkif->be->dev->state != XenbusStateConnected)
97 err = blkback_name(blkif, name);
99 xenbus_dev_error(blkif->be->dev, err, "get blkback dev name");
103 err = filemap_write_and_wait(blkif->vbd.bdev->bd_inode->i_mapping);
105 xenbus_dev_error(blkif->be->dev, err, "block flush");
108 invalidate_inode_pages2(blkif->vbd.bdev->bd_inode->i_mapping);
110 blkif->xenblkd = kthread_run(xen_blkif_schedule, blkif, "%s", name);
111 if (IS_ERR(blkif->xenblkd)) {
112 err = PTR_ERR(blkif->xenblkd);
113 blkif->xenblkd = NULL;
114 xenbus_dev_error(blkif->be->dev, err, "start xenblkd");
119 static struct xen_blkif *xen_blkif_alloc(domid_t domid)
121 struct xen_blkif *blkif;
122 struct pending_req *req, *n;
125 BUILD_BUG_ON(MAX_INDIRECT_PAGES > BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST);
127 blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL);
129 return ERR_PTR(-ENOMEM);
131 blkif->domid = domid;
132 spin_lock_init(&blkif->blk_ring_lock);
133 atomic_set(&blkif->refcnt, 1);
134 init_waitqueue_head(&blkif->wq);
135 init_completion(&blkif->drain_complete);
136 atomic_set(&blkif->drain, 0);
137 blkif->st_print = jiffies;
138 blkif->persistent_gnts.rb_node = NULL;
139 spin_lock_init(&blkif->free_pages_lock);
140 INIT_LIST_HEAD(&blkif->free_pages);
141 INIT_LIST_HEAD(&blkif->persistent_purge_list);
142 blkif->free_pages_num = 0;
143 atomic_set(&blkif->persistent_gnt_in_use, 0);
144 atomic_set(&blkif->inflight, 0);
145 INIT_WORK(&blkif->persistent_purge_work, xen_blkbk_unmap_purged_grants);
147 INIT_LIST_HEAD(&blkif->pending_free);
148 INIT_WORK(&blkif->free_work, xen_blkif_deferred_free);
150 for (i = 0; i < XEN_BLKIF_REQS; i++) {
151 req = kzalloc(sizeof(*req), GFP_KERNEL);
154 list_add_tail(&req->free_list,
155 &blkif->pending_free);
156 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
157 req->segments[j] = kzalloc(sizeof(*req->segments[0]),
159 if (!req->segments[j])
162 for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
163 req->indirect_pages[j] = kzalloc(sizeof(*req->indirect_pages[0]),
165 if (!req->indirect_pages[j])
169 spin_lock_init(&blkif->pending_free_lock);
170 init_waitqueue_head(&blkif->pending_free_wq);
171 init_waitqueue_head(&blkif->shutdown_wq);
176 list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
177 list_del(&req->free_list);
178 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++) {
179 if (!req->segments[j])
181 kfree(req->segments[j]);
183 for (j = 0; j < MAX_INDIRECT_PAGES; j++) {
184 if (!req->indirect_pages[j])
186 kfree(req->indirect_pages[j]);
191 kmem_cache_free(xen_blkif_cachep, blkif);
193 return ERR_PTR(-ENOMEM);
196 static int xen_blkif_map(struct xen_blkif *blkif, grant_ref_t gref,
201 /* Already connected through? */
205 err = xenbus_map_ring_valloc(blkif->be->dev, &gref, 1,
210 switch (blkif->blk_protocol) {
211 case BLKIF_PROTOCOL_NATIVE:
213 struct blkif_sring *sring;
214 sring = (struct blkif_sring *)blkif->blk_ring;
215 BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
218 case BLKIF_PROTOCOL_X86_32:
220 struct blkif_x86_32_sring *sring_x86_32;
221 sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring;
222 BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
225 case BLKIF_PROTOCOL_X86_64:
227 struct blkif_x86_64_sring *sring_x86_64;
228 sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring;
229 BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
236 err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn,
238 "blkif-backend", blkif);
240 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
241 blkif->blk_rings.common.sring = NULL;
249 static int xen_blkif_disconnect(struct xen_blkif *blkif)
251 if (blkif->xenblkd) {
252 kthread_stop(blkif->xenblkd);
253 wake_up(&blkif->shutdown_wq);
254 blkif->xenblkd = NULL;
257 /* The above kthread_stop() guarantees that at this point we
258 * don't have any discard_io or other_io requests. So, checking
259 * for inflight IO is enough.
261 if (atomic_read(&blkif->inflight) > 0)
265 unbind_from_irqhandler(blkif->irq, blkif);
269 if (blkif->blk_rings.common.sring) {
270 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
271 blkif->blk_rings.common.sring = NULL;
274 /* Remove all persistent grants and the cache of ballooned pages. */
275 xen_blkbk_free_caches(blkif);
280 static void xen_blkif_free(struct xen_blkif *blkif)
282 struct pending_req *req, *n;
285 xen_blkif_disconnect(blkif);
286 xen_vbd_free(&blkif->vbd);
288 /* Make sure everything is drained before shutting down */
289 BUG_ON(blkif->persistent_gnt_c != 0);
290 BUG_ON(atomic_read(&blkif->persistent_gnt_in_use) != 0);
291 BUG_ON(blkif->free_pages_num != 0);
292 BUG_ON(!list_empty(&blkif->persistent_purge_list));
293 BUG_ON(!list_empty(&blkif->free_pages));
294 BUG_ON(!RB_EMPTY_ROOT(&blkif->persistent_gnts));
296 /* Check that there is no request in use */
297 list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
298 list_del(&req->free_list);
300 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++)
301 kfree(req->segments[j]);
303 for (j = 0; j < MAX_INDIRECT_PAGES; j++)
304 kfree(req->indirect_pages[j]);
310 WARN_ON(i != XEN_BLKIF_REQS);
312 kmem_cache_free(xen_blkif_cachep, blkif);
315 int __init xen_blkif_interface_init(void)
317 xen_blkif_cachep = kmem_cache_create("blkif_cache",
318 sizeof(struct xen_blkif),
320 if (!xen_blkif_cachep)
327 * sysfs interface for VBD I/O requests
330 #define VBD_SHOW(name, format, args...) \
331 static ssize_t show_##name(struct device *_dev, \
332 struct device_attribute *attr, \
335 struct xenbus_device *dev = to_xenbus_device(_dev); \
336 struct backend_info *be = dev_get_drvdata(&dev->dev); \
338 return sprintf(buf, format, ##args); \
340 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
342 VBD_SHOW(oo_req, "%llu\n", be->blkif->st_oo_req);
343 VBD_SHOW(rd_req, "%llu\n", be->blkif->st_rd_req);
344 VBD_SHOW(wr_req, "%llu\n", be->blkif->st_wr_req);
345 VBD_SHOW(f_req, "%llu\n", be->blkif->st_f_req);
346 VBD_SHOW(ds_req, "%llu\n", be->blkif->st_ds_req);
347 VBD_SHOW(rd_sect, "%llu\n", be->blkif->st_rd_sect);
348 VBD_SHOW(wr_sect, "%llu\n", be->blkif->st_wr_sect);
350 static struct attribute *xen_vbdstat_attrs[] = {
351 &dev_attr_oo_req.attr,
352 &dev_attr_rd_req.attr,
353 &dev_attr_wr_req.attr,
354 &dev_attr_f_req.attr,
355 &dev_attr_ds_req.attr,
356 &dev_attr_rd_sect.attr,
357 &dev_attr_wr_sect.attr,
361 static struct attribute_group xen_vbdstat_group = {
362 .name = "statistics",
363 .attrs = xen_vbdstat_attrs,
366 VBD_SHOW(physical_device, "%x:%x\n", be->major, be->minor);
367 VBD_SHOW(mode, "%s\n", be->mode);
369 static int xenvbd_sysfs_addif(struct xenbus_device *dev)
373 error = device_create_file(&dev->dev, &dev_attr_physical_device);
377 error = device_create_file(&dev->dev, &dev_attr_mode);
381 error = sysfs_create_group(&dev->dev.kobj, &xen_vbdstat_group);
387 fail3: sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group);
388 fail2: device_remove_file(&dev->dev, &dev_attr_mode);
389 fail1: device_remove_file(&dev->dev, &dev_attr_physical_device);
393 static void xenvbd_sysfs_delif(struct xenbus_device *dev)
395 sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group);
396 device_remove_file(&dev->dev, &dev_attr_mode);
397 device_remove_file(&dev->dev, &dev_attr_physical_device);
401 static void xen_vbd_free(struct xen_vbd *vbd)
404 blkdev_put(vbd->bdev, vbd->readonly ? FMODE_READ : FMODE_WRITE);
408 static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
409 unsigned major, unsigned minor, int readonly,
413 struct block_device *bdev;
414 struct request_queue *q;
417 vbd->handle = handle;
418 vbd->readonly = readonly;
421 vbd->pdevice = MKDEV(major, minor);
423 bdev = blkdev_get_by_dev(vbd->pdevice, vbd->readonly ?
424 FMODE_READ : FMODE_WRITE, NULL);
427 DPRINTK("xen_vbd_create: device %08x could not be opened.\n",
433 if (vbd->bdev->bd_disk == NULL) {
434 DPRINTK("xen_vbd_create: device %08x doesn't exist.\n",
439 vbd->size = vbd_sz(vbd);
441 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
442 vbd->type |= VDISK_CDROM;
443 if (vbd->bdev->bd_disk->flags & GENHD_FL_REMOVABLE)
444 vbd->type |= VDISK_REMOVABLE;
446 q = bdev_get_queue(bdev);
447 if (q && q->flush_flags)
448 vbd->flush_support = true;
450 if (q && blk_queue_secdiscard(q))
451 vbd->discard_secure = true;
453 DPRINTK("Successful creation of handle=%04x (dom=%u)\n",
454 handle, blkif->domid);
457 static int xen_blkbk_remove(struct xenbus_device *dev)
459 struct backend_info *be = dev_get_drvdata(&dev->dev);
463 if (be->major || be->minor)
464 xenvbd_sysfs_delif(dev);
466 if (be->backend_watch.node) {
467 unregister_xenbus_watch(&be->backend_watch);
468 kfree(be->backend_watch.node);
469 be->backend_watch.node = NULL;
472 dev_set_drvdata(&dev->dev, NULL);
475 xen_blkif_disconnect(be->blkif);
476 xen_blkif_put(be->blkif);
484 int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
485 struct backend_info *be, int state)
487 struct xenbus_device *dev = be->dev;
490 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache",
493 dev_warn(&dev->dev, "writing feature-flush-cache (%d)", err);
498 static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
500 struct xenbus_device *dev = be->dev;
501 struct xen_blkif *blkif = be->blkif;
503 int state = 0, discard_enable;
504 struct block_device *bdev = be->blkif->vbd.bdev;
505 struct request_queue *q = bdev_get_queue(bdev);
507 err = xenbus_scanf(XBT_NIL, dev->nodename, "discard-enable", "%d",
509 if (err == 1 && !discard_enable)
512 if (blk_queue_discard(q)) {
513 err = xenbus_printf(xbt, dev->nodename,
514 "discard-granularity", "%u",
515 q->limits.discard_granularity);
517 dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
520 err = xenbus_printf(xbt, dev->nodename,
521 "discard-alignment", "%u",
522 q->limits.discard_alignment);
524 dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
529 err = xenbus_printf(xbt, dev->nodename,
530 "discard-secure", "%d",
531 blkif->vbd.discard_secure);
533 dev_warn(&dev->dev, "writing discard-secure (%d)", err);
537 err = xenbus_printf(xbt, dev->nodename, "feature-discard",
540 dev_warn(&dev->dev, "writing feature-discard (%d)", err);
542 int xen_blkbk_barrier(struct xenbus_transaction xbt,
543 struct backend_info *be, int state)
545 struct xenbus_device *dev = be->dev;
548 err = xenbus_printf(xbt, dev->nodename, "feature-barrier",
551 dev_warn(&dev->dev, "writing feature-barrier (%d)", err);
557 * Entry point to this code when a new device is created. Allocate the basic
558 * structures, and watch the store waiting for the hotplug scripts to tell us
559 * the device's physical major and minor numbers. Switch to InitWait.
561 static int xen_blkbk_probe(struct xenbus_device *dev,
562 const struct xenbus_device_id *id)
565 struct backend_info *be = kzalloc(sizeof(struct backend_info),
568 xenbus_dev_fatal(dev, -ENOMEM,
569 "allocating backend structure");
573 dev_set_drvdata(&dev->dev, be);
575 be->blkif = xen_blkif_alloc(dev->otherend_id);
576 if (IS_ERR(be->blkif)) {
577 err = PTR_ERR(be->blkif);
579 xenbus_dev_fatal(dev, err, "creating block interface");
583 /* setup back pointer */
586 err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
587 "%s/%s", dev->nodename, "physical-device");
591 err = xenbus_switch_state(dev, XenbusStateInitWait);
599 xen_blkbk_remove(dev);
605 * Callback received when the hotplug scripts have placed the physical-device
606 * node. Read it and the mode node, and create a vbd. If the frontend is
609 static void backend_changed(struct xenbus_watch *watch,
610 const char **vec, unsigned int len)
615 struct backend_info *be
616 = container_of(watch, struct backend_info, backend_watch);
617 struct xenbus_device *dev = be->dev;
619 unsigned long handle;
624 err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", "%x:%x",
626 if (XENBUS_EXIST_ERR(err)) {
628 * Since this watch will fire once immediately after it is
629 * registered, we expect this. Ignore it, and wait for the
635 xenbus_dev_fatal(dev, err, "reading physical-device");
639 if (be->major | be->minor) {
640 if (be->major != major || be->minor != minor)
641 pr_warn(DRV_PFX "changing physical device (from %x:%x to %x:%x) not supported.\n",
642 be->major, be->minor, major, minor);
646 be->mode = xenbus_read(XBT_NIL, dev->nodename, "mode", NULL);
647 if (IS_ERR(be->mode)) {
648 err = PTR_ERR(be->mode);
650 xenbus_dev_fatal(dev, err, "reading mode");
654 device_type = xenbus_read(XBT_NIL, dev->otherend, "device-type", NULL);
655 if (!IS_ERR(device_type)) {
656 cdrom = strcmp(device_type, "cdrom") == 0;
660 /* Front end dir is a number, which is used as the handle. */
661 err = kstrtoul(strrchr(dev->otherend, '/') + 1, 0, &handle);
668 err = xen_vbd_create(be->blkif, handle, major, minor,
669 !strchr(be->mode, 'w'), cdrom);
672 xenbus_dev_fatal(dev, err, "creating vbd structure");
674 err = xenvbd_sysfs_addif(dev);
676 xen_vbd_free(&be->blkif->vbd);
677 xenbus_dev_fatal(dev, err, "creating sysfs entries");
687 /* We're potentially connected now */
688 xen_update_blkif_status(be->blkif);
694 * Callback received when the frontend's state changes.
696 static void frontend_changed(struct xenbus_device *dev,
697 enum xenbus_state frontend_state)
699 struct backend_info *be = dev_get_drvdata(&dev->dev);
702 DPRINTK("%s", xenbus_strstate(frontend_state));
704 switch (frontend_state) {
705 case XenbusStateInitialising:
706 if (dev->state == XenbusStateClosed) {
707 pr_info(DRV_PFX "%s: prepare for reconnect\n",
709 xenbus_switch_state(dev, XenbusStateInitWait);
713 case XenbusStateInitialised:
714 case XenbusStateConnected:
716 * Ensure we connect even when two watches fire in
717 * close succession and we miss the intermediate value
720 if (dev->state == XenbusStateConnected)
724 * Enforce precondition before potential leak point.
725 * xen_blkif_disconnect() is idempotent.
727 err = xen_blkif_disconnect(be->blkif);
729 xenbus_dev_fatal(dev, err, "pending I/O");
733 err = connect_ring(be);
736 xen_update_blkif_status(be->blkif);
739 case XenbusStateClosing:
740 xenbus_switch_state(dev, XenbusStateClosing);
743 case XenbusStateClosed:
744 xen_blkif_disconnect(be->blkif);
745 xenbus_switch_state(dev, XenbusStateClosed);
746 if (xenbus_dev_is_online(dev))
748 /* fall through if not online */
749 case XenbusStateUnknown:
750 /* implies xen_blkif_disconnect() via xen_blkbk_remove() */
751 device_unregister(&dev->dev);
755 xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
762 /* ** Connection ** */
766 * Write the physical details regarding the block device to the store, and
767 * switch to Connected state.
769 static void connect(struct backend_info *be)
771 struct xenbus_transaction xbt;
773 struct xenbus_device *dev = be->dev;
775 DPRINTK("%s", dev->otherend);
777 /* Supply the information about the device the frontend needs */
779 err = xenbus_transaction_start(&xbt);
781 xenbus_dev_fatal(dev, err, "starting transaction");
785 /* If we can't advertise it is OK. */
786 xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support);
788 xen_blkbk_discard(xbt, be);
790 xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
792 err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", 1);
794 xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
798 err = xenbus_printf(xbt, dev->nodename, "feature-max-indirect-segments", "%u",
799 MAX_INDIRECT_SEGMENTS);
801 dev_warn(&dev->dev, "writing %s/feature-max-indirect-segments (%d)",
804 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
805 (unsigned long long)vbd_sz(&be->blkif->vbd));
807 xenbus_dev_fatal(dev, err, "writing %s/sectors",
812 /* FIXME: use a typename instead */
813 err = xenbus_printf(xbt, dev->nodename, "info", "%u",
814 be->blkif->vbd.type |
815 (be->blkif->vbd.readonly ? VDISK_READONLY : 0));
817 xenbus_dev_fatal(dev, err, "writing %s/info",
821 err = xenbus_printf(xbt, dev->nodename, "sector-size", "%lu",
823 bdev_logical_block_size(be->blkif->vbd.bdev));
825 xenbus_dev_fatal(dev, err, "writing %s/sector-size",
829 err = xenbus_printf(xbt, dev->nodename, "physical-sector-size", "%u",
830 bdev_physical_block_size(be->blkif->vbd.bdev));
832 xenbus_dev_error(dev, err, "writing %s/physical-sector-size",
835 err = xenbus_transaction_end(xbt, 0);
839 xenbus_dev_fatal(dev, err, "ending transaction");
841 err = xenbus_switch_state(dev, XenbusStateConnected);
843 xenbus_dev_fatal(dev, err, "%s: switching to Connected state",
848 xenbus_transaction_end(xbt, 1);
852 static int connect_ring(struct backend_info *be)
854 struct xenbus_device *dev = be->dev;
855 unsigned long ring_ref;
857 unsigned int pers_grants;
858 char protocol[64] = "";
861 DPRINTK("%s", dev->otherend);
863 err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu",
864 &ring_ref, "event-channel", "%u", &evtchn, NULL);
866 xenbus_dev_fatal(dev, err,
867 "reading %s/ring-ref and event-channel",
872 be->blkif->blk_protocol = BLKIF_PROTOCOL_DEFAULT;
873 err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
874 "%63s", protocol, NULL);
876 strcpy(protocol, "unspecified, assuming default");
877 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
878 be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
879 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
880 be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32;
881 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64))
882 be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
884 xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
887 err = xenbus_gather(XBT_NIL, dev->otherend,
888 "feature-persistent", "%u",
893 be->blkif->vbd.feature_gnt_persistent = pers_grants;
894 be->blkif->vbd.overflow_max_grants = 0;
896 pr_info(DRV_PFX "ring-ref %ld, event-channel %d, protocol %d (%s) %s\n",
897 ring_ref, evtchn, be->blkif->blk_protocol, protocol,
898 pers_grants ? "persistent grants" : "");
900 /* Map the shared frame, irq etc. */
901 err = xen_blkif_map(be->blkif, ring_ref, evtchn);
903 xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
911 static const struct xenbus_device_id xen_blkbk_ids[] = {
916 static struct xenbus_driver xen_blkbk_driver = {
917 .ids = xen_blkbk_ids,
918 .probe = xen_blkbk_probe,
919 .remove = xen_blkbk_remove,
920 .otherend_changed = frontend_changed
923 int xen_blkif_xenbus_init(void)
925 return xenbus_register_backend(&xen_blkbk_driver);