[dm-devel] [PATCH] kpartx: free loop device after listing partitions

Martin Wilck martin.wilck at suse.com
Fri Mar 12 15:53:30 UTC 2021


On Wed, 2021-02-24 at 00:05 -0600, Benjamin Marzinski wrote:
> If "kpartx -l" is run on a file that doesn't already have a loop
> device
> associated with it, it will create a loop device to run the command.
> Starting with da59d15c6 ("Fix loopback file with kpartx -av"), it
> will
> not free the loop device when exitting. This is because it checks if
> the
> the file it stat()ed is a regular file, before freeing the loop
> device.
> However, after da59d15c6, stat() is rerun on the loop device itself,
> so
> the check fails.  There is no need to check this, if loopcreated is
> true, then the file will be a kpartx created loop device, and should
> be
> freed.
> 
> Also, keep kpartx from printing that the loop device has been removed
> at normal verbosity.
> 
> Fixes: da59d15c6 ("Fix loopback file with kpartx -av")
> Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>

Reviewed-by: Martin Wilck <mwilck at suse.com>





More information about the dm-devel mailing list