/* This returns the number of stats entries in the snapshot and only copies them using the iter if there is enough space for them. The caller passes in the global stats so that we can size and copy while holding the lock.  */
unsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter, unsigned int avail)
/* This returns the number of stats entries in the snapshot and only copies them using the iter if there is enough space for them. The caller passes in the global stats so that we can size and copy while holding the lock.  */
unsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter, unsigned int avail)
{
	struct rds_transport *trans;
	unsigned int total = 0;
	unsigned int part;
	int i;
	rds_info_iter_unmap(iter);
	down_read(&rds_trans_sem);
	for (i = 0; i < RDS_TRANS_COUNT; i++)
	{
		trans = transports[i];
		if (!trans || !trans->stats_info_copy)
			continue;
		part = trans->stats_info_copy(iter, avail);
		avail -= min(avail, part);
		total += part;
	}
	up_read(&rds_trans_sem);
	return total;
}