Skip to content

Commit fe8f65b

Browse files
sjp38jgross1
authored andcommitted
xen-blkfront: Cache feature_persistent value before advertisement
Xen blkfront advertises its support of the persistent grants feature when it first setting up and when resuming in 'talk_to_blkback()'. Then, blkback reads the advertised value when it connects with blkfront and decides if it will use the persistent grants feature or not, and advertises its decision to blkfront. Blkfront reads the blkback's decision and it also makes the decision for the use of the feature. Commit 402c43e ("xen-blkfront: Apply 'feature_persistent' parameter when connect"), however, made the blkfront's read of the parameter for disabling the advertisement, namely 'feature_persistent', to be done when it negotiate, not when advertise. Therefore blkfront advertises without reading the parameter. As the field for caching the parameter value is zero-initialized, it always advertises as the feature is disabled, so that the persistent grants feature becomes always disabled. This commit fixes the issue by making the blkfront does parmeter caching just before the advertisement. Fixes: 402c43e ("xen-blkfront: Apply 'feature_persistent' parameter when connect") Cc: <stable@vger.kernel.org> # 5.10.x Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Signed-off-by: SeongJae Park <sj@kernel.org> Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Reviewed-by: Juergen Gross <jgross@suse.com> Link: https://lore.kernel.org/r/20220831165824.94815-4-sj@kernel.org Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 9f5e0fe commit fe8f65b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/block/xen-blkfront.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,6 +1759,12 @@ static int write_per_ring_nodes(struct xenbus_transaction xbt,
17591759
return err;
17601760
}
17611761

1762+
/* Enable the persistent grants feature. */
1763+
static bool feature_persistent = true;
1764+
module_param(feature_persistent, bool, 0644);
1765+
MODULE_PARM_DESC(feature_persistent,
1766+
"Enables the persistent grants feature");
1767+
17621768
/* Common code used when first setting up, and when resuming. */
17631769
static int talk_to_blkback(struct xenbus_device *dev,
17641770
struct blkfront_info *info)
@@ -1850,6 +1856,7 @@ static int talk_to_blkback(struct xenbus_device *dev,
18501856
message = "writing protocol";
18511857
goto abort_transaction;
18521858
}
1859+
info->feature_persistent_parm = feature_persistent;
18531860
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
18541861
info->feature_persistent_parm);
18551862
if (err)
@@ -1919,12 +1926,6 @@ static int negotiate_mq(struct blkfront_info *info)
19191926
return 0;
19201927
}
19211928

1922-
/* Enable the persistent grants feature. */
1923-
static bool feature_persistent = true;
1924-
module_param(feature_persistent, bool, 0644);
1925-
MODULE_PARM_DESC(feature_persistent,
1926-
"Enables the persistent grants feature");
1927-
19281929
/*
19291930
* Entry point to this code when a new device is created. Allocate the basic
19301931
* structures and the ring buffer for communication with the backend, and
@@ -2284,7 +2285,6 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
22842285
if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0))
22852286
blkfront_setup_discard(info);
22862287

2287-
info->feature_persistent_parm = feature_persistent;
22882288
if (info->feature_persistent_parm)
22892289
info->feature_persistent =
22902290
!!xenbus_read_unsigned(info->xbdev->otherend,

0 commit comments

Comments
 (0)