From: Christoph Hellwig <hch@lst.de>
To: John Garry <john.g.garry@oracle.com>
Cc: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-raid@vger.kernel.org, martin.petersen@oracle.com
Subject: Re: [PATCH v2 2/5] block: Support atomic writes limits for stacked devices
Date: Wed, 30 Oct 2024 14:50:06 +0100 [thread overview]
Message-ID: <20241030135006.GC27762@lst.de> (raw)
In-Reply-To: <20241030094912.3960234-3-john.g.garry@oracle.com>
On Wed, Oct 30, 2024 at 09:49:09AM +0000, John Garry wrote:
> Allow stacked devices to support atomic writes by aggregating the minimum
> capability of all bottom devices.
>
> Flag BLK_FEAT_ATOMIC_WRITES_STACKED is set for stacked devices which
> have been enabled to support atomic writes.
>
> Some things to note on the implementation:
> - For simplicity, all bottom devices must have same atomic write boundary
> value (if any)
> - The atomic write boundary must be a power-of-2 already, but this
> restriction could be relaxed. Furthermore, it is now required that the
> chunk sectors for a top device must be aligned with this boundary.
> - If a bottom device atomic write unit min/max are not aligned with the
> top device chunk sectors, the top device atomic write unit min/max are
> reduced to a value which works for the chunk sectors.
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
> block/blk-settings.c | 89 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/blkdev.h | 4 ++
> 2 files changed, 93 insertions(+)
>
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index 1642e65a6521..6a900ef86e5a 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -496,6 +496,93 @@ static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lb
> return sectors;
> }
>
> +static void blk_stack_atomic_writes_limits(struct queue_limits *t, struct queue_limits *b)
Avoid the overly long line here.
> + if (t->atomic_write_hw_max) {
Maybe split this branch and the code for when it is not set into
separate helpers to keep the function to a size where it can be
easily understood?
> + /* Check first bottom device limits */
> + if (!b->atomic_write_hw_boundary)
> + goto check_unit;
> + /*
> + * Ensure atomic write boundary is aligned with chunk sectors. Stacked
> + * devices store chunk sectors in t->io_min.
> + */
> + if (b->atomic_write_hw_boundary > t->io_min &&
> + b->atomic_write_hw_boundary % t->io_min)
> + goto unsupported;
> + else if (t->io_min > b->atomic_write_hw_boundary &&
No need for the else here.
> + t->io_min % b->atomic_write_hw_boundary)
> + goto unsupported;
> +
> + t->atomic_write_hw_boundary = b->atomic_write_hw_boundary;
> +
> +check_unit:
Maybe instead of the check_unit goto just move the checks between the
goto above and this into a branch?
Otherwise this looks conceptually fine to me.
next prev parent reply other threads:[~2024-10-30 13:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-30 9:49 [PATCH v2 0/5] RAID 0/1/10 atomic write support John Garry
2024-10-30 9:49 ` [PATCH v2 1/5] block: Add extra checks in blk_validate_atomic_write_limits() John Garry
2024-10-30 13:47 ` Christoph Hellwig
2024-10-30 9:49 ` [PATCH v2 2/5] block: Support atomic writes limits for stacked devices John Garry
2024-10-30 13:50 ` Christoph Hellwig [this message]
2024-10-30 14:03 ` John Garry
2024-10-30 9:49 ` [PATCH v2 3/5] md/raid0: Atomic write support John Garry
2024-10-30 9:49 ` [PATCH v2 4/5] md/raid1: " John Garry
2024-10-31 1:47 ` kernel test robot
2024-10-31 1:57 ` Yu Kuai
2024-10-31 11:17 ` John Garry
2024-10-31 4:43 ` kernel test robot
2024-10-30 9:49 ` [PATCH v2 5/5] md/raid10: " John Garry
2024-10-31 4:53 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241030135006.GC27762@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=john.g.garry@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=song@kernel.org \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox