Commit 98d34c08 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

xen-blkfront: fix sector_size propagation to the block layer

Ensure that info->sector_size and info->physical_sector_size are set
before the call to blkif_set_queue_limits by doing away with the
local variables and arguments that propagate them.

Thanks to Marek Marczykowski-Górecki and Jürgen Groß for root causing
the issue.

Fixes: ba3f67c1 ("xen-blkfront: atomically update queue limits")
Reported-by: default avatarRusty Bird <rustybird@net-c.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Link: https://lore.kernel.org/r/20240625055238.7934-1-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1c0b3fca
...@@ -1070,8 +1070,7 @@ static char *encode_disk_name(char *ptr, unsigned int n) ...@@ -1070,8 +1070,7 @@ static char *encode_disk_name(char *ptr, unsigned int n)
} }
static int xlvbd_alloc_gendisk(blkif_sector_t capacity, static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
struct blkfront_info *info, u16 sector_size, struct blkfront_info *info)
unsigned int physical_sector_size)
{ {
struct queue_limits lim = {}; struct queue_limits lim = {};
struct gendisk *gd; struct gendisk *gd;
...@@ -1165,8 +1164,6 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity, ...@@ -1165,8 +1164,6 @@ static int xlvbd_alloc_gendisk(blkif_sector_t capacity,
info->rq = gd->queue; info->rq = gd->queue;
info->gd = gd; info->gd = gd;
info->sector_size = sector_size;
info->physical_sector_size = physical_sector_size;
xlvbd_flush(info); xlvbd_flush(info);
...@@ -2320,8 +2317,6 @@ static void blkfront_gather_backend_features(struct blkfront_info *info) ...@@ -2320,8 +2317,6 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
static void blkfront_connect(struct blkfront_info *info) static void blkfront_connect(struct blkfront_info *info)
{ {
unsigned long long sectors; unsigned long long sectors;
unsigned long sector_size;
unsigned int physical_sector_size;
int err, i; int err, i;
struct blkfront_ring_info *rinfo; struct blkfront_ring_info *rinfo;
...@@ -2360,7 +2355,7 @@ static void blkfront_connect(struct blkfront_info *info) ...@@ -2360,7 +2355,7 @@ static void blkfront_connect(struct blkfront_info *info)
err = xenbus_gather(XBT_NIL, info->xbdev->otherend, err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
"sectors", "%llu", &sectors, "sectors", "%llu", &sectors,
"info", "%u", &info->vdisk_info, "info", "%u", &info->vdisk_info,
"sector-size", "%lu", &sector_size, "sector-size", "%lu", &info->sector_size,
NULL); NULL);
if (err) { if (err) {
xenbus_dev_fatal(info->xbdev, err, xenbus_dev_fatal(info->xbdev, err,
...@@ -2374,9 +2369,9 @@ static void blkfront_connect(struct blkfront_info *info) ...@@ -2374,9 +2369,9 @@ static void blkfront_connect(struct blkfront_info *info)
* provide this. Assume physical sector size to be the same as * provide this. Assume physical sector size to be the same as
* sector_size in that case. * sector_size in that case.
*/ */
physical_sector_size = xenbus_read_unsigned(info->xbdev->otherend, info->physical_sector_size = xenbus_read_unsigned(info->xbdev->otherend,
"physical-sector-size", "physical-sector-size",
sector_size); info->sector_size);
blkfront_gather_backend_features(info); blkfront_gather_backend_features(info);
for_each_rinfo(info, rinfo, i) { for_each_rinfo(info, rinfo, i) {
err = blkfront_setup_indirect(rinfo); err = blkfront_setup_indirect(rinfo);
...@@ -2388,8 +2383,7 @@ static void blkfront_connect(struct blkfront_info *info) ...@@ -2388,8 +2383,7 @@ static void blkfront_connect(struct blkfront_info *info)
} }
} }
err = xlvbd_alloc_gendisk(sectors, info, sector_size, err = xlvbd_alloc_gendisk(sectors, info);
physical_sector_size);
if (err) { if (err) {
xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",
info->xbdev->otherend); info->xbdev->otherend);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment