Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-5.5b-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
"This contains two cleanup patches and a small series for supporting
reloading the Xen block backend driver"

* tag 'for-linus-5.5b-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
xen/grant-table: remove multiple BUG_ON on gnttab_interface
xen-blkback: support dynamic unbind/bind
xen/interface: re-define FRONT/BACK_RING_ATTACH()
xenbus: limit when state is forced to closed
xenbus: move xenbus_dev_shutdown() into frontend code...
xen/blkfront: Adjust indentation in xlvbd_alloc_gendisk

+83 -73
+38 -18
drivers/block/xen-blkback/xenbus.c
··· 190 190 { 191 191 int err; 192 192 struct xen_blkif *blkif = ring->blkif; 193 + const struct blkif_common_sring *sring_common; 194 + RING_IDX rsp_prod, req_prod; 195 + unsigned int size; 193 196 194 197 /* Already connected through? */ 195 198 if (ring->irq) ··· 203 200 if (err < 0) 204 201 return err; 205 202 203 + sring_common = (struct blkif_common_sring *)ring->blk_ring; 204 + rsp_prod = READ_ONCE(sring_common->rsp_prod); 205 + req_prod = READ_ONCE(sring_common->req_prod); 206 + 206 207 switch (blkif->blk_protocol) { 207 208 case BLKIF_PROTOCOL_NATIVE: 208 209 { 209 - struct blkif_sring *sring; 210 - sring = (struct blkif_sring *)ring->blk_ring; 211 - BACK_RING_INIT(&ring->blk_rings.native, sring, 212 - XEN_PAGE_SIZE * nr_grefs); 210 + struct blkif_sring *sring_native = 211 + (struct blkif_sring *)ring->blk_ring; 212 + 213 + BACK_RING_ATTACH(&ring->blk_rings.native, sring_native, 214 + rsp_prod, XEN_PAGE_SIZE * nr_grefs); 215 + size = __RING_SIZE(sring_native, XEN_PAGE_SIZE * nr_grefs); 213 216 break; 214 217 } 215 218 case BLKIF_PROTOCOL_X86_32: 216 219 { 217 - struct blkif_x86_32_sring *sring_x86_32; 218 - sring_x86_32 = (struct blkif_x86_32_sring *)ring->blk_ring; 219 - BACK_RING_INIT(&ring->blk_rings.x86_32, sring_x86_32, 220 - XEN_PAGE_SIZE * nr_grefs); 220 + struct blkif_x86_32_sring *sring_x86_32 = 221 + (struct blkif_x86_32_sring *)ring->blk_ring; 222 + 223 + BACK_RING_ATTACH(&ring->blk_rings.x86_32, sring_x86_32, 224 + rsp_prod, XEN_PAGE_SIZE * nr_grefs); 225 + size = __RING_SIZE(sring_x86_32, XEN_PAGE_SIZE * nr_grefs); 221 226 break; 222 227 } 223 228 case BLKIF_PROTOCOL_X86_64: 224 229 { 225 - struct blkif_x86_64_sring *sring_x86_64; 226 - sring_x86_64 = (struct blkif_x86_64_sring *)ring->blk_ring; 227 - BACK_RING_INIT(&ring->blk_rings.x86_64, sring_x86_64, 228 - XEN_PAGE_SIZE * nr_grefs); 230 + struct blkif_x86_64_sring *sring_x86_64 = 231 + (struct blkif_x86_64_sring *)ring->blk_ring; 232 + 233 + BACK_RING_ATTACH(&ring->blk_rings.x86_64, sring_x86_64, 234 + rsp_prod, XEN_PAGE_SIZE * nr_grefs); 235 + size = __RING_SIZE(sring_x86_64, XEN_PAGE_SIZE * nr_grefs); 229 236 break; 230 237 } 231 238 default: 232 239 BUG(); 233 240 } 234 241 242 + err = -EIO; 243 + if (req_prod - rsp_prod > size) 244 + goto fail; 245 + 235 246 err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn, 236 247 xen_blkif_be_int, 0, 237 248 "blkif-backend", ring); 238 - if (err < 0) { 239 - xenbus_unmap_ring_vfree(blkif->be->dev, ring->blk_ring); 240 - ring->blk_rings.common.sring = NULL; 241 - return err; 242 - } 249 + if (err < 0) 250 + goto fail; 243 251 ring->irq = err; 244 252 245 253 return 0; 254 + 255 + fail: 256 + xenbus_unmap_ring_vfree(blkif->be->dev, ring->blk_ring); 257 + ring->blk_rings.common.sring = NULL; 258 + return err; 246 259 } 247 260 248 261 static int xen_blkif_disconnect(struct xen_blkif *blkif) ··· 1150 1131 .ids = xen_blkbk_ids, 1151 1132 .probe = xen_blkbk_probe, 1152 1133 .remove = xen_blkbk_remove, 1153 - .otherend_changed = frontend_changed 1134 + .otherend_changed = frontend_changed, 1135 + .allow_rebind = true, 1154 1136 }; 1155 1137 1156 1138 int xen_blkif_xenbus_init(void)
+2 -2
drivers/block/xen-blkfront.c
··· 1113 1113 if (!VDEV_IS_EXTENDED(info->vdevice)) { 1114 1114 err = xen_translate_vdev(info->vdevice, &minor, &offset); 1115 1115 if (err) 1116 - return err; 1117 - nr_parts = PARTS_PER_DISK; 1116 + return err; 1117 + nr_parts = PARTS_PER_DISK; 1118 1118 } else { 1119 1119 minor = BLKIF_MINOR_EXT(info->vdevice); 1120 1120 nr_parts = PARTS_PER_EXT_DISK;
-4
drivers/xen/grant-table.c
··· 664 664 unsigned int nr_glist_frames, new_nr_glist_frames; 665 665 unsigned int grefs_per_frame; 666 666 667 - BUG_ON(gnttab_interface == NULL); 668 667 grefs_per_frame = gnttab_interface->grefs_per_grant_frame; 669 668 670 669 new_nr_grant_frames = nr_grant_frames + more_frames; ··· 1159 1160 1160 1161 static unsigned int nr_status_frames(unsigned int nr_grant_frames) 1161 1162 { 1162 - BUG_ON(gnttab_interface == NULL); 1163 1163 return gnttab_frames(nr_grant_frames, SPP); 1164 1164 } 1165 1165 ··· 1386 1388 int rc; 1387 1389 unsigned int cur, extra; 1388 1390 1389 - BUG_ON(gnttab_interface == NULL); 1390 1391 cur = nr_grant_frames; 1391 1392 extra = ((req_entries + gnttab_interface->grefs_per_grant_frame - 1) / 1392 1393 gnttab_interface->grefs_per_grant_frame); ··· 1420 1423 /* Determine the maximum number of frames required for the 1421 1424 * grant reference free list on the current hypervisor. 1422 1425 */ 1423 - BUG_ON(gnttab_interface == NULL); 1424 1426 max_nr_glist_frames = (max_nr_grant_frames * 1425 1427 gnttab_interface->grefs_per_grant_frame / RPP); 1426 1428
-2
drivers/xen/xenbus/xenbus.h
··· 116 116 117 117 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus); 118 118 119 - void xenbus_dev_shutdown(struct device *_dev); 120 - 121 119 int xenbus_dev_suspend(struct device *dev); 122 120 int xenbus_dev_resume(struct device *dev); 123 121 int xenbus_dev_cancel(struct device *dev);
+10 -25
drivers/xen/xenbus/xenbus_probe.c
··· 255 255 module_put(drv->driver.owner); 256 256 fail: 257 257 xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); 258 - xenbus_switch_state(dev, XenbusStateClosed); 259 258 return err; 260 259 } 261 260 EXPORT_SYMBOL_GPL(xenbus_dev_probe); ··· 275 276 276 277 free_otherend_details(dev); 277 278 278 - xenbus_switch_state(dev, XenbusStateClosed); 279 + /* 280 + * If the toolstack has forced the device state to closing then set 281 + * the state to closed now to allow it to be cleaned up. 282 + * Similarly, if the driver does not support re-bind, set the 283 + * closed. 284 + */ 285 + if (!drv->allow_rebind || 286 + xenbus_read_driver_state(dev->nodename) == XenbusStateClosing) 287 + xenbus_switch_state(dev, XenbusStateClosed); 288 + 279 289 return 0; 280 290 } 281 291 EXPORT_SYMBOL_GPL(xenbus_dev_remove); 282 - 283 - void xenbus_dev_shutdown(struct device *_dev) 284 - { 285 - struct xenbus_device *dev = to_xenbus_device(_dev); 286 - unsigned long timeout = 5*HZ; 287 - 288 - DPRINTK("%s", dev->nodename); 289 - 290 - get_device(&dev->dev); 291 - if (dev->state != XenbusStateConnected) { 292 - pr_info("%s: %s: %s != Connected, skipping\n", 293 - __func__, dev->nodename, xenbus_strstate(dev->state)); 294 - goto out; 295 - } 296 - xenbus_switch_state(dev, XenbusStateClosing); 297 - timeout = wait_for_completion_timeout(&dev->down, timeout); 298 - if (!timeout) 299 - pr_info("%s: %s timeout closing device\n", 300 - __func__, dev->nodename); 301 - out: 302 - put_device(&dev->dev); 303 - } 304 - EXPORT_SYMBOL_GPL(xenbus_dev_shutdown); 305 292 306 293 int xenbus_register_driver_common(struct xenbus_driver *drv, 307 294 struct xen_bus_type *bus,
-1
drivers/xen/xenbus/xenbus_probe_backend.c
··· 198 198 .uevent = xenbus_uevent_backend, 199 199 .probe = xenbus_dev_probe, 200 200 .remove = xenbus_dev_remove, 201 - .shutdown = xenbus_dev_shutdown, 202 201 .dev_groups = xenbus_dev_groups, 203 202 }, 204 203 };
+23 -1
drivers/xen/xenbus/xenbus_probe_frontend.c
··· 126 126 return xenbus_dev_probe(dev); 127 127 } 128 128 129 + static void xenbus_frontend_dev_shutdown(struct device *_dev) 130 + { 131 + struct xenbus_device *dev = to_xenbus_device(_dev); 132 + unsigned long timeout = 5*HZ; 133 + 134 + DPRINTK("%s", dev->nodename); 135 + 136 + get_device(&dev->dev); 137 + if (dev->state != XenbusStateConnected) { 138 + pr_info("%s: %s: %s != Connected, skipping\n", 139 + __func__, dev->nodename, xenbus_strstate(dev->state)); 140 + goto out; 141 + } 142 + xenbus_switch_state(dev, XenbusStateClosing); 143 + timeout = wait_for_completion_timeout(&dev->down, timeout); 144 + if (!timeout) 145 + pr_info("%s: %s timeout closing device\n", 146 + __func__, dev->nodename); 147 + out: 148 + put_device(&dev->dev); 149 + } 150 + 129 151 static const struct dev_pm_ops xenbus_pm_ops = { 130 152 .suspend = xenbus_dev_suspend, 131 153 .resume = xenbus_frontend_dev_resume, ··· 168 146 .uevent = xenbus_uevent_frontend, 169 147 .probe = xenbus_frontend_dev_probe, 170 148 .remove = xenbus_dev_remove, 171 - .shutdown = xenbus_dev_shutdown, 149 + .shutdown = xenbus_frontend_dev_shutdown, 172 150 .dev_groups = xenbus_dev_groups, 173 151 174 152 .pm = &xenbus_pm_ops,
+9 -20
include/xen/interface/io/ring.h
··· 125 125 memset((_s)->pad, 0, sizeof((_s)->pad)); \ 126 126 } while(0) 127 127 128 - #define FRONT_RING_INIT(_r, _s, __size) do { \ 129 - (_r)->req_prod_pvt = 0; \ 130 - (_r)->rsp_cons = 0; \ 128 + #define FRONT_RING_ATTACH(_r, _s, _i, __size) do { \ 129 + (_r)->req_prod_pvt = (_i); \ 130 + (_r)->rsp_cons = (_i); \ 131 131 (_r)->nr_ents = __RING_SIZE(_s, __size); \ 132 132 (_r)->sring = (_s); \ 133 133 } while (0) 134 134 135 - #define BACK_RING_INIT(_r, _s, __size) do { \ 136 - (_r)->rsp_prod_pvt = 0; \ 137 - (_r)->req_cons = 0; \ 135 + #define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __size) 136 + 137 + #define BACK_RING_ATTACH(_r, _s, _i, __size) do { \ 138 + (_r)->rsp_prod_pvt = (_i); \ 139 + (_r)->req_cons = (_i); \ 138 140 (_r)->nr_ents = __RING_SIZE(_s, __size); \ 139 141 (_r)->sring = (_s); \ 140 142 } while (0) 141 143 142 - /* Initialize to existing shared indexes -- for recovery */ 143 - #define FRONT_RING_ATTACH(_r, _s, __size) do { \ 144 - (_r)->sring = (_s); \ 145 - (_r)->req_prod_pvt = (_s)->req_prod; \ 146 - (_r)->rsp_cons = (_s)->rsp_prod; \ 147 - (_r)->nr_ents = __RING_SIZE(_s, __size); \ 148 - } while (0) 149 - 150 - #define BACK_RING_ATTACH(_r, _s, __size) do { \ 151 - (_r)->sring = (_s); \ 152 - (_r)->rsp_prod_pvt = (_s)->rsp_prod; \ 153 - (_r)->req_cons = (_s)->req_prod; \ 154 - (_r)->nr_ents = __RING_SIZE(_s, __size); \ 155 - } while (0) 144 + #define BACK_RING_INIT(_r, _s, __size) BACK_RING_ATTACH(_r, _s, 0, __size) 156 145 157 146 /* How big is this ring? */ 158 147 #define RING_SIZE(_r) \
+1
include/xen/xenbus.h
··· 93 93 struct xenbus_driver { 94 94 const char *name; /* defaults to ids[0].devicetype */ 95 95 const struct xenbus_device_id *ids; 96 + bool allow_rebind; /* avoid setting xenstore closed during remove */ 96 97 int (*probe)(struct xenbus_device *dev, 97 98 const struct xenbus_device_id *id); 98 99 void (*otherend_changed)(struct xenbus_device *dev,