scsi: Cache physical block size locally

Addressing review comment from 6cebe9d0.
Minor optimisation to cache result of spdk_u32log2() into local variable
instead of calling it multiple times.

Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Change-Id: I2fd6afd1e3ee461662de3f9d278958664224e106
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7806
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: sunshihao <sunshihao@huawei.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
This commit is contained in:
Swapnil Ingle 2021-05-07 06:35:15 -04:00 committed by Tomasz Zawadzki
parent 646f41476d
commit 2421e99849

View File

@ -1614,15 +1614,16 @@ bdev_scsi_process_block(struct spdk_scsi_task *task)
switch (cdb[1] & 0x1f) { /* SERVICE ACTION */
case SPDK_SBC_SAI_READ_CAPACITY_16: {
uint8_t buffer[32] = {0};
uint32_t lbppb;
uint32_t lbppb, lbppbe;
to_be64(&buffer[0], spdk_bdev_get_num_blocks(bdev) - 1);
to_be32(&buffer[8], spdk_bdev_get_data_block_size(bdev));
lbppb = spdk_bdev_get_physical_block_size(bdev) / spdk_bdev_get_data_block_size(bdev);
if (spdk_u32log2(lbppb) > 0xf) {
SPDK_ERRLOG("lbppbe(0x%x) > 0xf\n", spdk_u32log2(lbppb));
lbppbe = spdk_u32log2(lbppb);
if (lbppbe > 0xf) {
SPDK_ERRLOG("lbppbe(0x%x) > 0xf\n", lbppbe);
} else {
buffer[13] = spdk_u32log2(lbppb);
buffer[13] = lbppbe;
}
/*
* Set the TPE bit to 1 to indicate thin provisioning.