bdev: validate I/O offset block alignment
Change-Id: I33506d6b9ff09c45c057326f7339d742eebc45b4 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/372861 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
906ce69413
commit
3754eedc9b
@ -742,6 +742,11 @@ spdk_bdev_has_write_cache(const struct spdk_bdev *bdev)
|
||||
static bool
|
||||
spdk_bdev_io_valid(struct spdk_bdev *bdev, uint64_t offset, uint64_t nbytes)
|
||||
{
|
||||
/* Return failure if offset is not a multiple of bdev->blocklen */
|
||||
if (offset % bdev->blocklen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return failure if nbytes is not a multiple of bdev->blocklen */
|
||||
if (nbytes % bdev->blocklen) {
|
||||
return false;
|
||||
|
@ -316,8 +316,7 @@ io_valid_test(void)
|
||||
CU_ASSERT(spdk_bdev_io_valid(&bdev, 512, 1024) == true);
|
||||
|
||||
/* Offset not a block multiple */
|
||||
/* TODO: add a check for this in spdk_bdev_io_valid() */
|
||||
/* CU_ASSERT(spdk_bdev_io_valid(&bdev, 3, 512) == false); */
|
||||
CU_ASSERT(spdk_bdev_io_valid(&bdev, 3, 512) == false);
|
||||
|
||||
/* Length not a block multiple */
|
||||
CU_ASSERT(spdk_bdev_io_valid(&bdev, 512, 3) == false);
|
||||
|
Loading…
Reference in New Issue
Block a user