* [PATCH 1/3] dm vdo: slight cleanup of UDS error codes
2024-01-27 2:42 [PATCH 0/3] dm vdo: various error code improvements Matthew Sakai
@ 2024-01-27 2:42 ` Matthew Sakai
2024-01-27 2:42 ` [PATCH 2/3] dm vdo: rename uds_map_to_system_error to uds_status_to_errno Matthew Sakai
2024-01-27 2:42 ` [PATCH 3/3] dm vdo: rename vdo_map_to_system_error to vdo_status_to_errno Matthew Sakai
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Sakai @ 2024-01-27 2:42 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
No need to increment each UDS_ error code manually (relative to
UDS_ERROR_CODE_BASE).
Also, remove unused PRP_BLOCK_START and PRP_BLOCK_END.
Lastly, UDS_SUCCESS and VDO_SUCCESS are used interchangeably; so best
to explicitly set VDO_SUCCESS equal to UDS_SUCCESS.
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/errors.h | 35 ++++++++++++++++----------------
drivers/md/dm-vdo/status-codes.h | 4 +---
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/drivers/md/dm-vdo/errors.h b/drivers/md/dm-vdo/errors.h
index 0129fa37d8d8..c37f198a159c 100644
--- a/drivers/md/dm-vdo/errors.h
+++ b/drivers/md/dm-vdo/errors.h
@@ -15,43 +15,42 @@
enum uds_status_codes {
/* Successful return */
UDS_SUCCESS = 0,
-
/* Used as a base value for reporting internal errors */
UDS_ERROR_CODE_BASE = 1024,
/* Index overflow */
- UDS_OVERFLOW = UDS_ERROR_CODE_BASE + 0,
+ UDS_OVERFLOW = UDS_ERROR_CODE_BASE,
/* Invalid argument passed to internal routine */
- UDS_INVALID_ARGUMENT = UDS_ERROR_CODE_BASE + 1,
+ UDS_INVALID_ARGUMENT,
/* UDS data structures are in an invalid state */
- UDS_BAD_STATE = UDS_ERROR_CODE_BASE + 2,
+ UDS_BAD_STATE,
/* Attempt to enter the same name into an internal structure twice */
- UDS_DUPLICATE_NAME = UDS_ERROR_CODE_BASE + 3,
+ UDS_DUPLICATE_NAME,
/* An assertion failed */
- UDS_ASSERTION_FAILED = UDS_ERROR_CODE_BASE + 4,
+ UDS_ASSERTION_FAILED,
/* A request has been queued for later processing (not an error) */
- UDS_QUEUED = UDS_ERROR_CODE_BASE + 5,
+ UDS_QUEUED,
/* A problem has occurred with a buffer */
- UDS_BUFFER_ERROR = UDS_ERROR_CODE_BASE + 6,
+ UDS_BUFFER_ERROR,
/* No directory was found where one was expected */
- UDS_NO_DIRECTORY = UDS_ERROR_CODE_BASE + 7,
+ UDS_NO_DIRECTORY,
/* This error range has already been registered */
- UDS_ALREADY_REGISTERED = UDS_ERROR_CODE_BASE + 8,
+ UDS_ALREADY_REGISTERED,
/* Attempt to read or write data outside the valid range */
- UDS_OUT_OF_RANGE = UDS_ERROR_CODE_BASE + 9,
+ UDS_OUT_OF_RANGE,
/* Could not load modules */
- UDS_EMODULE_LOAD = UDS_ERROR_CODE_BASE + 10,
+ UDS_EMODULE_LOAD,
/* The index session is disabled */
- UDS_DISABLED = UDS_ERROR_CODE_BASE + 11,
+ UDS_DISABLED,
/* Unknown error */
- UDS_UNKNOWN_ERROR = UDS_ERROR_CODE_BASE + 12,
+ UDS_UNKNOWN_ERROR,
/* The index configuration or volume format is no longer supported */
- UDS_UNSUPPORTED_VERSION = UDS_ERROR_CODE_BASE + 13,
+ UDS_UNSUPPORTED_VERSION,
/* Some index structure is corrupt */
- UDS_CORRUPT_DATA = UDS_ERROR_CODE_BASE + 14,
+ UDS_CORRUPT_DATA,
/* No index state found */
- UDS_NO_INDEX = UDS_ERROR_CODE_BASE + 15,
+ UDS_NO_INDEX,
/* Attempt to access incomplete index save data */
- UDS_INDEX_NOT_SAVED_CLEANLY = UDS_ERROR_CODE_BASE + 16,
+ UDS_INDEX_NOT_SAVED_CLEANLY,
/* One more than the last UDS_INTERNAL error code */
UDS_ERROR_CODE_LAST,
/* One more than the last error this block will ever use */
diff --git a/drivers/md/dm-vdo/status-codes.h b/drivers/md/dm-vdo/status-codes.h
index c5da37ec8b55..9e0126a83c6b 100644
--- a/drivers/md/dm-vdo/status-codes.h
+++ b/drivers/md/dm-vdo/status-codes.h
@@ -12,14 +12,12 @@ enum {
UDS_BLOCK_SIZE = UDS_ERROR_CODE_BLOCK_END - UDS_ERROR_CODE_BASE,
VDO_BLOCK_START = UDS_ERROR_CODE_BLOCK_END,
VDO_BLOCK_END = VDO_BLOCK_START + UDS_BLOCK_SIZE,
- PRP_BLOCK_START = VDO_BLOCK_END,
- PRP_BLOCK_END = PRP_BLOCK_START + UDS_BLOCK_SIZE,
};
/* VDO-specific status codes. */
enum vdo_status_codes {
/* successful result */
- VDO_SUCCESS,
+ VDO_SUCCESS = UDS_SUCCESS,
/* base of all VDO errors */
VDO_STATUS_CODE_BASE = VDO_BLOCK_START,
/* we haven't written this yet */
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] dm vdo: rename uds_map_to_system_error to uds_status_to_errno
2024-01-27 2:42 [PATCH 0/3] dm vdo: various error code improvements Matthew Sakai
2024-01-27 2:42 ` [PATCH 1/3] dm vdo: slight cleanup of UDS error codes Matthew Sakai
@ 2024-01-27 2:42 ` Matthew Sakai
2024-01-27 2:42 ` [PATCH 3/3] dm vdo: rename vdo_map_to_system_error to vdo_status_to_errno Matthew Sakai
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Sakai @ 2024-01-27 2:42 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/errors.c | 2 +-
drivers/md/dm-vdo/errors.h | 2 +-
drivers/md/dm-vdo/index-layout.c | 4 ++--
drivers/md/dm-vdo/index-session.c | 20 ++++++++++----------
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/md/dm-vdo/errors.c b/drivers/md/dm-vdo/errors.c
index d19504a1445e..e8599599a377 100644
--- a/drivers/md/dm-vdo/errors.c
+++ b/drivers/md/dm-vdo/errors.c
@@ -219,7 +219,7 @@ const char *uds_string_error_name(int errnum, char *buf, size_t buflen)
* system-generated value (such as -EIO), or an internal UDS status code. The result will be a
* negative errno value.
*/
-int uds_map_to_system_error(int error)
+int uds_status_to_errno(int error)
{
char error_name[UDS_MAX_ERROR_NAME_SIZE];
char error_message[UDS_MAX_ERROR_MESSAGE_SIZE];
diff --git a/drivers/md/dm-vdo/errors.h b/drivers/md/dm-vdo/errors.h
index c37f198a159c..cf15d7243204 100644
--- a/drivers/md/dm-vdo/errors.h
+++ b/drivers/md/dm-vdo/errors.h
@@ -71,7 +71,7 @@ const char * __must_check uds_string_error(int errnum, char *buf, size_t buflen)
const char *uds_string_error_name(int errnum, char *buf, size_t buflen);
-int uds_map_to_system_error(int error);
+int uds_status_to_errno(int error);
int uds_register_error_block(const char *block_name, int first_error,
int last_reserved_error, const struct error_info *infos,
diff --git a/drivers/md/dm-vdo/index-layout.c b/drivers/md/dm-vdo/index-layout.c
index 4dffa82a3c43..6446a1f58641 100644
--- a/drivers/md/dm-vdo/index-layout.c
+++ b/drivers/md/dm-vdo/index-layout.c
@@ -267,13 +267,13 @@ int uds_compute_index_size(const struct uds_parameters *parameters, u64 *index_s
result = uds_make_configuration(parameters, &index_config);
if (result != UDS_SUCCESS) {
uds_log_error_strerror(result, "cannot compute index size");
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
result = compute_sizes(index_config, &sizes);
uds_free_configuration(index_config);
if (result != UDS_SUCCESS)
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
*index_size = sizes.total_size;
return UDS_SUCCESS;
diff --git a/drivers/md/dm-vdo/index-session.c b/drivers/md/dm-vdo/index-session.c
index 615c7b840d7b..73c2927f74ce 100644
--- a/drivers/md/dm-vdo/index-session.c
+++ b/drivers/md/dm-vdo/index-session.c
@@ -210,7 +210,7 @@ static void handle_callbacks(struct uds_request *request)
if (request->status == UDS_SUCCESS)
update_session_stats(request);
- request->status = uds_map_to_system_error(request->status);
+ request->status = uds_status_to_errno(request->status);
request->callback(request);
release_index_session(index_session);
}
@@ -276,7 +276,7 @@ int uds_create_index_session(struct uds_index_session **session)
return -EINVAL;
}
- return uds_map_to_system_error(make_empty_index_session(session));
+ return uds_status_to_errno(make_empty_index_session(session));
}
static int __must_check start_loading_index_session(struct uds_index_session *index_session)
@@ -374,7 +374,7 @@ int uds_open_index(enum uds_open_index_type open_type,
result = start_loading_index_session(session);
if (result != UDS_SUCCESS)
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
session->parameters = *parameters;
format_dev_t(name, parameters->bdev->bd_dev);
@@ -386,7 +386,7 @@ int uds_open_index(enum uds_open_index_type open_type,
get_open_type_string(open_type));
finish_loading_index_session(session, result);
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
static void wait_for_no_requests_in_progress(struct uds_index_session *index_session)
@@ -470,7 +470,7 @@ int uds_suspend_index_session(struct uds_index_session *session, bool save)
uds_unlock_mutex(&session->request_mutex);
if (no_work)
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
if (rebuilding)
suspend_rebuild(session);
@@ -484,7 +484,7 @@ int uds_suspend_index_session(struct uds_index_session *session, bool save)
session->state |= IS_FLAG_SUSPENDED;
uds_broadcast_cond(&session->request_cond);
uds_unlock_mutex(&session->request_mutex);
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
static int replace_device(struct uds_index_session *session, struct block_device *bdev)
@@ -536,7 +536,7 @@ int uds_resume_index_session(struct uds_index_session *session,
session->state &= ~IS_FLAG_WAITING;
uds_broadcast_cond(&session->request_cond);
uds_unlock_mutex(&session->request_mutex);
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
}
@@ -635,7 +635,7 @@ int uds_close_index(struct uds_index_session *index_session)
}
uds_unlock_mutex(&index_session->request_mutex);
if (result != UDS_SUCCESS)
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
uds_log_debug("Closing index");
wait_for_no_requests_in_progress(index_session);
@@ -646,7 +646,7 @@ int uds_close_index(struct uds_index_session *index_session)
index_session->state &= ~IS_FLAG_CLOSING;
uds_broadcast_cond(&index_session->request_cond);
uds_unlock_mutex(&index_session->request_mutex);
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
/* This will save and close an open index before destroying the session. */
@@ -702,7 +702,7 @@ int uds_destroy_index_session(struct uds_index_session *index_session)
uds_destroy_mutex(&index_session->request_mutex);
uds_log_debug("Destroyed index session");
uds_free(index_session);
- return uds_map_to_system_error(result);
+ return uds_status_to_errno(result);
}
/* Wait until all callbacks for index operations are complete. */
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] dm vdo: rename vdo_map_to_system_error to vdo_status_to_errno
2024-01-27 2:42 [PATCH 0/3] dm vdo: various error code improvements Matthew Sakai
2024-01-27 2:42 ` [PATCH 1/3] dm vdo: slight cleanup of UDS error codes Matthew Sakai
2024-01-27 2:42 ` [PATCH 2/3] dm vdo: rename uds_map_to_system_error to uds_status_to_errno Matthew Sakai
@ 2024-01-27 2:42 ` Matthew Sakai
2 siblings, 0 replies; 4+ messages in thread
From: Matthew Sakai @ 2024-01-27 2:42 UTC (permalink / raw)
To: dm-devel; +Cc: Mike Snitzer, Matthew Sakai
From: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Susan LeGendre-McGhee <slegendr@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
---
drivers/md/dm-vdo/data-vio.c | 2 +-
drivers/md/dm-vdo/dm-vdo-target.c | 10 +++++-----
drivers/md/dm-vdo/status-codes.c | 4 ++--
drivers/md/dm-vdo/status-codes.h | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/md/dm-vdo/data-vio.c b/drivers/md/dm-vdo/data-vio.c
index 711396e7a77d..7d8100f29e13 100644
--- a/drivers/md/dm-vdo/data-vio.c
+++ b/drivers/md/dm-vdo/data-vio.c
@@ -274,7 +274,7 @@ static void acknowledge_data_vio(struct data_vio *data_vio)
{
struct vdo *vdo = vdo_from_data_vio(data_vio);
struct bio *bio = data_vio->user_bio;
- int error = vdo_map_to_system_error(data_vio->vio.completion.result);
+ int error = vdo_status_to_errno(data_vio->vio.completion.result);
if (bio == NULL)
return;
diff --git a/drivers/md/dm-vdo/dm-vdo-target.c b/drivers/md/dm-vdo/dm-vdo-target.c
index fcba50d8d088..e2e60a29e873 100644
--- a/drivers/md/dm-vdo/dm-vdo-target.c
+++ b/drivers/md/dm-vdo/dm-vdo-target.c
@@ -1117,7 +1117,7 @@ static int vdo_message(struct dm_target *ti, unsigned int argc, char **argv,
vdo_write_stats(vdo, result_buffer, maxlen);
result = 1;
} else {
- result = vdo_map_to_system_error(process_vdo_message(vdo, argc, argv));
+ result = vdo_status_to_errno(process_vdo_message(vdo, argc, argv));
}
uds_unregister_thread_device_id();
@@ -1613,7 +1613,7 @@ static int construct_new_vdo_registered(struct dm_target *ti, unsigned int argc,
if (result != VDO_SUCCESS) {
release_instance(instance);
free_device_config(config);
- return vdo_map_to_system_error(result);
+ return vdo_status_to_errno(result);
}
return VDO_SUCCESS;
@@ -1852,7 +1852,7 @@ static int prepare_to_modify(struct dm_target *ti, struct device_config *config,
if (result != VDO_SUCCESS) {
if (result == VDO_PARAMETER_MISMATCH) {
/*
- * If we don't trap this case, vdo_map_to_system_error() will remap
+ * If we don't trap this case, vdo_status_to_errno() will remap
* it to -EIO, which is misleading and ahistorical.
*/
result = -EINVAL;
@@ -1892,7 +1892,7 @@ static int update_existing_vdo(const char *device_name, struct dm_target *ti,
result = prepare_to_modify(ti, config, vdo);
if (result != VDO_SUCCESS) {
free_device_config(config);
- return vdo_map_to_system_error(result);
+ return vdo_status_to_errno(result);
}
set_device_config(ti, vdo, config);
@@ -2850,7 +2850,7 @@ static int vdo_preresume(struct dm_target *ti)
if ((result == VDO_PARAMETER_MISMATCH) || (result == VDO_INVALID_ADMIN_STATE))
result = -EINVAL;
uds_unregister_thread_device_id();
- return vdo_map_to_system_error(result);
+ return vdo_status_to_errno(result);
}
static void vdo_resume(struct dm_target *ti)
diff --git a/drivers/md/dm-vdo/status-codes.c b/drivers/md/dm-vdo/status-codes.c
index 33b1de29b205..b4d7eb7f94ff 100644
--- a/drivers/md/dm-vdo/status-codes.c
+++ b/drivers/md/dm-vdo/status-codes.c
@@ -87,7 +87,7 @@ int vdo_register_status_codes(void)
}
/**
- * vdo_map_to_system_error() - Given an error code, return a value we can return to the OS.
+ * vdo_status_to_errno() - Given an error code, return a value we can return to the OS.
* @error: The error code to convert.
*
* The input error code may be a system-generated value (such as -EIO), an errno macro used in our
@@ -96,7 +96,7 @@ int vdo_register_status_codes(void)
*
* Return: A system error code value.
*/
-int vdo_map_to_system_error(int error)
+int vdo_status_to_errno(int error)
{
char error_name[UDS_MAX_ERROR_NAME_SIZE];
char error_message[UDS_MAX_ERROR_MESSAGE_SIZE];
diff --git a/drivers/md/dm-vdo/status-codes.h b/drivers/md/dm-vdo/status-codes.h
index 9e0126a83c6b..5d1e8bbe54b4 100644
--- a/drivers/md/dm-vdo/status-codes.h
+++ b/drivers/md/dm-vdo/status-codes.h
@@ -105,6 +105,6 @@ extern const struct error_info vdo_status_list[];
int vdo_register_status_codes(void);
-int vdo_map_to_system_error(int error);
+int vdo_status_to_errno(int error);
#endif /* VDO_STATUS_CODES_H */
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread