#include "storage/aio_subsys.h"
#include "utils/guc.h"
#include "utils/guc_hooks.h"
+#include "utils/injection_point.h"
#include "utils/resowner.h"
#include "utils/wait_event_types.h"
-#ifdef USE_INJECTION_POINTS
-#include "utils/injection_point.h"
-#endif
-
static inline void pgaio_io_update_state(PgAioHandle *ioh, PgAioHandleState new_state);
static void pgaio_io_reclaim(PgAioHandle *ioh);
const IoMethodOps *pgaio_method_ops;
-/*
- * Currently there's no infrastructure to pass arguments to injection points,
- * so we instead set this up for the duration of the injection point
- * invocation. See pgaio_io_call_inj().
- */
-#ifdef USE_INJECTION_POINTS
-static PgAioHandle *pgaio_inj_cur_handle;
-#endif
-
-
-
/* --------------------------------------------------------------------------------
* Public Functions related to PgAioHandle
* --------------------------------------------------------------------------------
pgaio_io_update_state(ioh, PGAIO_HS_COMPLETED_IO);
- pgaio_io_call_inj(ioh, "aio-process-completion-before-shared");
+ INJECTION_POINT("aio-process-completion-before-shared", ioh);
pgaio_io_call_complete_shared(ioh);
return true;
}
-
-
-
-/* --------------------------------------------------------------------------------
- * Injection point support
- * --------------------------------------------------------------------------------
- */
-
-#ifdef USE_INJECTION_POINTS
-
-/*
- * Call injection point with support for pgaio_inj_io_get().
- */
-void
-pgaio_io_call_inj(PgAioHandle *ioh, const char *injection_point)
-{
- pgaio_inj_cur_handle = ioh;
-
- PG_TRY();
- {
- InjectionPointCached(injection_point, NULL);
- }
- PG_FINALLY();
- {
- pgaio_inj_cur_handle = NULL;
- }
- PG_END_TRY();
-}
-
-/*
- * Return IO associated with injection point invocation. This is only needed
- * as injection points currently don't support arguments.
- */
-PgAioHandle *
-pgaio_inj_io_get(void)
-{
- return pgaio_inj_cur_handle;
-}
-
-#endif
#include "storage/latch.h"
#include "storage/proc.h"
#include "tcop/tcopprot.h"
+#include "utils/injection_point.h"
#include "utils/memdebug.h"
#include "utils/ps_status.h"
#include "utils/wait_event.h"
* To be able to exercise the reopen-fails path, allow injection
* points to trigger a failure at this point.
*/
- pgaio_io_call_inj(ioh, "aio-worker-after-reopen");
+ INJECTION_POINT("aio-worker-after-reopen", ioh);
error_errno = 0;
error_ioh = NULL;
pgaio_io_get_state_name(ioh), \
__VA_ARGS__)
-
-#ifdef USE_INJECTION_POINTS
-
-extern void pgaio_io_call_inj(PgAioHandle *ioh, const char *injection_point);
-
-/* just for use in tests, from within injection points */
-extern PgAioHandle *pgaio_inj_io_get(void);
-
-#else
-
-#define pgaio_io_call_inj(ioh, injection_point) (void) 0
-
-/*
- * no fallback for pgaio_inj_io_get, all code using injection points better be
- * guarded by USE_INJECTION_POINTS.
- */
-
-#endif
-
-
/* Declarations for the tables of function pointers exposed by each IO method. */
extern PGDLLIMPORT const IoMethodOps pgaio_sync_ops;
extern PGDLLIMPORT const IoMethodOps pgaio_worker_ops;
void
inj_io_short_read(const char *name, const void *private_data, void *arg)
{
- PgAioHandle *ioh;
+ PgAioHandle *ioh = (PgAioHandle *) arg;
ereport(LOG,
errmsg("short read injection point called, is enabled: %d",
if (inj_io_error_state->enabled_short_read)
{
- ioh = pgaio_inj_io_get();
-
/*
* Only shorten reads that are actually longer than the target size,
* otherwise we can trigger over-reads.