mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
ublk: reject non-power-of-2 zone sizes in SET_PARAMS
UBLK_F_ZONED uses params.basic.chunk_sectors as zone size. ublk uses
ilog2(chunk_sectors) to get number of zones, so the value must be power
of 2.
If chunk_sectors is 96 and dev_sectors is 96 * 16, userspace asks for
16 zones. But the shift calculation gets 24 zones.
Block layer rejects such zone size when the disk is started. But
SET_PARAMS has already returned success, which is confusing for
userspace. Reject it in SET_PARAMS with other zoned parameter checks.
Fixes: 29802d7ca3 ("ublk: enable zoned storage support")
Signed-off-by: Yao Sang <sangyao@kylinos.cn>
Link: https://patch.msgid.link/20260814023226.354288-2-sangyao@kylinos.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
4febfe7d98
commit
2707acf185
|
|
@ -980,7 +980,7 @@ static int ublk_validate_params(const struct ublk_device *ub)
|
|||
if (p->max_sectors < PAGE_SECTORS)
|
||||
return -EINVAL;
|
||||
|
||||
if (ublk_dev_is_zoned(ub) && !p->chunk_sectors)
|
||||
if (ublk_dev_is_zoned(ub) && !is_power_of_2(p->chunk_sectors))
|
||||
return -EINVAL;
|
||||
} else
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user