Commit ebcb0d71 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Ben Walker
Browse files

lib/ftl: FTL property verbose mode



In verbose mode, user is able to get access to additional advanced
FTL properties.

Change-Id: I5905efbfef781ae52d42ea5c26a1c1bd4d904af6
Signed-off-by: default avatarMariusz Barczak <Mariusz.Barczak@solidigmtechnology.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19046


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 119935cc
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -118,8 +118,16 @@ struct spdk_ftl_conf {
	 */
	bool					prep_upgrade_on_shutdown;

	/* Hole at bytes 0x65 - 0x67. */
	uint8_t					reserved[3];
	/* In verbose mode, user is able to get access to additional advanced FTL properties.
	 *
	 * Advanced properties currently include entries, which will result in printing large amount of data
	 * (e.g. state of all bands, or chunks); or allow for receiving internal state of FTL (e.g. bands currently
	 * used for garbage collection) - live data which may be useful for profling, or debugging.
	 */
	bool					verbose_mode;

	/* Hole at bytes 0x66 - 0x67. */
	uint8_t					reserved[2];

	/* Name of base block device (zoned or non-zoned) */
	char					*base_bdev;
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ ftl_mngt_finalize_startup(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mng

	ftl_property_register(dev, "superblock_version", &dev->sb->header.version,
			      sizeof(dev->sb->header.version), NULL, NULL,
			      ftl_property_dump_uint64, NULL, NULL);
			      ftl_property_dump_uint64, NULL, NULL, false);

	/* Clear the limit applications as they're incremented incorrectly by
	 * the initialization code.
+5 −1
Original line number Diff line number Diff line
@@ -144,7 +144,11 @@ ftl_conf_init_dev(struct spdk_ftl_dev *dev, const struct spdk_ftl_conf *conf)

	ftl_property_register_bool_rw(dev, "prep_upgrade_on_shutdown", &dev->conf.prep_upgrade_on_shutdown,
				      "", "During shutdown, FTL executes all actions which "
				      "are needed for upgrade to a new version");
				      "are needed for upgrade to a new version", false);

	ftl_property_register_bool_rw(dev, "verbose_mode", &dev->conf.verbose_mode,
				      "", "In verbose mode, user is able to get access to additional "
				      "advanced FTL properties", false);

	return 0;
}
+30 −1
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ struct ftl_property {
	/* Set the FTL property */
	ftl_property_set_fn set;

	/* It indicates the property is available in verbose mode only */
	bool verbose_mode;

	/** Link to put the property to the list */
	LIST_ENTRY(ftl_property) entry;
};
@@ -67,7 +70,8 @@ ftl_property_register(struct spdk_ftl_dev *dev,
		      const char *unit, const char *desc,
		      ftl_property_dump_fn dump,
		      ftl_property_decode_fn decode,
		      ftl_property_set_fn set)
		      ftl_property_set_fn set,
		      bool verbose_mode)
{
	struct ftl_properties *properties = dev->properties;

@@ -89,6 +93,7 @@ ftl_property_register(struct spdk_ftl_dev *dev,
		prop->dump = dump;
		prop->decode = decode;
		prop->set = set;
		prop->verbose_mode = verbose_mode;
		LIST_INSERT_HEAD(&properties->list, prop, entry);
	}
}
@@ -124,6 +129,16 @@ ftl_properties_deinit(struct spdk_ftl_dev *dev)
	free(dev->properties);
}

static bool
is_property_visible(struct spdk_ftl_dev *dev, struct ftl_property *prop)
{
	if (prop->verbose_mode && !dev->conf.verbose_mode) {
		return false;
	}

	return true;
}

static void
ftl_property_dump_common_begin(const struct ftl_property *property,
			       struct spdk_json_write_ctx *w)
@@ -161,6 +176,10 @@ ftl_property_dump(struct spdk_ftl_dev *dev, struct spdk_jsonrpc_request *request

	spdk_json_write_named_array_begin(w, "properties");
	LIST_FOREACH(prop, &properties->list, entry) {
		if (!is_property_visible(dev, prop)) {
			continue;
		}

		spdk_json_write_object_begin(w);
		ftl_property_dump_common_begin(prop, w);
		prop->dump(dev, prop, w);
@@ -221,6 +240,11 @@ ftl_property_decode(struct spdk_ftl_dev *dev, const char *name, const char *valu
		return -EACCES;
	}

	if (!is_property_visible(dev, prop)) {
		FTL_ERRLOG(dev, "Property is inactive, enable verbose mode to access it, name %s.\n", name);
		return -EACCES;
	}

	assert(prop->size);
	assert(NULL == *output);

@@ -260,6 +284,11 @@ ftl_property_set(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt,
		return -EACCES;
	}

	if (!is_property_visible(dev, prop)) {
		FTL_ERRLOG(dev, "Property is inactive, enable verbose mode to access it, name %s\n", name);
		return -EACCES;
	}

	prop->set(dev, mngt, prop, value, value_size);
	return 0;
}
+6 −3
Original line number Diff line number Diff line
@@ -88,13 +88,15 @@ typedef void (*ftl_property_set_fn)(struct spdk_ftl_dev *dev, struct ftl_mngt_pr
 * @param dump The function to dump the property to the JSON RPC request
 * @param decode The function to decode a new value of the property
 * @param set The function to execute the property setting procedure
 * @param verbose_mode The property is available in verbose mode only
 */
void ftl_property_register(struct spdk_ftl_dev *dev,
			   const char *name, void *value, size_t size,
			   const char *unit, const char *desc,
			   ftl_property_dump_fn dump,
			   ftl_property_decode_fn decode,
			   ftl_property_set_fn set);
			   ftl_property_set_fn set,
			   bool verbose_mode);

/**
 * @brief Dump FTL properties to the JSON request
@@ -152,13 +154,14 @@ void ftl_property_set_generic(struct spdk_ftl_dev *dev, struct ftl_mngt_process
 * @param value The pointer to the boolean value of the property
 * @param unit The property unit
 * @param desc The property description
 * @param verbose_mode The verbose mode flag
 */
static inline void
ftl_property_register_bool_rw(struct spdk_ftl_dev *dev, const char *name, bool *value,
			      const char *unit, const char *desc)
			      const char *unit, const char *desc, bool verbose_mode)
{
	ftl_property_register(dev, name, value, sizeof(*value), unit, desc, ftl_property_dump_bool,
			      ftl_property_decode_bool, ftl_property_set_generic);
			      ftl_property_decode_bool, ftl_property_set_generic, verbose_mode);
}

#endif
Loading