[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04620cc5-7c3a-4e4f-87ce-b691d9b57917@kernel.dk>
Date: Thu, 10 Jul 2025 09:08:44 -0600
From: Jens Axboe <axboe@...nel.dk>
To: John Garry <john.g.garry@...cle.com>, agk@...hat.com, snitzer@...nel.org,
mpatocka@...hat.com, song@...nel.org, yukuai3@...wei.com, hch@....de,
nilay@...ux.ibm.com, cem@...nel.org
Cc: dm-devel@...ts.linux.dev, linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org, linux-block@...r.kernel.org,
ojaswin@...ux.ibm.com, martin.petersen@...cle.com,
akpm@...ux-foundation.org, linux-xfs@...r.kernel.org, djwong@...nel.org
Subject: Re: [PATCH v5 2/6] block: sanitize chunk_sectors for atomic write
limits
On 7/9/25 4:02 AM, John Garry wrote:
> Currently we just ensure that a non-zero value in chunk_sectors aligns
> with any atomic write boundary, as the blk boundary functionality uses
> both these values.
>
> However it is also improper to have atomic write unit max > chunk_sectors
> (for non-zero chunk_sectors), as this would lead to splitting of atomic
> write bios (which is disallowed).
>
> Sanitize atomic write unit max against chunk_sectors to avoid any
> potential problems.
>
> Fixes: d00eea91deaf3 ("block: Add extra checks in blk_validate_atomic_write_limits()")
> Reviewed-by: Nilay Shroff <nilay@...ux.ibm.com>
> Signed-off-by: John Garry <john.g.garry@...cle.com>
> ---
> block/blk-settings.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index a000daafbfb4..725035376f51 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -180,6 +180,7 @@ static void blk_atomic_writes_update_limits(struct queue_limits *lim)
>
> static void blk_validate_atomic_write_limits(struct queue_limits *lim)
> {
> + unsigned long long chunk_bytes;
> unsigned int boundary_sectors;
>
> if (!(lim->features & BLK_FEAT_ATOMIC_WRITES))
> @@ -202,6 +203,13 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim)
> lim->atomic_write_hw_max))
> goto unsupported;
>
> + chunk_bytes = lim->chunk_sectors << SECTOR_SHIFT;
> + if (chunk_bytes) {
> + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max >
> + chunk_bytes))
> + goto unsupported;
> + }
Unnecessary indentation here. Why not just:
chunk_bytes = lim->chunk_sectors << SECTOR_SHIFT;
if (WARN_ON_ONCE(chunk_bytes &&
lim->atomic_write_hw_unit_max > chunk_bytes))
goto unsupposed.
Also avoids splitting a comparison over multiple lines, which is always
annoying to read.
--
Jens Axboe
Powered by blists - more mailing lists