mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
block: Add extra checks in blk_validate_atomic_write_limits()
It is so far expected that the limits passed are valid. In future atomic writes will be supported for stacked block devices, and calculating the limits there will be complicated, so add extra sanity checks to ensure that the values are always valid. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: John Garry <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
1 parent
34c1227035
commit
d00eea91de
1 file changed
+17
@@ -178,9 +178,26 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim)
|
||||
if (!lim->atomic_write_hw_max)
|
||||
goto unsupported;
|
||||
|
||||
if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_min)))
|
||||
goto unsupported;
|
||||
|
||||
if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_max)))
|
||||
goto unsupported;
|
||||
|
||||
if (WARN_ON_ONCE(lim->atomic_write_hw_unit_min >
|
||||
lim->atomic_write_hw_unit_max))
|
||||
goto unsupported;
|
||||
|
||||
if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max >
|
||||
lim->atomic_write_hw_max))
|
||||
goto unsupported;
|
||||
|
||||
boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT;
|
||||
|
||||
if (boundary_sectors) {
|
||||
if (WARN_ON_ONCE(lim->atomic_write_hw_max >
|
||||
lim->atomic_write_hw_boundary))
|
||||
goto unsupported;
|
||||
/*
|
||||
* A feature of boundary support is that it disallows bios to
|
||||
* be merged which would result in a merged request which
|
||||
|
||||
Reference in new issue
Block a user