diff mbox series

[RFC,3/4] block: Support atomic writes limits for stacked devices

Message ID 20240903150748.2179966-4-john.g.garry@oracle.com (mailing list archive)
State Handled Elsewhere
Headers show
Series RAID0 atomic write support | expand

Checks

Context Check Description
mdraidci/vmtest-md-6_12-PR success PR summary
mdraidci/vmtest-md-6_12-VM_Test-0 success Logs for per-patch-testing

Commit Message

John Garry Sept. 3, 2024, 3:07 p.m. UTC
Allow stacked devices to support atomic writes by aggregating the minimum
capacility of all bottom devices.

If a bottom device does not support atomic writes, then
BLK_FEAT_ATOMIC_WRITES should be cleared for that device, and the top
device then will also not support atomic writes.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 block/blk-settings.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Christoph Hellwig Sept. 12, 2024, 1:16 p.m. UTC | #1
On Tue, Sep 03, 2024 at 03:07:47PM +0000, John Garry wrote:
> +	} else if (t->features & BLK_FEAT_ATOMIC_WRITES) {
> +		t->atomic_write_hw_max = min_not_zero(t->atomic_write_hw_max,
> +						b->atomic_write_hw_max);
> +		t->atomic_write_boundary_sectors =
> +					min_not_zero(t->atomic_write_boundary_sectors,
> +						b->atomic_write_boundary_sectors);
> +		t->atomic_write_hw_unit_min = max(t->atomic_write_hw_unit_min,
> +						b->atomic_write_hw_unit_min);
> +		t->atomic_write_hw_unit_max =
> +					min_not_zero(t->atomic_write_hw_unit_max,
> +						b->atomic_write_hw_unit_max);

Maybe split this into a helper to make the code more readable?

Otherwise this looks good to me.
John Garry Sept. 12, 2024, 3:05 p.m. UTC | #2
On 12/09/2024 14:16, Christoph Hellwig wrote:
> On Tue, Sep 03, 2024 at 03:07:47PM +0000, John Garry wrote:
>> +	} else if (t->features & BLK_FEAT_ATOMIC_WRITES) {
>> +		t->atomic_write_hw_max = min_not_zero(t->atomic_write_hw_max,
>> +						b->atomic_write_hw_max);
>> +		t->atomic_write_boundary_sectors =
>> +					min_not_zero(t->atomic_write_boundary_sectors,
>> +						b->atomic_write_boundary_sectors);
>> +		t->atomic_write_hw_unit_min = max(t->atomic_write_hw_unit_min,
>> +						b->atomic_write_hw_unit_min);
>> +		t->atomic_write_hw_unit_max =
>> +					min_not_zero(t->atomic_write_hw_unit_max,
>> +						b->atomic_write_hw_unit_max);
> 
> Maybe split this into a helper to make the code more readable?

Yeah, I will do.

I was reworking this anyway.

So far I am not supporting a stripe unit with which is not a power-of-2. 
But that is too restrictive. And lifting that restriction makes 
calculating atomic write limits more complicated.

> 
> Otherwise this looks good to me.

cheers
diff mbox series

Patch

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 036e67f73116..aeb05fb24801 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -682,6 +682,25 @@  int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 		t->zone_write_granularity = 0;
 		t->max_zone_append_sectors = 0;
 	}
+	if (!(b->features & BLK_FEAT_ATOMIC_WRITES)) {
+		t->atomic_write_hw_max = 0;
+		t->atomic_write_hw_unit_max = 0;
+		t->atomic_write_hw_unit_min = 0;
+		t->atomic_write_hw_boundary = 0;
+		t->features &= ~BLK_FEAT_ATOMIC_WRITES;
+	} else if (t->features & BLK_FEAT_ATOMIC_WRITES) {
+		t->atomic_write_hw_max = min_not_zero(t->atomic_write_hw_max,
+						b->atomic_write_hw_max);
+		t->atomic_write_boundary_sectors =
+					min_not_zero(t->atomic_write_boundary_sectors,
+						b->atomic_write_boundary_sectors);
+		t->atomic_write_hw_unit_min = max(t->atomic_write_hw_unit_min,
+						b->atomic_write_hw_unit_min);
+		t->atomic_write_hw_unit_max =
+					min_not_zero(t->atomic_write_hw_unit_max,
+						b->atomic_write_hw_unit_max);
+	}
+
 	return ret;
 }
 EXPORT_SYMBOL(blk_stack_limits);