Thread (104 messages) 104 messages, 13 authors, 2023-12-05

Re: [PATCH 18/21] scsi: sd: Support reading atomic properties from block limits VPD

From: John Garry <john.g.garry@oracle.com>
Date: 2023-10-02 11:28:33
Also in: linux-block, linux-fsdevel, linux-nvme, linux-xfs, lkml

On 29/09/2023 18:54, Bart Van Assche wrote:
On 9/29/23 03:27, John Garry wrote:
quoted
+static void sd_config_atomic(struct scsi_disk *sdkp)
+{
+    unsigned int logical_block_size = sdkp->device->sector_size;
+    struct request_queue *q = sdkp->disk->queue;
+
+    if (sdkp->max_atomic) {
Please use the "return early" style here to keep the indentation
level in this function low.
ok, fine.
quoted
+        unsigned int max_atomic = max_t(unsigned int,
+            rounddown_pow_of_two(sdkp->max_atomic),
+            rounddown_pow_of_two(sdkp->max_atomic_with_boundary));
+        unsigned int unit_min = sdkp->atomic_granularity ?
+            rounddown_pow_of_two(sdkp->atomic_granularity) :
+            physical_block_size_sectors;
+        unsigned int unit_max = max_atomic;
+
+        if (sdkp->max_atomic_boundary)
+            unit_max = min_t(unsigned int, unit_max,
+                rounddown_pow_of_two(sdkp->max_atomic_boundary));
Why does "rounddown_pow_of_two()" occur in the above code?
I assume that you are talking about all the code above to calculate 
atomic write values for the device.

The reason is that atomic write unit min and max are always a power-of-2 
- see rules described earlier - as so that we why we rounddown to a 
power-of-2.

Thanks,
John
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help