Commit e21c39aa authored by Anton Nayshtut's avatar Anton Nayshtut Committed by Jim Harris
Browse files

fsdev/aio: Add aio fsdev implementation



Change-Id: I5add43886241803eb3a65d64beae58ddd91d335d
Signed-off-by: default avatarAnton Nayshtut <anayshtut@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22534


Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent 260d18d1
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -241,3 +241,15 @@ CONFIG_GOLANG=n

# Build fsdev
CONFIG_FSDEV=y

# Build with aio fsdev
CONFIG_AIO_FSDEV=y

# struct stat has st_atime field
CONFIG_HAVE_STRUCT_STAT_ST_ATIM=n

# struct stat has st_atimespec field
CONFIG_HAVE_STRUCT_STAT_ST_ATIMESPEC=n

# libc contains the copy_file_range
CONFIG_COPY_FILE_RANGE=n
+43 −0
Original line number Diff line number Diff line
@@ -132,6 +132,8 @@ function usage() {
	echo " --without-avahi           No path required."
	echo " --with-golang             Build with components written in Go"
	echo " --without-golang          No path required."
	echo " --with-aio-fsdev          Build aio FSDEV component."
	echo " --without-aio-fsdev       No path required."
	echo ""
	echo "Environment variables:"
	echo ""
@@ -691,6 +693,13 @@ for i in "$@"; do
			CONFIG[MAX_LCORES]="${i#*=}"
			CONFIG["MAX_LCORES"]=${CONFIG["MAX_LCORES"],,}
			;;
		--with-aio-fsdev)
			CONFIG[AIO_FSDEV]=y
			AIO_FSDEV_REQUIRED=y
			;;
		--without-aio-fsdev)
			CONFIG[AIO_FSDEV]=n
			;;
		--)
			break
			;;
@@ -1346,6 +1355,40 @@ if [[ -n ${CONFIG[MAX_LCORES]} ]]; then
	fi
fi

if [[ "${CONFIG[FSDEV]}" = "n" ]]; then
	if [[ "$AIO_FSDEV_REQUIRED" = "y" ]]; then
		echo "ERROR: --with-aio-fsdev cannot be specified as fsdev is disabled."
		exit 1
	fi

	# if AIO_FSDEV is not explicitly required by user, we just silently disable it
	CONFIG[AIO_FSDEV]=n
fi

if [[ "${CONFIG[AIO_FSDEV]}" = "y" ]]; then
	if echo -e '#define _GNU_SOURCE\n#include <unistd.h>\n' \
		'int main(void) { return copy_file_range(0, 0, 0, 0, 0, 0); }\n' \
		| "${BUILD_CMD[@]}" - 2> /dev/null; then
		CONFIG[COPY_FILE_RANGE]=y
	else
		CONFIG[COPY_FILE_RANGE]=n
	fi
	if echo -e '#include <sys/stat.h>\n' \
		'int main(void) { struct stat s; s.st_atime = s.st_atime; return 0 ;}\n' \
		| "${BUILD_CMD[@]}" - 2> /dev/null; then
		CONFIG[HAVE_STRUCT_STAT_ST_ATIM]=y
		CONFIG[HAVE_STRUCT_STAT_ST_ATIMESPEC]=n
	elif echo -e '#include <sys/stat.h>\n' \
		'int main(void) { struct stat s; s.st_atimespec = s.st_atimespec; return 0; }\n' \
		| "${BUILD_CMD[@]}" - 2> /dev/null; then
		CONFIG[HAVE_STRUCT_STAT_ST_ATIM]=n
		CONFIG[HAVE_STRUCT_STAT_ST_ATIMESPEC]=y
	else
		CONFIG[HAVE_STRUCT_STAT_ST_ATIM]=n
		CONFIG[HAVE_STRUCT_STAT_ST_ATIMESPEC]=n
	fi
fi

# For ARM Neoverse-N1 platform, debug build needs gcc version newer than 8.4
if [[ "${CONFIG[DEBUG]}" = "y" && $arch = aarch64* && "$CC_TYPE" = "gcc" ]]; then
	GCC_VERSION=$($CC -dumpfullversion)
+76 −0
Original line number Diff line number Diff line
@@ -13507,3 +13507,79 @@ Example response:
  }
}
~~~

### fsdev_aio_create {#fsdev_aio_create}

Create an AIO fsdev.

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
name                    | Required | string      | Name of the AIO fsdev to create.
root_path               | Required | string      | Path on the system directory to be exposed as an SPDK filesystem
enable_xattr            | Optional | bool        | true to enable the extended attributes, false otherwise
enable_writeback_cache  | Optional | bool        | true to enable the writeback cache, false otherwise
max_write               | Optional | int         | Max write size in bytes

#### Example

Example request:
~~~json
{
  "jsonrpc": "2.0",
  "method": "fsdev_aio_create",
  "id": 8,
  "params": {
    "name": "aio0",
    "root_path": "/tmp/vfio-test",
    "enable_xattr": false,
    "enable_writeback_cache": true,
    "max_write": 65535
  }
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 8,
  "result": "aio0"
}
~~~

### fsdev_aio_delete {#fsdev_aio_delete}

Delete an AIO fsdev.

#### Parameters

Name                    | Optional | Type        | Description
----------------------- | -------- | ----------- | -----------
name                    | Required | string      | Name of the AIO fsdev to delete.

#### Example

Example request:
~~~json
{
  "jsonrpc": "2.0",
  "method": "fsdev_aio_delete",
  "id": 1,
  "params": {
    "name": "aio0"
  }
}
~~~

Example response:

~~~json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}
~~~
+5 −2
Original line number Diff line number Diff line
@@ -66,18 +66,21 @@ extern "C" {
#include <sys/wait.h>
#include <regex.h>
#include <sys/statvfs.h>
#include <sys/syscall.h>
#include <sys/file.h>

/* GNU extension */
#include <getopt.h>

/* Linux */
#ifdef __linux__
#include <sys/xattr.h>
#include <sys/eventfd.h>
#include <sched.h>
#endif

/* FreeBSD */
#ifdef __FreeBSD__
/* FreeBSD or Linux */
#if defined(__FreeBSD__) || defined(__linux__)
#include <aio.h>
#endif

+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ DEPDIRS-bdev_virtio := $(BDEV_DEPS_THREAD) virtio
DEPDIRS-bdev_zone_block := $(BDEV_DEPS_THREAD)
DEPDIRS-bdev_xnvme := $(BDEV_DEPS_THREAD)

# module/fsdev
DEPDIRS-fsdev_aio := $(FSDEV_DEPS_THREAD)

# module/event

# module/event/subsystems
Loading