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/kernel/xloop_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/xloop_main.c b/src/kernel/xloop_main.c index de1fc3d..441282a 100644 --- a/src/kernel/xloop_main.c +++ b/src/kernel/xloop_main.c @@ -877,11 +877,6 @@ static int xloop_configure(struct xloop_device *xlo, fmode_t mode, if (error) goto out_unlock; - error = xloop_file_fmt_init(xlo->xlo_fmt, - config->info.xlo_file_fmt_type); - if (error) - goto out_unlock; - set_device_ro(bdev, (xlo->xlo_flags & XLO_FLAGS_READ_ONLY) != 0); xlo->use_dio = xlo->xlo_flags & XLO_FLAGS_DIRECT_IO; @@ -890,6 +885,11 @@ static int xloop_configure(struct xloop_device *xlo, fmode_t mode, xlo->old_gfp_mask = mapping_gfp_mask(mapping); mapping_set_gfp_mask(mapping, xlo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); + error = xloop_file_fmt_init(xlo->xlo_fmt, + config->info.xlo_file_fmt_type); + if (error) + goto out_unlock; + if (!(xlo->xlo_flags & XLO_FLAGS_READ_ONLY) && file->f_op->fsync) blk_queue_write_cache(xlo->xlo_queue, true, false); -- cgit v1.2.3-55-g7522