Thin provisioning
Eric Sandeen, Lukáš Czerner, Mike Snitzer, and Dmitry Monakhov discussed thin provisioning support in Linux at the 2014 LSFMM Summit. Thin provisioning is a way for a storage device to pretend to have more space than it actually does, relying on the administrator to add more storage "just in time". For the most part, Snitzer said, thin provisioning using the device mapper (dm-thin) is pretty stable. But there are some performance issues that they would like to address.
One of the problem areas in terms of performance is that the block allocator from dm-thin is "dumb". Multi-threaded writes end up on the disk with bad ordering that leads to bad read performance. What Snitzer would like to do is to split writes into different lists, one per thin volume, then sort the struct bio entries in the list. He doesn't want to add a full-on bio-based elevator, but does want to get some better locality to improve performance.
As part of that, Snitzer would like to have a way to ask an XFS or ext4 filesystem about its allocation group boundaries. Those could be used as a hint for block allocation in the thin provisioning code. But Joel Becker wondered why that information was needed, and why the logical block address (LBA) information was not enough. Dave Chinner agreed, noting that the filesystem relies on the LBA information to make its allocation decisions.
Becker suggested that what Snitzer was really after is the "borders at which we stop caring about locality"—basically the distance between two writes that would not be considered "close". Snitzer said that he is looking for something concrete that dm-thin can use. Ted Ts'o thought that both ext4 and XFS could provide some values that would be reasonable for dm-thin to use to determine locality.
Monakhov noted that filesystems spread out their data throughout their volume, which causes problems for dm-thin. The problem, Chinner said, is that the filesystem needs to tell the block layer where the free space is. Chinner said that one dm-thin developer was asking for information on how the filesystem will spread things out, while another was asking that filesystems not spread things out.
There needs to be an automatic way for the filesystem to tell the block layer about free space, Ts'o said. Discard is one mechanism to do so, but Roland Dreier said that most administrators are disabling discard. In addition, TRIM command (that tells devices about unused blocks) support has been spotty, Martin Petersen said. Unqueued TRIM didn't work early on, but works now, while queued TRIM support is being added and is not yet working. Unqueued TRIM requires stopping all other activity on the device, so performance suffers; queued TRIM was added to the standard relatively recently to avoid that problem.
Someone said that fstrim (offline discard) is probably the right solution for most workloads. Snitzer said that mount -o discard (online discard) could be used with dm-thin. It passes the discard information to dm-thin, which doesn't (necessarily) pass it down to the storage device. That gives dm-thin the information it needs on free space, however.
Another problem for dm-thin is that fallocate() will reserve space, but that isn't getting passed down to the block layer. The result is that even after a successful fallocate() call, applications can still get ENOSPC—exactly the outcome fallocate() was meant to avoid. Ts'o said that can't be solved without handing the block allocation job to the block layer. But, Chinner said, it is not necessarily right for dm-thin to handle allocation.
Sandeen noted another problem: filesystems act differently when they run out of space. For XFS, it will keep trying to write any pending metadata, while ext4 and Btrfs do not. Chinner explained that XFS already has the metadata on stable storage in the log, so it retries to see if the administrator wants to add more storage.
More generally, there are different classes of errors for the different filesystems, Chinner said. Some are considered transient errors by some filesystems, which leads to different behavior between them. But, Monakhov noted, "user space goes crazy" when it gets an ENOSPC.
Monakhov went on to suggest (as he had in a lightning talk the previous day) that there be a standard way for the filesystem to report errors to the logs. James Bottomley said the obvious way to do that was with a uevent from the virtual filesystem (VFS). There is general agreement that some kind of event framework is needed, he said, but "we don't know who is going to do it, or when it will be done". As with many of the LSFMM sessions, few conclusions were drawn though some progress was clearly made.
[ Thanks to the Linux Foundation for travel support to attend LSFMM. ]
| Index entries for this article | |
|---|---|
| Conference | Storage, Filesystem, and Memory-Management Summit/2014 |
The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:
Note: you can avoid this step in the future by logging into your LWN account.
