/* Find transaction based on its generation number, bump its reference counter, so that none could free it under us, drop from the trees and lists and drop reference counter. When it hits zero (when all destinations replied and all timeout handled by async scanning code), completion will be called and transaction will be freed.  */
static int pohmelfs_transaction_response(struct netfs_state *st)
/* Find transaction based on its generation number, bump its reference counter, so that none could free it under us, drop from the trees and lists and drop reference counter. When it hits zero (when all destinations replied and all timeout handled by async scanning code), completion will be called and transaction will be freed.  */
static int pohmelfs_transaction_response(struct netfs_state *st)
{
	struct netfs_trans_dst *dst;
	struct netfs_trans *t = NULL;
	struct netfs_cmd *cmd = &st->cmd;
	short err = (signed)cmd->ext;
	mutex_lock(&st->trans_lock);
	dst = netfs_trans_search(st, cmd->start);
	if (dst) {
		netfs_trans_remove_nolock(dst, st);
		t = dst->trans;
	}
	mutex_unlock(&st->trans_lock);
	if (!t) {
		printk("%s: failed to find transaction: start: %llu: id: %llu, size: %u, ext: %u.\n",
				__func__, cmd->start, cmd->id, cmd->size, cmd->ext);
		err = -EINVAL;
		goto out;
	}
	t->result = err;
	netfs_trans_drop_dst_nostate(dst);
out:
	wake_up(&st->psb->wait);
	return err;
}