提交 3389bb8b 编写于 作者: K Konrad Rzeszutek Wilk

xen/blkback: Make optional features be really optional.

They were using the xenbus_dev_fatal() function which would
change the state of the connection immediately. Which is not
what we want when we advertise optional features.

So make 'feature-discard','feature-barrier','feature-flush-cache'
optional.
Suggested-by: NJan Beulich <JBeulich@suse.com>
[v1: Made the discard function void and static]
Signed-off-by: NKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
上级 4dae7670
...@@ -381,12 +381,12 @@ int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt, ...@@ -381,12 +381,12 @@ int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt,
err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache", err = xenbus_printf(xbt, dev->nodename, "feature-flush-cache",
"%d", state); "%d", state);
if (err) if (err)
xenbus_dev_fatal(dev, err, "writing feature-flush-cache"); dev_warn(&dev->dev, "writing feature-flush-cache (%d)", err);
return err; return err;
} }
int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be) static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
{ {
struct xenbus_device *dev = be->dev; struct xenbus_device *dev = be->dev;
struct xen_blkif *blkif = be->blkif; struct xen_blkif *blkif = be->blkif;
...@@ -400,17 +400,15 @@ int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be) ...@@ -400,17 +400,15 @@ int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
"discard-granularity", "%u", "discard-granularity", "%u",
q->limits.discard_granularity); q->limits.discard_granularity);
if (err) { if (err) {
xenbus_dev_fatal(dev, err, dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
"writing discard-granularity"); return;
goto out;
} }
err = xenbus_printf(xbt, dev->nodename, err = xenbus_printf(xbt, dev->nodename,
"discard-alignment", "%u", "discard-alignment", "%u",
q->limits.discard_alignment); q->limits.discard_alignment);
if (err) { if (err) {
xenbus_dev_fatal(dev, err, dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
"writing discard-alignment"); return;
goto out;
} }
state = 1; state = 1;
/* Optional. */ /* Optional. */
...@@ -418,17 +416,14 @@ int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be) ...@@ -418,17 +416,14 @@ int xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info *be)
"discard-secure", "%d", "discard-secure", "%d",
blkif->vbd.discard_secure); blkif->vbd.discard_secure);
if (err) { if (err) {
xenbus_dev_fatal(dev, err, dev_warn(dev-dev, "writing discard-secure (%d)", err);
"writting discard-secure"); return;
goto out;
} }
} }
err = xenbus_printf(xbt, dev->nodename, "feature-discard", err = xenbus_printf(xbt, dev->nodename, "feature-discard",
"%d", state); "%d", state);
if (err) if (err)
xenbus_dev_fatal(dev, err, "writing feature-discard"); dev_warn(&dev->dev, "writing feature-discard (%d)", err);
out:
return err;
} }
int xen_blkbk_barrier(struct xenbus_transaction xbt, int xen_blkbk_barrier(struct xenbus_transaction xbt,
struct backend_info *be, int state) struct backend_info *be, int state)
...@@ -439,7 +434,7 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt, ...@@ -439,7 +434,7 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt,
err = xenbus_printf(xbt, dev->nodename, "feature-barrier", err = xenbus_printf(xbt, dev->nodename, "feature-barrier",
"%d", state); "%d", state);
if (err) if (err)
xenbus_dev_fatal(dev, err, "writing feature-barrier"); dev_warn(&dev->dev, "writing feature-barrier (%d)", err);
return err; return err;
} }
...@@ -671,14 +666,12 @@ static void connect(struct backend_info *be) ...@@ -671,14 +666,12 @@ static void connect(struct backend_info *be)
return; return;
} }
err = xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support); /* If we can't advertise it is OK. */
if (err) xen_blkbk_flush_diskcache(xbt, be, be->blkif->vbd.flush_support);
goto abort;
err = xen_blkbk_discard(xbt, be); xen_blkbk_discard(xbt, be);
/* If we can't advertise it is OK. */ xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
err = xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu", err = xenbus_printf(xbt, dev->nodename, "sectors", "%llu",
(unsigned long long)vbd_sz(&be->blkif->vbd)); (unsigned long long)vbd_sz(&be->blkif->vbd));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册