Commit 9094b960 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

bdev: Assert to check if I/O pass dif_check_flags not enabled by bdev



The generic bdev layer should not pass an I/O with a dif_check_flags set
that the underlying bdev does not support.

The generic bdev layer satisfies this requirement now.

The following patches will change the passthrough vbdev module and the bdev
partition layer to passthrough dif_check_flags. We want to do this as
simply as we can. But, we want to keep satisfying this requirement.

Add an assert to ensure this requirement to be satisfied in future.

We should enable this check only for I/O types which support DIF.
Add a helper function to check if bdev_io supports DIF or not. Assert is
not enabled by release mode. Compiler unused warning does not care about
inline functions. Inline function + switch-case is easy for extension.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Suggested-by: default avatarJim Harris <jiharris@nvidia.com>
Change-Id: Ibdf3307862ea3287df130e63d899fc8cce2a3d31
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23016


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
parent 2e10c84c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1596,6 +1596,14 @@ bdev_submit_request(struct spdk_bdev *bdev, struct spdk_io_channel *ioch,
		bdev_io->internal.f.has_accel_sequence = false;
	}

	/* The generic bdev layer should not pass an I/O with a dif_check_flags set that
	 * the underlying bdev does not support. Add an assert to check this.
	 */
	assert((bdev_io->type != SPDK_BDEV_IO_TYPE_WRITE &&
		bdev_io->type != SPDK_BDEV_IO_TYPE_READ) ||
	       ((bdev_io->u.bdev.dif_check_flags & bdev->dif_check_flags) ==
		bdev_io->u.bdev.dif_check_flags));

	bdev->fn_table->submit_request(ioch, bdev_io);
}