direct-io.hg
changeset 7058:70b6e60df750
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>
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>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Mon Sep 26 19:13:57 2005 +0100 (2005-09-26) |
parents | 8c2aa0878927 |
children | 9ff1bea68d51 |
files | linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Sep 26 18:49:21 2005 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Sep 26 19:13:57 2005 +0100 1.3 @@ -80,6 +80,15 @@ static void frontend_changed(struct xenb 1.4 return; 1.5 } 1.6 1.7 + /* Map the shared frame, irq etc. */ 1.8 + err = blkif_map(be->blkif, ring_ref, evtchn); 1.9 + if (err) { 1.10 + xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u", 1.11 + ring_ref, evtchn); 1.12 + return; 1.13 + } 1.14 + /* XXX From here on should 'blkif_unmap' on error. */ 1.15 + 1.16 again: 1.17 /* Supply the information about the device the frontend needs */ 1.18 err = xenbus_transaction_start(); 1.19 @@ -112,14 +121,6 @@ again: 1.20 goto abort; 1.21 } 1.22 1.23 - /* Map the shared frame, irq etc. */ 1.24 - err = blkif_map(be->blkif, ring_ref, evtchn); 1.25 - if (err) { 1.26 - xenbus_dev_error(be->dev, err, "mapping ring-ref %lu port %u", 1.27 - ring_ref, evtchn); 1.28 - goto abort; 1.29 - } 1.30 - 1.31 err = xenbus_transaction_end(0); 1.32 if (err == -EAGAIN) 1.33 goto again;
2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon Sep 26 18:49:21 2005 +0100 2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c Mon Sep 26 19:13:57 2005 +0100 2.3 @@ -591,17 +591,6 @@ again: 2.4 goto abort_transaction; 2.5 } 2.6 2.7 - info->backend = backend; 2.8 - backend = NULL; 2.9 - 2.10 - info->watch.node = info->backend; 2.11 - info->watch.callback = watch_for_status; 2.12 - err = register_xenbus_watch(&info->watch); 2.13 - if (err) { 2.14 - message = "registering watch on backend"; 2.15 - goto abort_transaction; 2.16 - } 2.17 - 2.18 err = xenbus_transaction_end(0); 2.19 if (err) { 2.20 if (err == -EAGAIN) 2.21 @@ -610,10 +599,17 @@ again: 2.22 goto destroy_blkring; 2.23 } 2.24 2.25 - out: 2.26 - if (backend) 2.27 - kfree(backend); 2.28 - return err; 2.29 + info->watch.node = backend; 2.30 + info->watch.callback = watch_for_status; 2.31 + err = register_xenbus_watch(&info->watch); 2.32 + if (err) { 2.33 + message = "registering watch on backend"; 2.34 + goto destroy_blkring; 2.35 + } 2.36 + 2.37 + info->backend = backend; 2.38 + 2.39 + return 0; 2.40 2.41 abort_transaction: 2.42 xenbus_transaction_end(1); 2.43 @@ -621,7 +617,10 @@ again: 2.44 xenbus_dev_error(dev, err, "%s", message); 2.45 destroy_blkring: 2.46 blkif_free(info); 2.47 - goto out; 2.48 + out: 2.49 + if (backend) 2.50 + kfree(backend); 2.51 + return err; 2.52 } 2.53 2.54 /* Setup supplies the backend dir, virtual device.
3.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Mon Sep 26 18:49:21 2005 +0100 3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Mon Sep 26 19:13:57 2005 +0100 3.3 @@ -1148,17 +1148,6 @@ again: 3.4 goto abort_transaction; 3.5 } 3.6 3.7 - info->backend = backend; 3.8 - backend = NULL; 3.9 - 3.10 - info->watch.node = info->backend; 3.11 - info->watch.callback = watch_for_status; 3.12 - err = register_xenbus_watch(&info->watch); 3.13 - if (err) { 3.14 - message = "registering watch on backend"; 3.15 - goto abort_transaction; 3.16 - } 3.17 - 3.18 err = xenbus_transaction_end(0); 3.19 if (err) { 3.20 if (err == -EAGAIN) 3.21 @@ -1167,12 +1156,19 @@ again: 3.22 goto destroy_ring; 3.23 } 3.24 3.25 + info->watch.node = backend; 3.26 + info->watch.callback = watch_for_status; 3.27 + err = register_xenbus_watch(&info->watch); 3.28 + if (err) { 3.29 + message = "registering watch on backend"; 3.30 + goto destroy_ring; 3.31 + } 3.32 + 3.33 + info->backend = backend; 3.34 + 3.35 netif_state = NETIF_STATE_CONNECTED; 3.36 3.37 - out: 3.38 - if (backend) 3.39 - kfree(backend); 3.40 - return err; 3.41 + return 0; 3.42 3.43 abort_transaction: 3.44 xenbus_transaction_end(1); 3.45 @@ -1180,7 +1176,10 @@ again: 3.46 xenbus_dev_error(dev, err, "%s", message); 3.47 destroy_ring: 3.48 shutdown_device(info); 3.49 - goto out; 3.50 + out: 3.51 + if (backend) 3.52 + kfree(backend); 3.53 + return err; 3.54 } 3.55 3.56 /* Setup supplies the backend dir, virtual device.
4.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon Sep 26 18:49:21 2005 +0100 4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Mon Sep 26 19:13:57 2005 +0100 4.3 @@ -88,6 +88,26 @@ static void frontend_changed(struct xenb 4.4 return; 4.5 } 4.6 4.7 + err = tpmif_map(be->tpmif, ringref, evtchn); 4.8 + if (err) { 4.9 + xenbus_dev_error(be->dev, err, 4.10 + "mapping shared-frame %lu port %u", 4.11 + ringref, evtchn); 4.12 + return; 4.13 + } 4.14 + 4.15 + err = tpmif_vtpm_open(be->tpmif, 4.16 + be->frontend_id, 4.17 + be->instance); 4.18 + if (err) { 4.19 + xenbus_dev_error(be->dev, err, 4.20 + "queueing vtpm open packet"); 4.21 + /* 4.22 + * Should close down this device and notify FE 4.23 + * about closure. 4.24 + */ 4.25 + return; 4.26 + } 4.27 4.28 /* 4.29 * Tell the front-end that we are ready to go - 4.30 @@ -107,27 +127,6 @@ again: 4.31 goto abort; 4.32 } 4.33 4.34 - err = tpmif_map(be->tpmif, ringref, evtchn); 4.35 - if (err) { 4.36 - xenbus_dev_error(be->dev, err, 4.37 - "mapping shared-frame %lu port %u", 4.38 - ringref, evtchn); 4.39 - goto abort; 4.40 - } 4.41 - 4.42 - err = tpmif_vtpm_open(be->tpmif, 4.43 - be->frontend_id, 4.44 - be->instance); 4.45 - if (err) { 4.46 - xenbus_dev_error(be->dev, err, 4.47 - "queueing vtpm open packet"); 4.48 - /* 4.49 - * Should close down this device and notify FE 4.50 - * about closure. 4.51 - */ 4.52 - goto abort; 4.53 - } 4.54 - 4.55 err = xenbus_transaction_end(0); 4.56 if (err == -EAGAIN) 4.57 goto again;
5.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Mon Sep 26 18:49:21 2005 +0100 5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c Mon Sep 26 19:13:57 2005 +0100 5.3 @@ -352,17 +352,6 @@ again: 5.4 goto abort_transaction; 5.5 } 5.6 5.7 - info->backend = backend; 5.8 - backend = NULL; 5.9 - 5.10 - info->watch.node = info->backend; 5.11 - info->watch.callback = watch_for_status; 5.12 - err = register_xenbus_watch(&info->watch); 5.13 - if (err) { 5.14 - message = "registering watch on backend"; 5.15 - goto abort_transaction; 5.16 - } 5.17 - 5.18 err = xenbus_transaction_end(0); 5.19 if (err == -EAGAIN) 5.20 goto again; 5.21 @@ -371,10 +360,17 @@ again: 5.22 goto destroy_tpmring; 5.23 } 5.24 5.25 -out: 5.26 - if (backend) 5.27 - kfree(backend); 5.28 - return err; 5.29 + info->watch.node = backend; 5.30 + info->watch.callback = watch_for_status; 5.31 + err = register_xenbus_watch(&info->watch); 5.32 + if (err) { 5.33 + message = "registering watch on backend"; 5.34 + goto destroy_tpmring; 5.35 + } 5.36 + 5.37 + info->backend = backend; 5.38 + 5.39 + return 0; 5.40 5.41 abort_transaction: 5.42 xenbus_transaction_end(1); 5.43 @@ -382,7 +378,10 @@ abort_transaction: 5.44 xenbus_dev_error(dev, err, "%s", message); 5.45 destroy_tpmring: 5.46 destroy_tpmring(info, &my_private); 5.47 - goto out; 5.48 +out: 5.49 + if (backend) 5.50 + kfree(backend); 5.51 + return err; 5.52 } 5.53 5.54