loop: add direct-io support
Support the LOOP_SET_DIRECT_IO ioctl, which alows us to control whether or not a loopback device should perform its own buffering or rely on the one done by the underlying backing file. Enabling this should improve both throughput and memory consumption, it is not currently hooked up as more testing would be required.
This commit is contained in:
parent
70f2ec7227
commit
79b2f37cbc
1 changed files with 14 additions and 0 deletions
|
|
@ -207,6 +207,20 @@ class Loop:
|
|||
info.lo_flags &= ~self.LO_FLAGS_PARTSCAN
|
||||
fcntl.ioctl(self.fd, self.LOOP_SET_STATUS64, info)
|
||||
|
||||
def set_direct_io(self, dio=True):
|
||||
"""Set the direct-IO property on the loopback device
|
||||
|
||||
Enabling direct IO allows one to avoid double caching, which
|
||||
should improve performance and memory usage.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
dio : bool, optional
|
||||
Whether or not to enable direct IO (default is True)
|
||||
"""
|
||||
|
||||
fcntl.ioctl(self.fd, self.LOOP_SET_DIRECT_IO, dio)
|
||||
|
||||
def mknod(self, dir_fd=None, mode=0o600):
|
||||
"""Create a secondary device node
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue