Merge branch 'for-2.6.36' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.36' of git://git.kernel.dk/linux-2.6-block: (149 commits) block: make sure that REQ_* types are seen even with CONFIG_BLOCK=n xen-blkfront: fix missing out label blkdev: fix blkdev_issue_zeroout return value block: update request stacking methods to support discards block: fix missing export of blk_types.h writeback: fix bad _bh spinlock nesting drbd: revert "delay probes", feature is being re-implemented differently drbd: Initialize all members of sync_conf to their defaults [Bugz 315] drbd: Disable delay probes for the upcomming release writeback: cleanup bdi_register writeback: add new tracepoints writeback: remove unnecessary init_timer call writeback: optimize periodic bdi thread wakeups writeback: prevent unnecessary bdi threads wakeups writeback: move bdi threads exiting logic to the forker thread writeback: restructure bdi forker loop a little writeback: move last_active to bdi writeback: do not remove bdi from bdi_list writeback: simplify bdi code a little writeback: do not lose wake-ups in bdi threads ... Fixed up pretty trivial conflicts in drivers/block/virtio_blk.c and drivers/scsi/scsi_error.c as per Jens.
This commit is contained in:
@@ -133,6 +133,64 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);
|
||||
|
||||
static void xenbus_switch_fatal(struct xenbus_device *, int, int,
|
||||
const char *, ...);
|
||||
|
||||
static int
|
||||
__xenbus_switch_state(struct xenbus_device *dev,
|
||||
enum xenbus_state state, int depth)
|
||||
{
|
||||
/* We check whether the state is currently set to the given value, and
|
||||
if not, then the state is set. We don't want to unconditionally
|
||||
write the given state, because we don't want to fire watches
|
||||
unnecessarily. Furthermore, if the node has gone, we don't write
|
||||
to it, as the device will be tearing down, and we don't want to
|
||||
resurrect that directory.
|
||||
|
||||
Note that, because of this cached value of our state, this
|
||||
function will not take a caller's Xenstore transaction
|
||||
(something it was trying to in the past) because dev->state
|
||||
would not get reset if the transaction was aborted.
|
||||
*/
|
||||
|
||||
struct xenbus_transaction xbt;
|
||||
int current_state;
|
||||
int err, abort;
|
||||
|
||||
if (state == dev->state)
|
||||
return 0;
|
||||
|
||||
again:
|
||||
abort = 1;
|
||||
|
||||
err = xenbus_transaction_start(&xbt);
|
||||
if (err) {
|
||||
xenbus_switch_fatal(dev, depth, err, "starting transaction");
|
||||
return 0;
|
||||
}
|
||||
|
||||
err = xenbus_scanf(xbt, dev->nodename, "state", "%d", ¤t_state);
|
||||
if (err != 1)
|
||||
goto abort;
|
||||
|
||||
err = xenbus_printf(xbt, dev->nodename, "state", "%d", state);
|
||||
if (err) {
|
||||
xenbus_switch_fatal(dev, depth, err, "writing new state");
|
||||
goto abort;
|
||||
}
|
||||
|
||||
abort = 0;
|
||||
abort:
|
||||
err = xenbus_transaction_end(xbt, abort);
|
||||
if (err) {
|
||||
if (err == -EAGAIN && !abort)
|
||||
goto again;
|
||||
xenbus_switch_fatal(dev, depth, err, "ending transaction");
|
||||
} else
|
||||
dev->state = state;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xenbus_switch_state
|
||||
@@ -145,42 +203,9 @@ EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);
|
||||
*/
|
||||
int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state state)
|
||||
{
|
||||
/* We check whether the state is currently set to the given value, and
|
||||
if not, then the state is set. We don't want to unconditionally
|
||||
write the given state, because we don't want to fire watches
|
||||
unnecessarily. Furthermore, if the node has gone, we don't write
|
||||
to it, as the device will be tearing down, and we don't want to
|
||||
resurrect that directory.
|
||||
|
||||
Note that, because of this cached value of our state, this function
|
||||
will not work inside a Xenstore transaction (something it was
|
||||
trying to in the past) because dev->state would not get reset if
|
||||
the transaction was aborted.
|
||||
|
||||
*/
|
||||
|
||||
int current_state;
|
||||
int err;
|
||||
|
||||
if (state == dev->state)
|
||||
return 0;
|
||||
|
||||
err = xenbus_scanf(XBT_NIL, dev->nodename, "state", "%d",
|
||||
¤t_state);
|
||||
if (err != 1)
|
||||
return 0;
|
||||
|
||||
err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%d", state);
|
||||
if (err) {
|
||||
if (state != XenbusStateClosing) /* Avoid looping */
|
||||
xenbus_dev_fatal(dev, err, "writing new state");
|
||||
return err;
|
||||
}
|
||||
|
||||
dev->state = state;
|
||||
|
||||
return 0;
|
||||
return __xenbus_switch_state(dev, state, 0);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(xenbus_switch_state);
|
||||
|
||||
int xenbus_frontend_closed(struct xenbus_device *dev)
|
||||
@@ -283,6 +308,23 @@ void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(xenbus_dev_fatal);
|
||||
|
||||
/**
|
||||
* Equivalent to xenbus_dev_fatal(dev, err, fmt, args), but helps
|
||||
* avoiding recursion within xenbus_switch_state.
|
||||
*/
|
||||
static void xenbus_switch_fatal(struct xenbus_device *dev, int depth, int err,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
xenbus_va_dev_error(dev, err, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!depth)
|
||||
__xenbus_switch_state(dev, XenbusStateClosing, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* xenbus_grant_ring
|
||||
* @dev: xenbus device
|
||||
|
Reference in New Issue
Block a user