[PATCH 0/9] loop: Micro-refactoring set_loop() and add LOOP_CONFIGURE

Xiaoming Ni nixiaoming at huawei.com
Fri Nov 18 01:01:49 UTC 2022


LOOP_CONFIGURE is added to Linux 5.8

This allows userspace to completely setup a loop device with a single
ioctl, 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.

https://lwn.net/Articles/820408/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3448914e8cc5

To facilitate the addition of new functions, the code of set_loop() is micro-refactored.

LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0):
	function                                             old     new   delta
	set_loop                                             760     626    -134
	------------------------------------------------------------------------------
	(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-134)           Total: -134 bytes
else
	function                                             old     new   delta
	set_loop                                             760     703     -57
	------------------------------------------------------------------------------
	(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-57)             Total: -57 bytes

----

Xiaoming Ni (9):
  loop:refactor: extract subfunction open_file()
  loop:refactor: extract subfunction get_next_free_loop()
  loop:refactor: del close_and_try_next_loopN
  loop:refactor: extract subfunction set_loop_info()
  loop:refactor: extract subfunction set_loop_configure()
  loop:refactor: Use a structure to reduce parameters
  loop:refactor: Extract subfunction do_stat_and_mknod()
  loop:refactor: extract subfunction set_loop_dev()
  loop: Add LOOP_CONFIGURE ioctl

 libbb/loop.c | 275 +++++++++++++++++++++++++++++++--------------------
 1 file changed, 170 insertions(+), 105 deletions(-)

-- 
2.27.0



More information about the busybox mailing list