Skip to content

Commit 06ba5d2

Browse files
sjp38jgross1
authored andcommitted
xen-blkback: Advertise feature-persistent as user requested
The advertisement of the persistent grants feature (writing 'feature-persistent' to xenbus) should mean not the decision for using the feature but only the availability of the feature. However, commit aac8a70 ("xen-blkback: add a parameter for disabling of persistent grants") made a field of blkback, which was a place for saving only the negotiation result, to be used for yet another purpose: caching of the 'feature_persistent' parameter value. As a result, the advertisement, which should follow only the parameter value, becomes inconsistent. This commit fixes the misuse of the semantic by making blkback saves the parameter value in a separate place and advertises the support based on only the saved value. Fixes: aac8a70 ("xen-blkback: add a parameter for disabling of persistent grants") Cc: <stable@vger.kernel.org> # 5.10.x Suggested-by: Juergen Gross <jgross@suse.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-2-sj@kernel.org Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent c5deb27 commit 06ba5d2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/block/xen-blkback/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ struct xen_vbd {
226226
sector_t size;
227227
unsigned int flush_support:1;
228228
unsigned int discard_secure:1;
229+
/* Connect-time cached feature_persistent parameter value */
230+
unsigned int feature_gnt_persistent_parm:1;
231+
/* Persistent grants feature negotiation result */
229232
unsigned int feature_gnt_persistent:1;
230233
unsigned int overflow_max_grants:1;
231234
};

drivers/block/xen-blkback/xenbus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ static void connect(struct backend_info *be)
907907
xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
908908

909909
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
910-
be->blkif->vbd.feature_gnt_persistent);
910+
be->blkif->vbd.feature_gnt_persistent_parm);
911911
if (err) {
912912
xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
913913
dev->nodename);
@@ -1085,7 +1085,9 @@ static int connect_ring(struct backend_info *be)
10851085
return -ENOSYS;
10861086
}
10871087

1088-
blkif->vbd.feature_gnt_persistent = feature_persistent &&
1088+
blkif->vbd.feature_gnt_persistent_parm = feature_persistent;
1089+
blkif->vbd.feature_gnt_persistent =
1090+
blkif->vbd.feature_gnt_persistent_parm &&
10891091
xenbus_read_unsigned(dev->otherend, "feature-persistent", 0);
10901092

10911093
blkif->vbd.overflow_max_grants = 0;

0 commit comments

Comments
 (0)