From cbdb5025a3127d20a1e18a14bbcb0cc17be84710 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Wed, 2 Dec 2020 07:07:44 +0100 Subject: Setup xloop device with XLOOP_CONFIGURE ioctl call This feature allows the userspace tool xlosetup to completely setup a loop device with a single ioctl call, removing the in-between state where the device can be partially configured, eg. the loop device has a backing file associated with it, but is reading from the wrong offset. Besides removing the intermediate state, another big benefit of this ioctl is that XLOOP_SET_STATUS can be slow. The main reason for this slowness is that XLOOP_SET_STATUS(64) calls blk_mq_freeze_queue() to freeze the associated queue. This requires waiting for RCU. --- src/utils/include/loopdev.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/utils/include/loopdev.h') diff --git a/src/utils/include/loopdev.h b/src/utils/include/loopdev.h index 0221e6b..9fa0688 100644 --- a/src/utils/include/loopdev.h +++ b/src/utils/include/loopdev.h @@ -75,6 +75,19 @@ struct loop_info64 { uint32_t lo_file_fmt_type; }; +#ifndef LOOP_CONFIGURE +/* + * Since Linux v5.8-rc1 (commit 3448914e8cc550ba792d4ccc74471d1ca4293aae) + */ +# define LOOP_CONFIGURE 0x4C0A +struct loop_config { + uint32_t fd; + uint32_t block_size; + struct loop_info64 info; + uint64_t __reserved[8]; +}; +#endif + #define LOOPDEV_MAJOR XLOOP_MAJOR /* loop major number */ #define LOOPDEV_DEFAULT_NNODES CONFIG_BLK_DEV_XLOOP_MIN_COUNT /* default number of loop devices */ @@ -114,7 +127,7 @@ struct loopdev_cxt { unsigned int control_ok:1; /* /dev/loop-control success */ struct path_cxt *sysfs; /* pointer to /sys/dev/block// */ - struct loop_info64 info; /* for GET/SET ioctl */ + struct loop_config config; /* for GET/SET ioctl */ struct loopdev_iter iter; /* scans /sys or /dev for used/free devices */ }; -- cgit v1.2.3-55-g7522