* [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard
2014-02-10 16:50 [PATCH 0/3] xen-block: changes for discard support Olaf Hering
@ 2014-02-10 16:50 ` Olaf Hering
2014-02-10 16:50 ` [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment Olaf Hering
2014-02-10 16:50 ` [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack Olaf Hering
2 siblings, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2014-02-10 16:50 UTC (permalink / raw)
To: konrad.wilk
Cc: xen-devel, linux-kernel, david.vrabel, boris.ostrovsky, Olaf Hering
In its initial implementation a check for "type" was added, but only phy
and file are handled. This breaks advertised discard support for other
type values such as qdisk.
Fix and simplify this function: If the backend advertises discard
support it is supposed to implement it properly, so enable
feature_discard unconditionally. If the backend advertises the need for
a certain granularity and alignment then propagate both properties to
the blocklayer. The discard-secure property is a boolean, update the code
to reflect that.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/block/xen-blkfront.c | 40 ++++++++++++++--------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 8dcfb54..4d8ddea 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -1635,36 +1635,24 @@ blkfront_closing(struct blkfront_info *info)
static void blkfront_setup_discard(struct blkfront_info *info)
{
int err;
- char *type;
unsigned int discard_granularity;
unsigned int discard_alignment;
unsigned int discard_secure;
- type = xenbus_read(XBT_NIL, info->xbdev->otherend, "type", NULL);
- if (IS_ERR(type))
- return;
-
- info->feature_secdiscard = 0;
- if (strncmp(type, "phy", 3) == 0) {
- err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
- "discard-granularity", "%u", &discard_granularity,
- "discard-alignment", "%u", &discard_alignment,
- NULL);
- if (!err) {
- info->feature_discard = 1;
- info->discard_granularity = discard_granularity;
- info->discard_alignment = discard_alignment;
- }
- err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
- "discard-secure", "%d", &discard_secure,
- NULL);
- if (!err)
- info->feature_secdiscard = discard_secure;
-
- } else if (strncmp(type, "file", 4) == 0)
- info->feature_discard = 1;
-
- kfree(type);
+ info->feature_discard = 1;
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+ "discard-granularity", "%u", &discard_granularity,
+ "discard-alignment", "%u", &discard_alignment,
+ NULL);
+ if (!err) {
+ info->discard_granularity = discard_granularity;
+ info->discard_alignment = discard_alignment;
+ }
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+ "discard-secure", "%d", &discard_secure,
+ NULL);
+ if (!err)
+ info->feature_secdiscard = !!discard_secure;
}
static int blkfront_setup_indirect(struct blkfront_info *info)
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack
2014-02-10 16:50 [PATCH 0/3] xen-block: changes for discard support Olaf Hering
2014-02-10 16:50 ` [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard Olaf Hering
2014-02-10 16:50 ` [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment Olaf Hering
@ 2014-02-10 16:50 ` Olaf Hering
2 siblings, 0 replies; 4+ messages in thread
From: Olaf Hering @ 2014-02-10 16:50 UTC (permalink / raw)
To: konrad.wilk
Cc: xen-devel, linux-kernel, david.vrabel, boris.ostrovsky, Olaf Hering
Newer toolstacks may provide a boolean property "discard-enable" in the
backend node. Its purpose is to disable discard for file backed storage
to avoid fragmentation. Recognize this setting also for physical
storage. If that property exists and is false, do not advertise
"feature-discard" to the frontend.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
drivers/block/xen-blkback/xenbus.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index c2014a0..83125e2 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -467,10 +467,15 @@ static void xen_blkbk_discard(struct xenbus_transaction xbt, struct backend_info
struct xenbus_device *dev = be->dev;
struct xen_blkif *blkif = be->blkif;
int err;
- int state = 0;
+ int state = 0, discard_enable;
struct block_device *bdev = be->blkif->vbd.bdev;
struct request_queue *q = bdev_get_queue(bdev);
+ err = xenbus_scanf(XBT_NIL, dev->nodename, "discard-enable", "%d",
+ &discard_enable);
+ if (err == 1 && !discard_enable)
+ return;
+
if (blk_queue_discard(q)) {
err = xenbus_printf(xbt, dev->nodename,
"discard-granularity", "%u",
^ permalink raw reply [flat|nested] 4+ messages in thread