xen-blkfront: allow discard-* nodes to be optional
This is inline with the specification described in blkif.h:
* discard-granularity: should be set to the physical block size if
node is not present.
* discard-alignment, discard-secure: should be set to 0 if node not
present.
This was detected as QEMU would only create the discard-granularity
node but not discard-alignment, and thus the setup done in
blkfront_setup_discard would fail.
Fix blkfront_setup_discard to not fail on missing nodes, and also fix
blkif_set_queue_limits to set the discard granularity to the physical
block size if none is specified in xenbus.
Fixes: ed30bf317c
('xen-blkfront: Handle discard requests.')
Reported-by: Arthur Borsboom <arthurborsboom@gmail.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Tested-By: Arthur Borsboom <arthurborsboom@gmail.com>
Link: https://lore.kernel.org/r/20210119105727.95173-1-roger.pau@citrix.com
Signed-off-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
Родитель
bd9dcef67f
Коммит
0549cd67b0
|
@ -945,7 +945,8 @@ static void blkif_set_queue_limits(struct blkfront_info *info)
|
||||||
if (info->feature_discard) {
|
if (info->feature_discard) {
|
||||||
blk_queue_flag_set(QUEUE_FLAG_DISCARD, rq);
|
blk_queue_flag_set(QUEUE_FLAG_DISCARD, rq);
|
||||||
blk_queue_max_discard_sectors(rq, get_capacity(gd));
|
blk_queue_max_discard_sectors(rq, get_capacity(gd));
|
||||||
rq->limits.discard_granularity = info->discard_granularity;
|
rq->limits.discard_granularity = info->discard_granularity ?:
|
||||||
|
info->physical_sector_size;
|
||||||
rq->limits.discard_alignment = info->discard_alignment;
|
rq->limits.discard_alignment = info->discard_alignment;
|
||||||
if (info->feature_secdiscard)
|
if (info->feature_secdiscard)
|
||||||
blk_queue_flag_set(QUEUE_FLAG_SECERASE, rq);
|
blk_queue_flag_set(QUEUE_FLAG_SECERASE, rq);
|
||||||
|
@ -2179,19 +2180,12 @@ static void blkfront_closing(struct blkfront_info *info)
|
||||||
|
|
||||||
static void blkfront_setup_discard(struct blkfront_info *info)
|
static void blkfront_setup_discard(struct blkfront_info *info)
|
||||||
{
|
{
|
||||||
int err;
|
|
||||||
unsigned int discard_granularity;
|
|
||||||
unsigned int discard_alignment;
|
|
||||||
|
|
||||||
info->feature_discard = 1;
|
info->feature_discard = 1;
|
||||||
err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
info->discard_granularity = xenbus_read_unsigned(info->xbdev->otherend,
|
||||||
"discard-granularity", "%u", &discard_granularity,
|
"discard-granularity",
|
||||||
"discard-alignment", "%u", &discard_alignment,
|
0);
|
||||||
NULL);
|
info->discard_alignment = xenbus_read_unsigned(info->xbdev->otherend,
|
||||||
if (!err) {
|
"discard-alignment", 0);
|
||||||
info->discard_granularity = discard_granularity;
|
|
||||||
info->discard_alignment = discard_alignment;
|
|
||||||
}
|
|
||||||
info->feature_secdiscard =
|
info->feature_secdiscard =
|
||||||
!!xenbus_read_unsigned(info->xbdev->otherend, "discard-secure",
|
!!xenbus_read_unsigned(info->xbdev->otherend, "discard-secure",
|
||||||
0);
|
0);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче