[elbe-devel] [PATCH] fstab: retry losetup, when it with EAGAIN

Olivier Dion dion at linutronix.de
Thu Apr 30 18:14:43 CEST 2020


On Thu, 30 Apr 2020, Torben Hohn <torben.hohn at linutronix.de> wrote:
> After deleting a loppback device, it might still have allocated pages,
> and may not be ready to be reinitialized. losetup returns 1 in
> this case.
>
> The issue seems to be fixed by this patch:
> https://lore.kernel.org/patchwork/patch/1075391/
>
> which has not found its way into the current debian kernel yet.
>
> However, since the patch suggest this is about dirty pages, we call
> sync, and retry.
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
>  elbepack/fstab.py | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/elbepack/fstab.py b/elbepack/fstab.py
> index 970d508bb..ee23121a6 100644
> --- a/elbepack/fstab.py
> +++ b/elbepack/fstab.py
> @@ -7,7 +7,7 @@

Shouldn't this patch apply to losetup for grub devices too?

>  
>  import os
>  
> -from elbepack.shellhelper import do, get_command_out
> +from elbepack.shellhelper import do, get_command_out, CommandError
>  
>  
>  def get_mtdnum(xml, label):
> @@ -141,8 +141,16 @@ class fstabentry(object):
>          self.number = '{}{}'.format(disk.type, ppart.number)
>  
>      def losetup(self):
> -        loopdev = get_command_out('losetup --offset %d --sizelimit %d --find --show "%s"' %
> -                                  (self.offset, self.size, self.filename))
> +        cmd = ('losetup --offset %d --sizelimit %d --find --show "%s"' %
> +               (self.offset, self.size, self.filename))
> +        try:
> +            loopdev = get_command_out(cmd)
> +        except CommandError as e:
> +            if e.returncode != 1:
> +                raise
> +            do('sync')
> +            loopdev = get_command_out(cmd)
> +
>          return loopdev.rstrip('\n')
>  
>      def tuning(self, loopdev):
> -- 
> 2.20.1
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
-- 
Olivier Dion
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen



More information about the elbe-devel mailing list