diff options
author | Ming Lei | 2015-11-17 15:32:47 +0100 |
---|---|---|
committer | Karel Zak | 2015-11-19 11:27:36 +0100 |
commit | 64c3bb3cb7ead2faa97aa6d400d65f392df3dba8 (patch) | |
tree | c4d0d92ea1f494c3d981d3614b79b1f033f9a75f /lib/loopdev.c | |
parent | blkid: don't mark zfs as RAID (diff) | |
download | kernel-qcow2-util-linux-64c3bb3cb7ead2faa97aa6d400d65f392df3dba8.tar.gz kernel-qcow2-util-linux-64c3bb3cb7ead2faa97aa6d400d65f392df3dba8.tar.xz kernel-qcow2-util-linux-64c3bb3cb7ead2faa97aa6d400d65f392df3dba8.zip |
losetup: support ioctl cmd of LOOP_SET_DIRECT_IO
From v4.4, linux kernel starts to support direct I/O and
AIO to backing file for loop driver, so allow losetup to
enable the feature by using LOOP_SET_DIRECT_IO ioctl cmd.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Diffstat (limited to 'lib/loopdev.c')
-rw-r--r-- | lib/loopdev.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c index fe047cdcf..ff99dd444 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -1315,6 +1315,24 @@ int loopcxt_set_capacity(struct loopdev_cxt *lc) return 0; } +int loopcxt_set_dio(struct loopdev_cxt *lc, unsigned long use_dio) +{ + int fd = loopcxt_get_fd(lc); + + if (fd < 0) + return -EINVAL; + + /* Kernels prior to v4.4 don't support this ioctl */ + if (ioctl(fd, LOOP_SET_DIRECT_IO, use_dio) < 0) { + int rc = -errno; + DBG(CXT, ul_debugobj(lc, "LOOP_SET_DIRECT_IO failed: %m")); + return rc; + } + + DBG(CXT, ul_debugobj(lc, "direct io set")); + return 0; +} + int loopcxt_delete_device(struct loopdev_cxt *lc) { int fd = loopcxt_get_fd(lc); |