+ bool need_flush = false;
+
+ if (mtx_trylock(&extctx->lock) != thrd_success) {
+ /*
+ * The other context could be locked in etna_flush() and
+ * stuck waiting for the resource lock, so release the
+ * resource lock here, let etna_flush() finish, and try
+ * again.
+ */
+ mtx_unlock(&rsc->lock);
+ thrd_yield();
+ goto again;
+ }