Commit 1c8cad6c authored by Olaf Hering's avatar Olaf Hering Committed by Konrad Rzeszutek Wilk

xen-blkfront: remove type check from blkfront_setup_discard

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: default avatarOlaf Hering <olaf@aepfle.de>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent c9eaa447
...@@ -1635,36 +1635,24 @@ blkfront_closing(struct blkfront_info *info) ...@@ -1635,36 +1635,24 @@ blkfront_closing(struct blkfront_info *info)
static void blkfront_setup_discard(struct blkfront_info *info) static void blkfront_setup_discard(struct blkfront_info *info)
{ {
int err; int err;
char *type;
unsigned int discard_granularity; unsigned int discard_granularity;
unsigned int discard_alignment; unsigned int discard_alignment;
unsigned int discard_secure; unsigned int discard_secure;
type = xenbus_read(XBT_NIL, info->xbdev->otherend, "type", NULL); info->feature_discard = 1;
if (IS_ERR(type)) err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
return; "discard-granularity", "%u", &discard_granularity,
"discard-alignment", "%u", &discard_alignment,
info->feature_secdiscard = 0; NULL);
if (strncmp(type, "phy", 3) == 0) { if (!err) {
err = xenbus_gather(XBT_NIL, info->xbdev->otherend, info->discard_granularity = discard_granularity;
"discard-granularity", "%u", &discard_granularity, info->discard_alignment = discard_alignment;
"discard-alignment", "%u", &discard_alignment, }
NULL); err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
if (!err) { "discard-secure", "%d", &discard_secure,
info->feature_discard = 1; NULL);
info->discard_granularity = discard_granularity; if (!err)
info->discard_alignment = discard_alignment; info->feature_secdiscard = !!discard_secure;
}
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);
} }
static int blkfront_setup_indirect(struct blkfront_info *info) static int blkfront_setup_indirect(struct blkfront_info *info)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment