Commit d00039db authored by Anton Nayshtut's avatar Anton Nayshtut Committed by Konrad Sztyber
Browse files

module/fsdev/aio: fsdev_aio_negotiate_opts moved



Code preparation. Trivial: fsdev_aio_negotiate_opts moved.

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent cc5f4049
Loading
Loading
Loading
Loading
+33 −33
Original line number Diff line number Diff line
@@ -498,6 +498,39 @@ lo_releasedir(struct spdk_io_channel *ch, struct spdk_fsdev_io *fsdev_io)
	return 0;
}

static int
fsdev_aio_negotiate_opts(void *ctx, struct spdk_fsdev_open_opts *opts)
{
	struct aio_fsdev *vfsdev = ctx;

	assert(opts != 0);
	assert(opts->opts_size != 0);

	UNUSED(vfsdev);

	if (opts->opts_size > offsetof(struct spdk_fsdev_open_opts, max_write)) {
		/* Set the value the aio fsdev was created with */
		opts->max_write = vfsdev->fsdev.opts.max_write;
	}

	if (opts->opts_size > offsetof(struct spdk_fsdev_open_opts, writeback_cache_enabled)) {
		if (vfsdev->fsdev.opts.writeback_cache_enabled) {
			/* The writeback_cache_enabled was enabled upon creation => we follow the opts */
			vfsdev->fsdev.opts.writeback_cache_enabled = opts->writeback_cache_enabled;
		} else {
			/* The writeback_cache_enabled was disabled upon creation => we reflect it in the opts */
			opts->writeback_cache_enabled = false;
		}
	}

	/* The AIO doesn't apply any additional restrictions, so we just accept the requested opts */
	SPDK_DEBUGLOG(fsdev_aio,
		      "aio filesystem %s: opts updated: max_write=%" PRIu32 ", writeback_cache=%" PRIu8 "\n",
		      vfsdev->fsdev.name, vfsdev->fsdev.opts.max_write, vfsdev->fsdev.opts.writeback_cache_enabled);

	return 0;
}

static int
lo_do_lookup(struct aio_fsdev *vfsdev, struct spdk_fsdev_file_object *parent_fobject,
	     const char *name, struct spdk_fsdev_file_object **pfobject,
@@ -2229,39 +2262,6 @@ fsdev_aio_get_io_channel(void *ctx)
	return spdk_get_io_channel(&g_aio_fsdev_head);
}

static int
fsdev_aio_negotiate_opts(void *ctx, struct spdk_fsdev_open_opts *opts)
{
	struct aio_fsdev *vfsdev = ctx;

	assert(opts != 0);
	assert(opts->opts_size != 0);

	UNUSED(vfsdev);

	if (opts->opts_size > offsetof(struct spdk_fsdev_open_opts, max_write)) {
		/* Set the value the aio fsdev was created with */
		opts->max_write = vfsdev->fsdev.opts.max_write;
	}

	if (opts->opts_size > offsetof(struct spdk_fsdev_open_opts, writeback_cache_enabled)) {
		if (vfsdev->fsdev.opts.writeback_cache_enabled) {
			/* The writeback_cache_enabled was enabled upon creation => we follow the opts */
			vfsdev->fsdev.opts.writeback_cache_enabled = opts->writeback_cache_enabled;
		} else {
			/* The writeback_cache_enabled was disabled upon creation => we reflect it in the opts */
			opts->writeback_cache_enabled = false;
		}
	}

	/* The AIO doesn't apply any additional restrictions, so we just accept the requested opts */
	SPDK_DEBUGLOG(fsdev_aio,
		      "aio filesystem %s: opts updated: max_write=%" PRIu32 ", writeback_cache=%" PRIu8 "\n",
		      vfsdev->fsdev.name, vfsdev->fsdev.opts.max_write, vfsdev->fsdev.opts.writeback_cache_enabled);

	return 0;
}

static void
fsdev_aio_write_config_json(struct spdk_fsdev *fsdev, struct spdk_json_write_ctx *w)
{