/*
* It's a bit ugly, but right now the easiest place to put the execution
- * of shared completion callbacks is this function, as we need to execute
+ * of local completion callbacks is this function, as we need to execute
* local callbacks just before reclaiming at multiple callsites.
*/
if (ioh->state == PGAIO_HS_COMPLETED_SHARED)
{
- pgaio_io_call_complete_local(ioh);
+ PgAioResult local_result;
+
+ local_result = pgaio_io_call_complete_local(ioh);
pgaio_io_update_state(ioh, PGAIO_HS_COMPLETED_LOCAL);
+
+ if (ioh->report_return)
+ {
+ ioh->report_return->result = local_result;
+ ioh->report_return->target_data = ioh->target_data;
+ }
}
pgaio_debug_io(DEBUG4, ioh,
ioh->distilled_result.error_data,
ioh->result);
- /* if the IO has been defined, we might need to do more work */
+ /* if the IO has been defined, it's on the in-flight list, remove */
if (ioh->state != PGAIO_HS_HANDED_OUT)
- {
dclist_delete_from(&pgaio_my_backend->in_flight_ios, &ioh->node);
- if (ioh->report_return)
- {
- ioh->report_return->result = ioh->distilled_result;
- ioh->report_return->target_data = ioh->target_data;
- }
- }
-
if (ioh->resowner)
{
ResourceOwnerForgetAioHandle(ioh->resowner, &ioh->resowner_node);
* Internal function which invokes ->complete_local for all the registered
* callbacks.
*
+ * Returns ioh->distilled_result after, possibly, being modified by local
+ * callbacks.
+ *
* XXX: It'd be nice to deduplicate with pgaio_io_call_complete_shared().
*/
-void
+PgAioResult
pgaio_io_call_complete_local(PgAioHandle *ioh)
{
PgAioResult result;
/*
* Note that we don't save the result in ioh->distilled_result, the local
- * callback's result should not ever matter to other waiters.
+ * callback's result should not ever matter to other waiters. However, the
+ * local backend does care, so we return the result as modified by local
+ * callbacks, which then can be passed to ioh->report_return->result.
*/
pgaio_debug_io(DEBUG3, ioh,
- "after local completion: distilled result: (status %s, id %u, error_data %d, result %d), raw_result: %d",
+ "after local completion: result: (status %s, id %u, error_data %d, result %d), raw_result: %d",
pgaio_result_status_string(result.status),
result.id, result.error_data, result.result,
ioh->result);
END_CRIT_SECTION();
+
+ return result;
}
/* aio_callback.c */
extern void pgaio_io_call_stage(PgAioHandle *ioh);
extern void pgaio_io_call_complete_shared(PgAioHandle *ioh);
-extern void pgaio_io_call_complete_local(PgAioHandle *ioh);
+extern PgAioResult pgaio_io_call_complete_local(PgAioHandle *ioh);
/* aio_io.c */
extern void pgaio_io_perform_synchronously(PgAioHandle *ioh);