In the original kernel, this function returned the disk offset where the page would be stored but this offset was used as an identifier for the swapped page. Only the swap code used it to access the disk. As we need to know the size of the compressed page before assigning it to a disk block (it has to fit in it), we will return an index to the virtual_swap_info table. To the rest of the kernel, this function behaves as always and the system believes that the swap partition is a larger one.
To return this index, the system searches for a free entry in the virtual_swap_info array. A given entry is free when no process is using it (swap_map[i] == 0) and when there are no operations remaining to be done on this page ( virtual_swap_info[i].rw_remaining == 0).
Another important issues is that the system cannot return an index unless it is sure that there will be enough disk space to keep the page. For this reason, the system will always assume the worst case. Until it knows the real compressed size, the system will assume that the page needs a full disk block to be stored. As soon as the system knows its real size, it will update this information.