Commit 6cebe9d0 authored by Swapnil Ingle's avatar Swapnil Ingle Committed by Tomasz Zawadzki
Browse files

nvmf: Support physical block size if exposed by bdev



(Note: this patch was previously applied as b32cfc46 and then reverted
as 63642bef.)

Today the in-guest nvme device shows physical_block_size=512 even though
the backend iSCSI bdev supports physical_block_size=4K

iSCSI targets exposes physical block size using
logical_block_per_physical_block_exponent in READ_CAPACITY_16

NPWG is one of the way to let Linux nvme driver set
physical_block_size of the nvme block device.

This patch adds spdk_bdev.phys_blocklen which is updated if the iSCSI
backend exposes physical_block_size.
Later phys_blocklen is used in nvmf to set NPWG and NAWUPF to report
back during NS identity.
Linux driver uses min(nawupf, npwg) to set physical_block_size.

Similarly in scsi_bdev fill lbppbe in READ_CAP16 response
based on spdk_bdev.phys_blocklen.

Fixes #1884

Signed-off-by: default avatarSwapnil Ingle <swapnil.ingle@nutanix.com>
Change-Id: I0b6c81f1937e346d448f49c927eda8c79d2d75c0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7739


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent fa796437
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1014,6 +1014,10 @@ print_namespace(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
			printf("  Atomic Write Unit (PFail):           %d\n", nsdata->nawupf + 1);
		}

		if (nsdata->npwg) {
			printf("  Preferred Write Granularity:         %d\n", nsdata->npwg + 1);
		}

		if (nsdata->nacwu) {
			printf("  Atomic Compare & Write Unit:         %d\n", nsdata->nacwu + 1);
		}
+8 −0
Original line number Diff line number Diff line
@@ -590,6 +590,14 @@ bool spdk_bdev_is_zoned(const struct spdk_bdev *bdev);
 */
uint32_t spdk_bdev_get_data_block_size(const struct spdk_bdev *bdev);

/**
 * Get block device physical block size.
 *
 * \param bdev Block device to query.
 * \return Size of physical block size for this bdev in bytes.
 */
uint32_t spdk_bdev_get_physical_block_size(const struct spdk_bdev *bdev);

/**
 * Get DIF type of the block device.
 *
+3 −0
Original line number Diff line number Diff line
@@ -295,6 +295,9 @@ struct spdk_bdev {
	/** Size in bytes of a logical block for the backend */
	uint32_t blocklen;

	/** Size in bytes of a physical block for the backend */
	uint32_t phys_blocklen;

	/** Number of blocks */
	uint64_t blockcnt;

+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 6
SO_VER := 7
SO_MINOR := 0

ifeq ($(CONFIG_VTUNE),y)
+10 −0
Original line number Diff line number Diff line
@@ -3291,6 +3291,12 @@ spdk_bdev_get_data_block_size(const struct spdk_bdev *bdev)
	}
}

uint32_t
spdk_bdev_get_physical_block_size(const struct spdk_bdev *bdev)
{
	return bdev->phys_blocklen;
}

static uint32_t
_bdev_get_block_size_with_md(const struct spdk_bdev *bdev)
{
@@ -5464,6 +5470,10 @@ bdev_init(struct spdk_bdev *bdev)
		bdev->acwu = 1;
	}

	if (bdev->phys_blocklen == 0) {
		bdev->phys_blocklen = spdk_bdev_get_data_block_size(bdev);
	}

	TAILQ_INIT(&bdev->internal.open_descs);
	TAILQ_INIT(&bdev->internal.locked_ranges);
	TAILQ_INIT(&bdev->internal.pending_locked_ranges);
Loading