public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 0/3] xen-block: changes for discard support
@ 2014-05-21 14:32 Olaf Hering
  2014-05-21 14:32 ` [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard Olaf Hering
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Olaf Hering @ 2014-05-21 14:32 UTC (permalink / raw)
  To: konrad.wilk
  Cc: xen-devel, linux-kernel, david.vrabel, boris.ostrovsky,
	Olaf Hering

Fix blkfront to handle all sorts of backends.

Also let blkback recognize a xenstore property to disable discard for a
given device. This part requires libxl changes ("discard-enable"):
http://lists.xenproject.org/archives/html/xen-devel/2014-05/msg02291.html

(This is a resend, this series was already sent 2014-02-10.)

Olaf Hering (3):
  xen-blkfront: remove type check from blkfront_setup_discard
  xen blkif.h: fix comment typo in discard-alignment
  xen/blkback: disable discard feature if requested by toolstack

 drivers/block/xen-blkback/xenbus.c |  7 ++++++-
 drivers/block/xen-blkfront.c       | 40 +++++++++++++-------------------------
 include/xen/interface/io/blkif.h   |  2 +-
 3 files changed, 21 insertions(+), 28 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard
  2014-05-21 14:32 [PATCH RESEND 0/3] xen-block: changes for discard support Olaf Hering
@ 2014-05-21 14:32 ` Olaf Hering
  2014-05-21 14:32 ` [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment Olaf Hering
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2014-05-21 14:32 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 efe1b47..25c11ad 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 related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment
  2014-05-21 14:32 [PATCH RESEND 0/3] xen-block: changes for discard support Olaf Hering
  2014-05-21 14:32 ` [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard Olaf Hering
@ 2014-05-21 14:32 ` Olaf Hering
  2014-05-21 14:32 ` [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack Olaf Hering
  2014-05-23 17:54 ` [PATCH RESEND 0/3] xen-block: changes for discard support Konrad Rzeszutek Wilk
  3 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2014-05-21 14:32 UTC (permalink / raw)
  To: konrad.wilk
  Cc: xen-devel, linux-kernel, david.vrabel, boris.ostrovsky,
	Olaf Hering

Add the missing 'n' to discard-alignment

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 include/xen/interface/io/blkif.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/xen/interface/io/blkif.h b/include/xen/interface/io/blkif.h
index 32ec05a..c33e1c4 100644
--- a/include/xen/interface/io/blkif.h
+++ b/include/xen/interface/io/blkif.h
@@ -86,7 +86,7 @@ typedef uint64_t blkif_sector_t;
  *     Interface%20manuals/100293068c.pdf
  * The backend can optionally provide three extra XenBus attributes to
  * further optimize the discard functionality:
- * 'discard-aligment' - Devices that support discard functionality may
+ * 'discard-alignment' - Devices that support discard functionality may
  * internally allocate space in units that are bigger than the exported
  * logical block size. The discard-alignment parameter indicates how many bytes
  * the beginning of the partition is offset from the internal allocation unit's

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack
  2014-05-21 14:32 [PATCH RESEND 0/3] xen-block: changes for discard support Olaf Hering
  2014-05-21 14:32 ` [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard Olaf Hering
  2014-05-21 14:32 ` [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment Olaf Hering
@ 2014-05-21 14:32 ` Olaf Hering
  2014-05-23 17:54 ` [PATCH RESEND 0/3] xen-block: changes for discard support Konrad Rzeszutek Wilk
  3 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2014-05-21 14:32 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 9a547e6..a71ecf5 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -481,10 +481,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 related	[flat|nested] 5+ messages in thread

* Re: [PATCH RESEND 0/3] xen-block: changes for discard support
  2014-05-21 14:32 [PATCH RESEND 0/3] xen-block: changes for discard support Olaf Hering
                   ` (2 preceding siblings ...)
  2014-05-21 14:32 ` [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack Olaf Hering
@ 2014-05-23 17:54 ` Konrad Rzeszutek Wilk
  3 siblings, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2014-05-23 17:54 UTC (permalink / raw)
  To: Olaf Hering; +Cc: xen-devel, linux-kernel, david.vrabel, boris.ostrovsky

On Wed, May 21, 2014 at 04:32:39PM +0200, Olaf Hering wrote:
> Fix blkfront to handle all sorts of backends.
> 
> Also let blkback recognize a xenstore property to disable discard for a
> given device. This part requires libxl changes ("discard-enable"):
> http://lists.xenproject.org/archives/html/xen-devel/2014-05/msg02291.html
> 
> (This is a resend, this series was already sent 2014-02-10.)

Applied to 'devel/for-jens-3.16'

Thank you for reposting!
> 
> Olaf Hering (3):
>   xen-blkfront: remove type check from blkfront_setup_discard
>   xen blkif.h: fix comment typo in discard-alignment
>   xen/blkback: disable discard feature if requested by toolstack
> 
>  drivers/block/xen-blkback/xenbus.c |  7 ++++++-
>  drivers/block/xen-blkfront.c       | 40 +++++++++++++-------------------------
>  include/xen/interface/io/blkif.h   |  2 +-
>  3 files changed, 21 insertions(+), 28 deletions(-)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-23 17:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 14:32 [PATCH RESEND 0/3] xen-block: changes for discard support Olaf Hering
2014-05-21 14:32 ` [PATCH 1/3] xen-blkfront: remove type check from blkfront_setup_discard Olaf Hering
2014-05-21 14:32 ` [PATCH 2/3] xen blkif.h: fix comment typo in discard-alignment Olaf Hering
2014-05-21 14:32 ` [PATCH 3/3] xen/blkback: disable discard feature if requested by toolstack Olaf Hering
2014-05-23 17:54 ` [PATCH RESEND 0/3] xen-block: changes for discard support Konrad Rzeszutek Wilk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox