/* This drops destination transaction entry from appropriate network state tree and drops related reference counter. It is possible that transaction will be freed here if its reference counter hits zero. Destination transaction entry will be freed.  */
void netfs_trans_drop_last(struct netfs_trans *t, struct netfs_state *st)
/* This drops destination transaction entry from appropriate network state tree and drops related reference counter. It is possible that transaction will be freed here if its reference counter hits zero. Destination transaction entry will be freed.  */
void netfs_trans_drop_last(struct netfs_trans *t, struct netfs_state *st)
{
	struct netfs_trans_dst *dst, *tmp, *ret;
	spin_lock(&t->dst_lock);
	ret = list_entry(t->dst_list.prev, struct netfs_trans_dst, trans_entry);
	if (ret->state != st) {
		ret = NULL;
		list_for_each_entry_safe(dst, tmp, &t->dst_list, trans_entry) {
			if (dst->state == st) {
				ret = dst;
				list_del_init(&dst->trans_entry);
				break;
			}
		}
	} else {
		list_del(&ret->trans_entry);
	}
	spin_unlock(&t->dst_lock);
	if (ret)
		netfs_trans_remove_dst(ret);
}