Re: [PATCH 21/21] nvme: Support atomic writes

From: Christoph Hellwig
Date: Thu Nov 09 2023 - 10:36:13 EST


> + if (le16_to_cpu(id->nabspf))
> + boundary = (le16_to_cpu(id->nabspf) + 1) * bs;
> +
> + if (is_power_of_2(boundary) || !boundary) {
> + blk_queue_atomic_write_max_bytes(disk->queue, atomic_bs);
> + blk_queue_atomic_write_unit_min_sectors(disk->queue, 1);
> + blk_queue_atomic_write_unit_max_sectors(disk->queue,
> + atomic_bs / bs);
> + blk_queue_atomic_write_boundary_bytes(disk->queue, boundary);
> + } else {
> + dev_err(ns->ctrl->device, "Unsupported atomic boundary=0x%x\n",
> + boundary);
> + }

Please figure out a way to split the atomic configuration into a
helper and avoid all those crazy long lines, preferable also avoid
the double calls to the block helpers as well while you're at it.

Also I really want a check in the NVMe I/O path that any request
with the atomic flag set actually adhers to the limits to at least
partially paper over the annoying lack of a separate write atomic
command in nvme.