Skip to contentSkip to conversation

xen-blkfront: remove type check from blkfront_setup_discard

PATCH In review Olaf Hering 5 participants 25 messages Jan 13, 2014 – Jan 23, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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: remove the check for "type" as the frontend is not supposed to care about this backend detail. Expect backends to provide discard-aligment, discard-granularity and discard-secure properties because interface specification in blkif.h does not list these properties as optional.

---
 drivers/block/xen-blkfront.c | 33 +++++++++------------------------
 1 file changed, 9 insertions(+), 24 deletions(-)
drivers/block/xen-blkfront.c +9 -24
index c4a4c90..6ef63eb 100644
@@ -1634,37 +1634,22 @@ 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))
+	if (xenbus_gather(XBT_NIL, info->xbdev->otherend,
+		"discard-granularity", "%u", &discard_granularity,
+		"discard-alignment", "%u", &discard_alignment,
+		"discard-secure", "%u", &discard_secure,
+		NULL))
 		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;
+	info->discard_granularity = discard_granularity;
+	info->discard_alignment = discard_alignment;
+	info->feature_secdiscard = !!discard_secure;
 
-	kfree(type);
+	info->feature_discard = 1;
 }
 
 static int blkfront_setup_indirect(struct blkfront_info *info)
#1 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
drivers/block/xen-blkfront.c +0 -2
@@ -1634,37 +1634,22 @@ 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;

drivers/block/xen-blkfront.c blkfront_closing(struct blkfront_info *info) · line 1646

Quoted 10 lines
drivers/block/xen-blkfront.c +5 -2
 	unsigned int discard_secure;
 
-	type = xenbus_read(XBT_NIL, info->xbdev->otherend, "type", NULL);
-	if (IS_ERR(type))
+	if (xenbus_gather(XBT_NIL, info->xbdev->otherend,
+		"discard-granularity", "%u", &discard_granularity,
+		"discard-alignment", "%u", &discard_alignment,
+		"discard-secure", "%u", &discard_secure,
+		NULL))
 		return;

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Jan

#2 lore raw
In reply to Olaf Hering
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
drivers/block/xen-blkfront.c +0 -2
@@ -1634,37 +1634,22 @@ 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;

drivers/block/xen-blkfront.c blkfront_closing(struct blkfront_info *info) · line 1646

Quoted 10 lines
drivers/block/xen-blkfront.c +5 -2
 	unsigned int discard_secure;
 
-	type = xenbus_read(XBT_NIL, info->xbdev->otherend, "type", NULL);
-	if (IS_ERR(type))
+	if (xenbus_gather(XBT_NIL, info->xbdev->otherend,
+		"discard-granularity", "%u", &discard_granularity,
+		"discard-alignment", "%u", &discard_alignment,
+		"discard-secure", "%u", &discard_secure,
+		NULL))
 		return;

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Jan

#3 lore raw
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Olaf

#4 lore raw
In reply to Jan Beulich
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Olaf

#5 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

Jan

#6 lore raw
In reply to Olaf Hering
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

Jan

#7 lore raw
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

In this case my first patch is correct and should be used.

Olaf

#8 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

In this case my first patch is correct and should be used.

Olaf

#9 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

But is it true that either they are all present or they are all absent?

Ian.

#10 lore raw
In reply to Jan Beulich
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

But is it true that either they are all present or they are all absent?

Ian.

#11 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Jan

#12 lore raw
In reply to Ian Campbell
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 8 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Jan

#13 lore raw
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Thanks for clarifying.

#14 lore raw
In reply to Jan Beulich
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Thanks for clarifying.

#15 lore raw
In reply to Jan Beulich
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

discard-secure may also be present if feature-discard is enabled.

David

#16 lore raw
In reply to Jan Beulich
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

discard-secure may also be present if feature-discard is enabled.

David

#17 lore raw
Quoted 25 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

Quoted 8 lines

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

It would be "may" here too afaict. But I'll defer to Konrad, who has done more work in this area...

Jan

Quoted 3 lines

discard-secure may also be present if feature-discard is enabled.

David

#18 lore raw
In reply to David Vrabel
Quoted 25 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 4 lines · Jan Beulich

You can't do this in one go - the first two and the last one may be set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an all or nothing thing. If they are truly optional then blkif.h should be updated to say that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

They _are_ optional.

But is it true that either they are all present or they are all absent?

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

Quoted 8 lines

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

It would be "may" here too afaict. But I'll defer to Konrad, who has done more work in this area...

Jan

Quoted 3 lines

discard-secure may also be present if feature-discard is enabled.

David

#19 lore raw
Quoted 51 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 13.01.14 at 14:00, Ian Campbell <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 1 line · Jan Beulich

You can't do this in one go - the first two and the last one may

be

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an

all or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

nothing thing. If they are truly optional then blkif.h should be

updated

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

to say that.

They _are_ optional.

But is it true that either they are all present or they are all

absent?

Quoted 6 lines
Quoted 3 lines

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

Quoted 8 lines

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

It would be "may" here too afaict. But I'll defer to Konrad, who has done more work in this area...

Jan

Quoted 3 lines

discard-secure may also be present if feature-discard is enabled.

David

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

It is all 'may'. If there is just 'feature-discard' without any other options that is OK.

#20 lore raw
In reply to Jan Beulich
Quoted 51 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · David Vrabel
Quoted 1 line · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 13.01.14 at 14:00, Ian Campbell <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Olaf Hering
Quoted 1 line · Jan Beulich

You can't do this in one go - the first two and the last one may

be

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

set independently (and are independent in their meaning), and hence need to be queried independently (xenbus_gather() fails on the first absent value).

Yes, thats the purpose. Since the properties are required its an

all or

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

nothing thing. If they are truly optional then blkif.h should be

updated

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

to say that.

They _are_ optional.

But is it true that either they are all present or they are all

absent?

Quoted 6 lines
Quoted 3 lines

No, it's not. discard-secure is independent of the other two (but those other two are tied together).

Can we have a patch to blkif.h that clarifies this?

Quoted 8 lines

e.g.,

feature-discard

...

discard-granularity and discard-offset must also be present if feature-discard is enabled

It would be "may" here too afaict. But I'll defer to Konrad, who has done more work in this area...

Jan

Quoted 3 lines

discard-secure may also be present if feature-discard is enabled.

David

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

It is all 'may'. If there is just 'feature-discard' without any other options that is OK.

#21 lore raw
In reply to David Vrabel
Quoted 1 line · David Vrabel

Can we have a patch to blkif.h that clarifies this?

What about this change?

xen/include/public/io/blkif.h +7 -3
index 84eb7fd..56e2faa 100644
@@ -194,6 +194,7 @@
  * discard-secure
  *      Values:         0/1 (boolean)
  *      Default Value:  0
+ *      Notes:          10
  *
  *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
  *      requests with the BLKIF_DISCARD_SECURE flag set.
@@ -323,9 +324,10 @@
  *     For full interoperability, block front and backends should publish
  *     identical ring parameters, adjusted for unit differences, to the
  *     XenStore nodes used in both schemes.
- * (4) Devices that support discard functionality may internally allocate
- *     space (discardable extents) in units that are larger than the
- *     exported logical block size.
+ * (4) Devices that support discard functionality may internally allocate space
+ *     (discardable extents) in units that are larger than the exported logical
+ *     block size. The properties discard-granularity and discard-alignment may
+ *     be present if the backing device has such requirments.
  * (5) The discard-alignment parameter allows a physical device to be
  *     partitioned into virtual devices that do not necessarily begin or
  *     end on a discardable extent boundary.
@@ -344,6 +346,8 @@
  *     grants that can be persistently mapped in the frontend driver, but
  *     due to the frontent driver implementation it should never be bigger
  *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *(10) The discard-secure property may be present and will be set to 1 if the
+ *     backing device supports secure discard.
  */
 
 /*

Olaf

#22 lore raw
In reply to David Vrabel
Quoted 1 line · David Vrabel

Can we have a patch to blkif.h that clarifies this?

What about this change?

xen/include/public/io/blkif.h +7 -3
index 84eb7fd..56e2faa 100644
@@ -194,6 +194,7 @@
  * discard-secure
  *      Values:         0/1 (boolean)
  *      Default Value:  0
+ *      Notes:          10
  *
  *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
  *      requests with the BLKIF_DISCARD_SECURE flag set.
@@ -323,9 +324,10 @@
  *     For full interoperability, block front and backends should publish
  *     identical ring parameters, adjusted for unit differences, to the
  *     XenStore nodes used in both schemes.
- * (4) Devices that support discard functionality may internally allocate
- *     space (discardable extents) in units that are larger than the
- *     exported logical block size.
+ * (4) Devices that support discard functionality may internally allocate space
+ *     (discardable extents) in units that are larger than the exported logical
+ *     block size. The properties discard-granularity and discard-alignment may
+ *     be present if the backing device has such requirments.
  * (5) The discard-alignment parameter allows a physical device to be
  *     partitioned into virtual devices that do not necessarily begin or
  *     end on a discardable extent boundary.
@@ -344,6 +346,8 @@
  *     grants that can be persistently mapped in the frontend driver, but
  *     due to the frontent driver implementation it should never be bigger
  *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *(10) The discard-secure property may be present and will be set to 1 if the
+ *     backing device supports secure discard.
  */
 
 /*

Olaf

#23 lore raw
Quoted 19 lines · Olaf Hering
Quoted 1 line · David Vrabel

Can we have a patch to blkif.h that clarifies this?

What about this change?

xen/include/public/io/blkif.h +1 -0
index 84eb7fd..56e2faa 100644
@@ -194,6 +194,7 @@
  * discard-secure
  *      Values:         0/1 (boolean)
  *      Default Value:  0
+ *      Notes:          10
  *
  *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
  *      requests with the BLKIF_DISCARD_SECURE flag set.

xen/include/public/io/blkif.h line 330

Quoted 10 lines
xen/include/public/io/blkif.h +4 -3
@@ -323,9 +324,10 @@
  *     For full interoperability, block front and backends should publish
  *     identical ring parameters, adjusted for unit differences, to the
  *     XenStore nodes used in both schemes.
- * (4) Devices that support discard functionality may internally allocate
- *     space (discardable extents) in units that are larger than the
- *     exported logical block size.
+ * (4) Devices that support discard functionality may internally allocate space
+ *     (discardable extents) in units that are larger than the exported logical
+ *     block size. The properties discard-granularity and discard-alignment may
+ *     be present if the backing device has such requirments.

Clarify that both discard-granularity and discard-alignment must be present if non-sector-sized granularity is required. e.g.,

"If the backing device has such discardable extents the backend must provide both discard-granularity and discard-alignment."

You find it useful to add these recommendations:

"Backends supporting discard should include discard-granularity and discard-alignment even if it supports discarding individual sectors. Frontends should assume discard-aligment == 0 and discard-granularity == sector size if these keys are missing."

xen/include/public/io/blkif.h line 351

Quoted 10 lines
xen/include/public/io/blkif.h +2 -0
  * (5) The discard-alignment parameter allows a physical device to be
  *     partitioned into virtual devices that do not necessarily begin or
  *     end on a discardable extent boundary.
@@ -344,6 +346,8 @@
  *     grants that can be persistently mapped in the frontend driver, but
  *     due to the frontent driver implementation it should never be bigger
  *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *(10) The discard-secure property may be present and will be set to 1 if the
+ *     backing device supports secure discard.
  */

David

#24 lore raw
In reply to Olaf Hering
Quoted 19 lines · Olaf Hering
Quoted 1 line · David Vrabel

Can we have a patch to blkif.h that clarifies this?

What about this change?

xen/include/public/io/blkif.h +1 -0
index 84eb7fd..56e2faa 100644
@@ -194,6 +194,7 @@
  * discard-secure
  *      Values:         0/1 (boolean)
  *      Default Value:  0
+ *      Notes:          10
  *
  *      A value of "1" indicates that the backend can process BLKIF_OP_DISCARD
  *      requests with the BLKIF_DISCARD_SECURE flag set.

xen/include/public/io/blkif.h line 330

Quoted 10 lines
xen/include/public/io/blkif.h +4 -3
@@ -323,9 +324,10 @@
  *     For full interoperability, block front and backends should publish
  *     identical ring parameters, adjusted for unit differences, to the
  *     XenStore nodes used in both schemes.
- * (4) Devices that support discard functionality may internally allocate
- *     space (discardable extents) in units that are larger than the
- *     exported logical block size.
+ * (4) Devices that support discard functionality may internally allocate space
+ *     (discardable extents) in units that are larger than the exported logical
+ *     block size. The properties discard-granularity and discard-alignment may
+ *     be present if the backing device has such requirments.

Clarify that both discard-granularity and discard-alignment must be present if non-sector-sized granularity is required. e.g.,

"If the backing device has such discardable extents the backend must provide both discard-granularity and discard-alignment."

You find it useful to add these recommendations:

"Backends supporting discard should include discard-granularity and discard-alignment even if it supports discarding individual sectors. Frontends should assume discard-aligment == 0 and discard-granularity == sector size if these keys are missing."

xen/include/public/io/blkif.h line 351

Quoted 10 lines
xen/include/public/io/blkif.h +2 -0
  * (5) The discard-alignment parameter allows a physical device to be
  *     partitioned into virtual devices that do not necessarily begin or
  *     end on a discardable extent boundary.
@@ -344,6 +346,8 @@
  *     grants that can be persistently mapped in the frontend driver, but
  *     due to the frontent driver implementation it should never be bigger
  *     than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST.
+ *(10) The discard-secure property may be present and will be set to 1 if the
+ *     backing device supports secure discard.
  */

David