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

Torben Hohn torben.hohn at linutronix.de
Thu May 7 14:10:05 CEST 2020


On Thu, Apr 30, 2020 at 12:14:43PM -0400, Olivier Dion wrote:
> 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?

indeed.

> 
> >  
> >  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
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list