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, unsigned long shared_page,
201 /* Already connected through? */
205 err = xenbus_map_ring_valloc(blkif->be->dev, shared_page, &blkif->blk_ring);
209 switch (blkif->blk_protocol) {
210 case BLKIF_PROTOCOL_NATIVE:
212 struct blkif_sring *sring;
213 sring = (struct blkif_sring *)blkif->blk_ring;
214 BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
217 case BLKIF_PROTOCOL_X86_32:
219 struct blkif_x86_32_sring *sring_x86_32;
220 sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring;
221 BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
224 case BLKIF_PROTOCOL_X86_64:
226 struct blkif_x86_64_sring *sring_x86_64;
227 sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring;
228 BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
235 err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn,
237 "blkif-backend", blkif);
239 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
240 blkif->blk_rings.common.sring = NULL;
248 static int xen_blkif_disconnect(struct xen_blkif *blkif)
250 if (blkif->xenblkd) {
251 kthread_stop(blkif->xenblkd);
252 wake_up(&blkif->shutdown_wq);
253 blkif->xenblkd = NULL;
256 /* The above kthread_stop() guarantees that at this point we
257 * don't have any discard_io or other_io requests. So, checking
258 * for inflight IO is enough.
260 if (atomic_read(&blkif->inflight) > 0)
264 unbind_from_irqhandler(blkif->irq, blkif);
268 if (blkif->blk_rings.common.sring) {
269 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
270 blkif->blk_rings.common.sring = NULL;
273 /* Remove all persistent grants and the cache of ballooned pages. */
274 xen_blkbk_free_caches(blkif);
279 static void xen_blkif_free(struct xen_blkif *blkif)
281 struct pending_req *req, *n;
284 xen_blkif_disconnect(blkif);
285 xen_vbd_free(&blkif->vbd);
287 /* Make sure everything is drained before shutting down */
288 BUG_ON(blkif->persistent_gnt_c != 0);
289 BUG_ON(atomic_read(&blkif->persistent_gnt_in_use) != 0);
290 BUG_ON(blkif->free_pages_num != 0);
291 BUG_ON(!list_empty(&blkif->persistent_purge_list));
292 BUG_ON(!list_empty(&blkif->free_pages));
293 BUG_ON(!RB_EMPTY_ROOT(&blkif->persistent_gnts));
295 /* Check that there is no request in use */
296 list_for_each_entry_safe(req, n, &blkif->pending_free, free_list) {
297 list_del(&req->free_list);
299 for (j = 0; j < MAX_INDIRECT_SEGMENTS; j++)
300 kfree(req->segments[j]);
302 for (j = 0; j < MAX_INDIRECT_PAGES; j++)
303 kfree(req->indirect_pages[j]);
309 WARN_ON(i != XEN_BLKIF_REQS);
311 kmem_cache_free(xen_blkif_cachep, blkif);
314 int __init xen_blkif_interface_init(void)
316 xen_blkif_cachep = kmem_cache_create("blkif_cache",
317 sizeof(struct xen_blkif),
319 if (!xen_blkif_cachep)
326 * sysfs interface for VBD I/O requests
329 #define VBD_SHOW(name, format, args...) \
330 static ssize_t show_##name(struct device *_dev, \
331 struct device_attribute *attr, \
334 struct xenbus_device *dev = to_xenbus_device(_dev); \
335 struct backend_info *be = dev_get_drvdata(&dev->dev); \
337 return sprintf(buf, format, ##args); \
339 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
341 VBD_SHOW(oo_req, "%llu\n", be->blkif->st_oo_req);
342 VBD_SHOW(rd_req, "%llu\n", be->blkif->st_rd_req);
343 VBD_SHOW(wr_req, "%llu\n", be->blkif->st_wr_req);
344 VBD_SHOW(f_req, "%llu\n", be->blkif->st_f_req);
345 VBD_SHOW(ds_req, "%llu\n", be->blkif->st_ds_req);
346 VBD_SHOW(rd_sect, "%llu\n", be->blkif->st_rd_sect);
347 VBD_SHOW(wr_sect, "%llu\n", be->blkif->st_wr_sect);
349 static struct attribute *xen_vbdstat_attrs[] = {
350 &dev_attr_oo_req.attr,
351 &dev_attr_rd_req.attr,
352 &dev_attr_wr_req.attr,
353 &dev_attr_f_req.attr,
354 &dev_attr_ds_req.attr,
355 &dev_attr_rd_sect.attr,
356 &dev_attr_wr_sect.attr,
360 static struct attribute_group xen_vbdstat_group = {
361 .name = "statistics",
362 .attrs = xen_vbdstat_attrs,
365 VBD_SHOW(physical_device, "%x:%x\n", be->major, be->minor);
366 VBD_SHOW(mode, "%s\n", be->mode);
368 static int xenvbd_sysfs_addif(struct xenbus_device *dev)
372 error = device_create_file(&dev->dev, &dev_attr_physical_device);
376 error = device_create_file(&dev->dev, &dev_attr_mode);
380 error = sysfs_create_group(&dev->dev.kobj, &xen_vbdstat_group);
386 fail3: sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group);
387 fail2: device_remove_file(&dev->dev, &dev_attr_mode);
388 fail1: device_remove_file(&dev->dev, &dev_attr_physical_device);
392 static void xenvbd_sysfs_delif(struct xenbus_device *dev)
394 sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group);
395 device_remove_file(&dev->dev, &dev_attr_mode);
396 device_remove_file(&dev->dev, &dev_attr_physical_device);
400 static void xen_vbd_free(struct xen_vbd *vbd)
403 blkdev_put(vbd->bdev, vbd->readonly ? FMODE_READ : FMODE_WRITE);
407 static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
408 unsigned major, unsigned minor, int readonly,
412 struct block_device *bdev;
413 struct request_queue *q;
416 vbd->handle = handle;
417 vbd->readonly = readonly;
420 vbd->pdevice = MKDEV(major, minor);
422 bdev = blkdev_get_by_dev(vbd->pdevice, vbd->readonly ?
423 FMODE_READ : FMODE_WRITE, NULL);
426 DPRINTK("xen_vbd_create: device %08x could not be opened.\n",
432 if (vbd->bdev->bd_disk == NULL) {
433 DPRINTK("xen_vbd_create: device %08x doesn't exist.\n",
438 vbd->size = vbd_sz(vbd);
440 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
441 vbd->type |= VDISK_CDROM;
442 if (vbd->bdev->bd_disk->flags & GENHD_FL_REMOVABLE)
443 vbd->type |= VDISK_REMOVABLE;
445 q = bdev_get_queue(bdev);
446 if (q && q->flush_flags)
447 vbd->flush_support = true;
449 if (q && blk_queue_secdiscard(q))
450 vbd->discard_secure = true;
452 DPRINTK("Successful creation of handle=%04x (dom=%u)\n",
453 handle, blkif->domid);
456 static int xen_blkbk_remove(struct xenbus_device *dev)
458 struct backend_info *be = dev_get_drvdata(&dev->dev);
462 if (be->major || be->minor)
463 xenvbd_sysfs_delif(dev);
465 if (be->backend_watch.node) {
466 unregister_xenbus_watch(&be->backend_watch);
467 kfree(be->backend_watch.node);
468 be->backend_watch.node = NULL;
471 dev_set_drvdata(&dev->dev, NULL);
474 xen_blkif_disconnect(be->blkif);
475 xen_blkif_put(be->blkif);
483 int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
484 struct backend_info *be, int state)
486 struct xenbus_device *dev = be->dev;
489 err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache",
492 dev_warn(&dev->dev, "writing feature-flush-cache (%d)", err);
497 static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
499 struct xenbus_device *dev = be->dev;
500 struct xen_blkif *blkif = be->blkif;
502 int state = 0, discard_enable;
503 struct block_device *bdev = be->blkif->vbd.bdev;
504 struct request_queue *q = bdev_get_queue(bdev);
506 err = xenbus_scanf(XBT_NIL, dev->nodename, "discard-enable", "%d",
508 if (err == 1 && !discard_enable)
511 if (blk_queue_discard(q)) {
512 err = xenbus_printf(xbt, dev->nodename,
513 "discard-granularity", "%u",
514 q->limits.discard_granularity);
516 dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
519 err = xenbus_printf(xbt, dev->nodename,
520 "discard-alignment", "%u",
521 q->limits.discard_alignment);
523 dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
528 err = xenbus_printf(xbt, dev->nodename,
529 "discard-secure", "%d",
530 blkif->vbd.discard_secure);
532 dev_warn(&dev->dev, "writing discard-secure (%d)", err);
536 err = xenbus_printf(xbt, dev->nodename, "feature-discard",
539 dev_warn(&dev->dev, "writing feature-discard (%d)", err);
541 int xen_blkbk_barrier(struct xenbus_transaction xbt,
542 struct backend_info *be, int state)
544 struct xenbus_device *dev = be->dev;
547 err = xenbus_printf(xbt, dev->nodename, "feature-barrier",
550 dev_warn(&dev->dev, "writing feature-barrier (%d)", err);
556 * Entry point to this code when a new device is created. Allocate the basic
557 * structures, and watch the store waiting for the hotplug scripts to tell us
558 * the device's physical major and minor numbers. Switch to InitWait.
560 static int xen_blkbk_probe(struct xenbus_device *dev,
561 const struct xenbus_device_id *id)
564 struct backend_info *be = kzalloc(sizeof(struct backend_info),
567 xenbus_dev_fatal(dev, -ENOMEM,
568 "allocating backend structure");
572 dev_set_drvdata(&dev->dev, be);
574 be->blkif = xen_blkif_alloc(dev->otherend_id);
575 if (IS_ERR(be->blkif)) {
576 err = PTR_ERR(be->blkif);
578 xenbus_dev_fatal(dev, err, "creating block interface");
582 /* setup back pointer */
585 err = xenbus_watch_pathfmt(dev, &be->backend_watch, backend_changed,
586 "%s/%s", dev->nodename, "physical-device");
590 err = xenbus_switch_state(dev, XenbusStateInitWait);
598 xen_blkbk_remove(dev);
604 * Callback received when the hotplug scripts have placed the physical-device
605 * node. Read it and the mode node, and create a vbd. If the frontend is
608 static void backend_changed(struct xenbus_watch *watch,
609 const char **vec, unsigned int len)
614 struct backend_info *be
615 = container_of(watch, struct backend_info, backend_watch);
616 struct xenbus_device *dev = be->dev;
618 unsigned long handle;
623 err = xenbus_scanf(XBT_NIL, dev->nodename, "physical-device", "%x:%x",
625 if (XENBUS_EXIST_ERR(err)) {
627 * Since this watch will fire once immediately after it is
628 * registered, we expect this. Ignore it, and wait for the
634 xenbus_dev_fatal(dev, err, "reading physical-device");
638 if (be->major | be->minor) {
639 if (be->major != major || be->minor != minor)
640 pr_warn(DRV_PFX "changing physical device (from %x:%x to %x:%x) not supported.\n",
641 be->major, be->minor, major, minor);
645 be->mode = xenbus_read(XBT_NIL, dev->nodename, "mode", NULL);
646 if (IS_ERR(be->mode)) {
647 err = PTR_ERR(be->mode);
649 xenbus_dev_fatal(dev, err, "reading mode");
653 device_type = xenbus_read(XBT_NIL, dev->otherend, "device-type", NULL);
654 if (!IS_ERR(device_type)) {
655 cdrom = strcmp(device_type, "cdrom") == 0;
659 /* Front end dir is a number, which is used as the handle. */
660 err = kstrtoul(strrchr(dev->otherend, '/') + 1, 0, &handle);
667 err = xen_vbd_create(be->blkif, handle, major, minor,
668 !strchr(be->mode, 'w'), cdrom);
671 xenbus_dev_fatal(dev, err, "creating vbd structure");
673 err = xenvbd_sysfs_addif(dev);
675 xen_vbd_free(&be->blkif->vbd);
676 xenbus_dev_fatal(dev, err, "creating sysfs entries");
686 /* We're potentially connected now */
687 xen_update_blkif_status(be->blkif);
693 * Callback received when the frontend's state changes.
695 static void frontend_changed(struct xenbus_device *dev,
696 enum xenbus_state frontend_state)
698 struct backend_info *be = dev_get_drvdata(&dev->dev);
701 DPRINTK("%s", xenbus_strstate(frontend_state));
703 switch (frontend_state) {
704 case XenbusStateInitialising:
705 if (dev->state == XenbusStateClosed) {
706 pr_info(DRV_PFX "%s: prepare for reconnect\n",
708 xenbus_switch_state(dev, XenbusStateInitWait);
712 case XenbusStateInitialised:
713 case XenbusStateConnected:
715 * Ensure we connect even when two watches fire in
716 * close succession and we miss the intermediate value
719 if (dev->state == XenbusStateConnected)
723 * Enforce precondition before potential leak point.
724 * xen_blkif_disconnect() is idempotent.
726 err = xen_blkif_disconnect(be->blkif);
728 xenbus_dev_fatal(dev, err, "pending I/O");
732 err = connect_ring(be);
735 xen_update_blkif_status(be->blkif);
738 case XenbusStateClosing:
739 xenbus_switch_state(dev, XenbusStateClosing);
742 case XenbusStateClosed:
743 xen_blkif_disconnect(be->blkif);
744 xenbus_switch_state(dev, XenbusStateClosed);
745 if (xenbus_dev_is_online(dev))
747 /* fall through if not online */
748 case XenbusStateUnknown:
749 /* implies xen_blkif_disconnect() via xen_blkbk_remove() */
750 device_unregister(&dev->dev);
754 xenbus_dev_fatal(dev, -EINVAL, "saw state %d at frontend",
761 /* ** Connection ** */
765 * Write the physical details regarding the block device to the store, and
766 * switch to Connected state.
768 static void connect(struct backend_info *be)
770 struct xenbus_transaction xbt;
772 struct xenbus_device *dev = be->dev;
774 DPRINTK("%s", dev->otherend);
776 /* Supply the information about the device the frontend needs */
778 err = xenbus_transaction_start(&xbt);
780 xenbus_dev_fatal(dev, err, "starting transaction");
784 /* If we can't advertise it is OK. */
785 xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support);
787 xen_blkbk_discard(xbt, be);
789 xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
791 err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", 1);
793 xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
797 err = xenbus_printf(xbt, dev->nodename, "feature-max-indirect-segments", "%u",
798 MAX_INDIRECT_SEGMENTS);
800 dev_warn(&dev->dev, "writing %s/feature-max-indirect-segments (%d)",
803 err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
804 (unsigned long long)vbd_sz(&be->blkif->vbd));
806 xenbus_dev_fatal(dev, err, "writing %s/sectors",
811 /* FIXME: use a typename instead */
812 err = xenbus_printf(xbt, dev->nodename, "info", "%u",
813 be->blkif->vbd.type |
814 (be->blkif->vbd.readonly ? VDISK_READONLY : 0));
816 xenbus_dev_fatal(dev, err, "writing %s/info",
820 err = xenbus_printf(xbt, dev->nodename, "sector-size", "%lu",
822 bdev_logical_block_size(be->blkif->vbd.bdev));
824 xenbus_dev_fatal(dev, err, "writing %s/sector-size",
828 err = xenbus_printf(xbt, dev->nodename, "physical-sector-size", "%u",
829 bdev_physical_block_size(be->blkif->vbd.bdev));
831 xenbus_dev_error(dev, err, "writing %s/physical-sector-size",
834 err = xenbus_transaction_end(xbt, 0);
838 xenbus_dev_fatal(dev, err, "ending transaction");
840 err = xenbus_switch_state(dev, XenbusStateConnected);
842 xenbus_dev_fatal(dev, err, "%s: switching to Connected state",
847 xenbus_transaction_end(xbt, 1);
851 static int connect_ring(struct backend_info *be)
853 struct xenbus_device *dev = be->dev;
854 unsigned long ring_ref;
856 unsigned int pers_grants;
857 char protocol[64] = "";
860 DPRINTK("%s", dev->otherend);
862 err = xenbus_gather(XBT_NIL, dev->otherend, "ring-ref", "%lu",
863 &ring_ref, "event-channel", "%u", &evtchn, NULL);
865 xenbus_dev_fatal(dev, err,
866 "reading %s/ring-ref and event-channel",
871 be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
872 err = xenbus_gather(XBT_NIL, dev->otherend, "protocol",
873 "%63s", protocol, NULL);
875 strcpy(protocol, "unspecified, assuming native");
876 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_NATIVE))
877 be->blkif->blk_protocol = BLKIF_PROTOCOL_NATIVE;
878 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_32))
879 be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_32;
880 else if (0 == strcmp(protocol, XEN_IO_PROTO_ABI_X86_64))
881 be->blkif->blk_protocol = BLKIF_PROTOCOL_X86_64;
883 xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
886 err = xenbus_gather(XBT_NIL, dev->otherend,
887 "feature-persistent", "%u",
892 be->blkif->vbd.feature_gnt_persistent = pers_grants;
893 be->blkif->vbd.overflow_max_grants = 0;
895 pr_info(DRV_PFX "ring-ref %ld, event-channel %d, protocol %d (%s) %s\n",
896 ring_ref, evtchn, be->blkif->blk_protocol, protocol,
897 pers_grants ? "persistent grants" : "");
899 /* Map the shared frame, irq etc. */
900 err = xen_blkif_map(be->blkif, ring_ref, evtchn);
902 xenbus_dev_fatal(dev, err, "mapping ring-ref %lu port %u",
910 static const struct xenbus_device_id xen_blkbk_ids[] = {
915 static struct xenbus_driver xen_blkbk_driver = {
916 .ids = xen_blkbk_ids,
917 .probe = xen_blkbk_probe,
918 .remove = xen_blkbk_remove,
919 .otherend_changed = frontend_changed
922 int xen_blkif_xenbus_init(void)
924 return xenbus_register_backend(&xen_blkbk_driver);