
static void io_rsrc_node_ref_zero(struct percpu_ref *ref)
{
	struct fixed_rsrc_ref_node *ref_node;
	struct fixed_rsrc_data *data;
	struct io_ring_ctx *ctx;
	bool first_add = false;
	int delay = HZ;

	ref_node = container_of(ref, struct fixed_rsrc_ref_node, refs);
	data = ref_node->rsrc_data;
	ctx = data->ctx;

	io_rsrc_ref_lock(ctx);
	ref_node->done = true;

	while (!list_empty(&ctx->rsrc_ref_list)) {
		ref_node = list_first_entry(&ctx->rsrc_ref_list,
					struct fixed_rsrc_ref_node, node);
		/* recycle ref nodes in order */
		if (!ref_node->done)
			break;
		list_del(&ref_node->node);
		first_add |= llist_add(&ref_node->llist, &ctx->rsrc_put_llist);
	}
	io_rsrc_ref_unlock(ctx);

	if (percpu_ref_is_dying(&data->refs))
		delay = 0;

	if (!delay)
		mod_delayed_work(system_wq, &ctx->rsrc_put_work, 0);
	else if (first_add)
		queue_delayed_work(system_wq, &ctx->rsrc_put_work, delay);

static void io_rsrc_node_ref_zero(struct percpu_ref *ref)
{
	struct fixed_rsrc_ref_node *ref_node;
	struct fixed_rsrc_data *data;
	struct io_ring_ctx *ctx;
	bool first_add = false;
	int delay = HZ;

	ref_node = container_of(ref, struct fixed_rsrc_ref_node, refs);
	data = ref_node->rsrc_data;
	ctx = data->ctx;

	io_rsrc_ref_lock(ctx);
	ref_node->done = true;

	while (!list_empty(&ctx->rsrc_ref_list)) {
		ref_node = list_first_entry(&ctx->rsrc_ref_list,
					struct fixed_rsrc_ref_node, node);
		 
		if (!ref_node->done)
			break;
		list_del(&ref_node->node);
		first_add |= llist_add(&ref_node->llist, &ctx->rsrc_put_llist);
	}
	io_rsrc_ref_unlock(ctx);

	if (percpu_ref_is_dying(&data->refs))
		delay = 0;

	if (!delay)
		mod_delayed_work(system_wq, &ctx->rsrc_put_work, 0);
	else if (first_add)
		queue_delayed_work(system_wq, &ctx->rsrc_put_work, delay);