提交 6674fb79 编写于 作者: J Jens Axboe

Merge branch 'stable/for-jens-3.4-bugfixes' of...

Merge branch 'stable/for-jens-3.4-bugfixes' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen into for-3.4/drivers

Konrad writes:

I've two small fixes for the xen-blkback - and I think one more will show up
eventually (a partial revert), but not sure when. So in the spirit of keeping
the patches flowing, please git pull the following branch.
...@@ -398,21 +398,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif, ...@@ -398,21 +398,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
int err = 0; int err = 0;
int status = BLKIF_RSP_OKAY; int status = BLKIF_RSP_OKAY;
struct block_device *bdev = blkif->vbd.bdev; struct block_device *bdev = blkif->vbd.bdev;
unsigned long secure;
blkif->st_ds_req++; blkif->st_ds_req++;
xen_blkif_get(blkif); xen_blkif_get(blkif);
if (blkif->blk_backend_type == BLKIF_BACKEND_PHY || secure = (blkif->vbd.discard_secure &&
blkif->blk_backend_type == BLKIF_BACKEND_FILE) { (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
unsigned long secure = (blkif->vbd.discard_secure && BLKDEV_DISCARD_SECURE : 0;
(req->u.discard.flag & BLKIF_DISCARD_SECURE)) ?
BLKDEV_DISCARD_SECURE : 0; err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
err = blkdev_issue_discard(bdev, req->u.discard.nr_sectors,
req->u.discard.sector_number, GFP_KERNEL, secure);
req->u.discard.nr_sectors,
GFP_KERNEL, secure);
} else
err = -EOPNOTSUPP;
if (err == -EOPNOTSUPP) { if (err == -EOPNOTSUPP) {
pr_debug(DRV_PFX "discard op failed, not supported\n"); pr_debug(DRV_PFX "discard op failed, not supported\n");
......
...@@ -146,11 +146,6 @@ enum blkif_protocol { ...@@ -146,11 +146,6 @@ enum blkif_protocol {
BLKIF_PROTOCOL_X86_64 = 3, BLKIF_PROTOCOL_X86_64 = 3,
}; };
enum blkif_backend_type {
BLKIF_BACKEND_PHY = 1,
BLKIF_BACKEND_FILE = 2,
};
struct xen_vbd { struct xen_vbd {
/* What the domain refers to this vbd as. */ /* What the domain refers to this vbd as. */
blkif_vdev_t handle; blkif_vdev_t handle;
...@@ -177,7 +172,6 @@ struct xen_blkif { ...@@ -177,7 +172,6 @@ struct xen_blkif {
unsigned int irq; unsigned int irq;
/* Comms information. */ /* Comms information. */
enum blkif_protocol blk_protocol; enum blkif_protocol blk_protocol;
enum blkif_backend_type blk_backend_type;
union blkif_back_rings blk_rings; union blkif_back_rings blk_rings;
void *blk_ring; void *blk_ring;
/* The VBD attached to this interface. */ /* The VBD attached to this interface. */
......
...@@ -381,72 +381,49 @@ int xen_blkbk_flush_diskcache(struct xenbus_transaction xbt, ...@@ -381,72 +381,49 @@ 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;
char *type;
int err; int err;
int state = 0; int state = 0;
struct block_device *bdev = be->blkif->vbd.bdev;
struct request_queue *q = bdev_get_queue(bdev);
type = xenbus_read(XBT_NIL, dev->nodename, "type", NULL); if (blk_queue_discard(q)) {
if (!IS_ERR(type)) { err = xenbus_printf(xbt, dev->nodename,
if (strncmp(type, "file", 4) == 0) { "discard-granularity", "%u",
state = 1; q->limits.discard_granularity);
blkif->blk_backend_type = BLKIF_BACKEND_FILE; if (err) {
dev_warn(&dev->dev, "writing discard-granularity (%d)", err);
return;
} }
if (strncmp(type, "phy", 3) == 0) { err = xenbus_printf(xbt, dev->nodename,
struct block_device *bdev = be->blkif->vbd.bdev; "discard-alignment", "%u",
struct request_queue *q = bdev_get_queue(bdev); q->limits.discard_alignment);
if (blk_queue_discard(q)) { if (err) {
err = xenbus_printf(xbt, dev->nodename, dev_warn(&dev->dev, "writing discard-alignment (%d)", err);
"discard-granularity", "%u", return;
q->limits.discard_granularity); }
if (err) { state = 1;
xenbus_dev_fatal(dev, err, /* Optional. */
"writing discard-granularity"); err = xenbus_printf(xbt, dev->nodename,
goto kfree; "discard-secure", "%d",
} blkif->vbd.discard_secure);
err = xenbus_printf(xbt, dev->nodename, if (err) {
"discard-alignment", "%u", dev_warn(dev-dev, "writing discard-secure (%d)", err);
q->limits.discard_alignment); return;
if (err) {
xenbus_dev_fatal(dev, err,
"writing discard-alignment");
goto kfree;
}
state = 1;
blkif->blk_backend_type = BLKIF_BACKEND_PHY;
}
/* Optional. */
err = xenbus_printf(xbt, dev->nodename,
"discard-secure", "%d",
blkif->vbd.discard_secure);
if (err) {
xenbus_dev_fatal(dev, err,
"writting discard-secure");
goto kfree;
}
} }
} else {
err = PTR_ERR(type);
xenbus_dev_fatal(dev, err, "reading type");
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);
kfree:
kfree(type);
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)
...@@ -457,7 +434,7 @@ int xen_blkbk_barrier(struct xenbus_transaction xbt, ...@@ -457,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;
} }
...@@ -689,14 +666,12 @@ static void connect(struct backend_info *be) ...@@ -689,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.
先完成此消息的编辑!
想要评论请 注册