Once the system wants to swap out a page, it compresses the page and tries to write it into the cache. Performing this operation, we might find that there is not enough free space to cache this new page. This means that all buffers are dirty (and have not been sent to the disk) and that all of them have less free space than the size of the compressed page. It is important to notice that the system will never split a compressed page among several buffers. When the system runs out of free space in the compressed cache, it performs a cleaning operation. Once it is done, at least one buffer will not be dirty and the system will be able to use it to put the new compressed page.
As we mentioned when describing the free operation, there are cases where a page could not be freed because there was a write operation still pending. If this is the last pending write operation and the page is marked as to be freed, the system will free the page after the write has been finished. The same steps as in the original free operation are taken.