Commit 2c0bc387 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

bdev: add "split" virtual blockdev example



This virtual block device takes an underlying block device and splits it
into several smaller equal-sized block devices.

Change-Id: I6f6e686c1177b2e4885f7e88809ad329caae55bd
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent efccac8c
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@
# Of course, users can disable offload even it is available.
[Malloc]
  # Number of Malloc targets
  NumberOfLuns 1
  NumberOfLuns 3
  # Malloc targets are 128M
  LunSizeInMB 128
  # Block size. Default is 512 bytes.
@@ -140,6 +140,18 @@
  AIO /dev/sdb
  AIO /dev/sdc

# The Split virtual block device slices block devices into multiple smaller bdevs.
[Split]
  # Syntax:
  #   Split <bdev> <count> [<size_in_megabytes>]

  # Split Malloc1 into two equally-sized portions, Malloc1p0 and Malloc1p1
  Split Malloc1 2

  # Split Malloc2 into eight 1-megabyte portions, Malloc2p0 ... Malloc2p7,
  # leaving the rest of the device inaccessible
  Split Malloc2 8 1

# Users should change the TargetNode section(s) below to match the
#  desired iSCSI target node configuration.
# TargetName, Mapping, LUN0 are minimum required
+12 −0
Original line number Diff line number Diff line
@@ -76,6 +76,18 @@
  # Units in microseconds.
  AdminPollRate 100000

# The Split virtual block device slices block devices into multiple smaller bdevs.
[Split]
  # Syntax:
  #   Split <bdev> <count> [<size_in_megabytes>]

  # Split Malloc2 into two equally-sized portions, Malloc2p0 and Malloc2p1
  Split Malloc2 2

  # Split Malloc3 into eight 1-megabyte portions, Malloc3p0 ... Malloc3p7,
  # leaving the rest of the device inaccessible
  Split Malloc3 8 1

# Define an NVMf Subsystem.
# - NQN is required and must be unique.
# - Core may be set or not. If set, the specified subsystem will run on
+1 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ struct spdk_bdev_io *spdk_bdev_get_child_io(struct spdk_bdev_io *parent,
		struct spdk_bdev *bdev,
		spdk_bdev_io_completion_cb cb,
		void *cb_arg);
void spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev *new_bdev);
void spdk_bdev_io_complete(struct spdk_bdev_io *bdev_io,
			   enum spdk_bdev_io_status status);

+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ CFLAGS += $(ENV_CFLAGS) -I.
C_SRCS = bdev.c
LIBNAME = bdev

DIRS-y += malloc nvme rpc
DIRS-y += malloc nvme rpc split

ifeq ($(OS),Linux)
DIRS-y += aio
+16 −0
Original line number Diff line number Diff line
@@ -430,6 +430,22 @@ spdk_bdev_io_submit(struct spdk_bdev_io *bdev_io)
	return 0;
}

void
spdk_bdev_io_resubmit(struct spdk_bdev_io *bdev_io, struct spdk_bdev *new_bdev)
{
	assert(bdev_io->status == SPDK_BDEV_IO_STATUS_PENDING);
	bdev_io->bdev = new_bdev;

	/*
	 * These fields are normally set during spdk_bdev_io_init(), but since bdev is
	 * being switched, they need to be reinitialized.
	 */
	bdev_io->gencnt = new_bdev->gencnt;
	bdev_io->ctx = new_bdev->ctxt;

	__submit_request(new_bdev, bdev_io);
}

static void
spdk_bdev_io_init(struct spdk_bdev_io *bdev_io,
		  struct spdk_bdev *bdev, void *cb_arg,
Loading