On Mon, Jan 18, 2021 at 11:25:49AM +0100, Arthur Borsboom wrote:
> Find attached the output of xenstore-ls

Thanks, that's very helpful. I think this is ude to QEMU not writing
the discard-aligment node, which leads to blkfront only setting the
discard feature partially.

Could you give a try to the following patch on on domU? I think it
should solve your issues (I've only build tested it).

---8<---
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 5265975b3fba..5a93f7cc2939 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2179,22 +2179,23 @@ static void blkfront_closing(struct blkfront_info *info)
 
 static void blkfront_setup_discard(struct blkfront_info *info)
 {
-       int err;
-       unsigned int discard_granularity;
-       unsigned int discard_alignment;
+       unsigned int discard_granularity = 0;
+       unsigned int discard_alignment = 0;
+       unsigned int discard_secure = 0;
 
-       info->feature_discard = 1;
-       err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+       xenbus_gather(XBT_NIL, info->xbdev->otherend,
                "discard-granularity", "%u", &discard_granularity,
                "discard-alignment", "%u", &discard_alignment,
+               "discard-secure", "%u", &discard_secure,
                NULL);
-       if (!err) {
-               info->discard_granularity = discard_granularity;
-               info->discard_alignment = discard_alignment;
-       }
-       info->feature_secdiscard =
-               !!xenbus_read_unsigned(info->xbdev->otherend, "discard-secure",
-                                      0);
+
+       if (!discard_granularity)
+               return;
+
+       info->feature_discard = 1;
+       info->discard_granularity = discard_granularity;
+       info->discard_alignment = discard_alignment;
+       info->feature_secdiscard = !!discard_secure;
 }
 
 static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo)

Reply via email to