mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
Move non-transactional and non-idempotent code out of
xenstore transaction retry loops in our device drivers. Otherwise things get very smelly if a transaction fails and is retried. Signed-off-by: Keir Fraser <keir@xensource.com>
This commit is contained in:
1 parent
45dc6ad80a
commit
68fd7614db
5 files changed
+74
-77
No files matched your search
@@ -80,6 +80,15 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Map the shared frame, irq etc. */
|
||||
err = blkif_map(be->blkif, ring_ref, evtchn);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u",
|
||||
ring_ref, evtchn);
|
||||
return;
|
||||
}
|
||||
/* XXX From here on should 'blkif_unmap' on error. */
|
||||
|
||||
again:
|
||||
/* Supply the information about the device the frontend needs */
|
||||
err = xenbus_transaction_start();
|
||||
@@ -112,14 +121,6 @@ again:
|
||||
goto abort;
|
||||
}
|
||||
|
||||
/* Map the shared frame, irq etc. */
|
||||
err = blkif_map(be->blkif, ring_ref, evtchn);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u",
|
||||
ring_ref, evtchn);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
err = xenbus_transaction_end(0);
|
||||
if (err == -EAGAIN)
|
||||
goto again;
|
||||
|
||||
@@ -591,17 +591,6 @@ again:
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
backend = NULL;
|
||||
|
||||
info->watch.node = info->backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
err = xenbus_transaction_end(0);
|
||||
if (err) {
|
||||
if (err == -EAGAIN)
|
||||
@@ -610,10 +599,17 @@ again:
|
||||
goto destroy_blkring;
|
||||
}
|
||||
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
info->watch.node = backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto destroy_blkring;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
|
||||
return 0;
|
||||
|
||||
abort_transaction:
|
||||
xenbus_transaction_end(1);
|
||||
@@ -621,7 +617,10 @@ again:
|
||||
xenbus_dev_error(dev, err, "%s", message);
|
||||
destroy_blkring:
|
||||
blkif_free(info);
|
||||
goto out;
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Setup supplies the backend dir, virtual device.
|
||||
|
||||
@@ -1148,17 +1148,6 @@ again:
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
backend = NULL;
|
||||
|
||||
info->watch.node = info->backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
err = xenbus_transaction_end(0);
|
||||
if (err) {
|
||||
if (err == -EAGAIN)
|
||||
@@ -1167,12 +1156,19 @@ again:
|
||||
goto destroy_ring;
|
||||
}
|
||||
|
||||
info->watch.node = backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto destroy_ring;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
|
||||
netif_state = NETIF_STATE_CONNECTED;
|
||||
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
return 0;
|
||||
|
||||
abort_transaction:
|
||||
xenbus_transaction_end(1);
|
||||
@@ -1180,7 +1176,10 @@ again:
|
||||
xenbus_dev_error(dev, err, "%s", message);
|
||||
destroy_ring:
|
||||
shutdown_device(info);
|
||||
goto out;
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Setup supplies the backend dir, virtual device.
|
||||
|
||||
@@ -88,6 +88,26 @@ static void frontend_changed(struct xenbus_watch *watch, const char *node)
|
||||
return;
|
||||
}
|
||||
|
||||
err = tpmif_map(be->tpmif, ringref, evtchn);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err,
|
||||
"mapping shared-frame %lu port %u",
|
||||
ringref, evtchn);
|
||||
return;
|
||||
}
|
||||
|
||||
err = tpmif_vtpm_open(be->tpmif,
|
||||
be->frontend_id,
|
||||
be->instance);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err,
|
||||
"queueing vtpm open packet");
|
||||
/*
|
||||
* Should close down this device and notify FE
|
||||
* about closure.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tell the front-end that we are ready to go -
|
||||
@@ -107,27 +127,6 @@ again:
|
||||
goto abort;
|
||||
}
|
||||
|
||||
err = tpmif_map(be->tpmif, ringref, evtchn);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err,
|
||||
"mapping shared-frame %lu port %u",
|
||||
ringref, evtchn);
|
||||
goto abort;
|
||||
}
|
||||
|
||||
err = tpmif_vtpm_open(be->tpmif,
|
||||
be->frontend_id,
|
||||
be->instance);
|
||||
if (err) {
|
||||
xenbus_dev_error(be->dev, err,
|
||||
"queueing vtpm open packet");
|
||||
/*
|
||||
* Should close down this device and notify FE
|
||||
* about closure.
|
||||
*/
|
||||
goto abort;
|
||||
}
|
||||
|
||||
err = xenbus_transaction_end(0);
|
||||
if (err == -EAGAIN)
|
||||
goto again;
|
||||
|
||||
@@ -352,17 +352,6 @@ again:
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
backend = NULL;
|
||||
|
||||
info->watch.node = info->backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto abort_transaction;
|
||||
}
|
||||
|
||||
err = xenbus_transaction_end(0);
|
||||
if (err == -EAGAIN)
|
||||
goto again;
|
||||
@@ -371,10 +360,17 @@ again:
|
||||
goto destroy_tpmring;
|
||||
}
|
||||
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
info->watch.node = backend;
|
||||
info->watch.callback = watch_for_status;
|
||||
err = register_xenbus_watch(&info->watch);
|
||||
if (err) {
|
||||
message = "registering watch on backend";
|
||||
goto destroy_tpmring;
|
||||
}
|
||||
|
||||
info->backend = backend;
|
||||
|
||||
return 0;
|
||||
|
||||
abort_transaction:
|
||||
xenbus_transaction_end(1);
|
||||
@@ -382,7 +378,10 @@ abort_transaction:
|
||||
xenbus_dev_error(dev, err, "%s", message);
|
||||
destroy_tpmring:
|
||||
destroy_tpmring(info, &my_private);
|
||||
goto out;
|
||||
out:
|
||||
if (backend)
|
||||
kfree(backend);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||