seastar
seastar copied to clipboard
Implement removal of files via blocks discarding according to configured bandwidth
To avoid I/O latency spikes that are caused by too many TRIM requests issued to the drive over a short period of time when the filesystem is mounted with the online discard option and many files are removed, the file_discard_queue class is used.
Instead of relying on the unlink operation that trims all extents of a file at once, the approach that utilizes blocks discarding at a given pace is used.
When a user wants to remove a file, then remove_file_via_blocks_discarding() needs to be called. Its main purpose is to enqueue the work into file_discard_queue object associated with the device on which the file is stored.
Reactor will invoke file_discard_queue::try_discard_blocks() function via poller. The function checks if the bandwidth of discards allows another block to be discarded. If the bandwidth is available, then the discard is performed.
The described approach ensures, that the amount of removed data over time remains at the configured level.
Refs: https://github.com/scylladb/scylladb/issues/14940