[elbe-devel] [PATCH] fstab: Fix issue #254

Torben Hohn torben.hohn at linutronix.de
Thu Mar 26 10:20:17 CET 2020


On Tue, Mar 24, 2020 at 12:34:11AM +0100, Bastian Germann wrote:
> Please use a more describing subject.
> 
> Am 24.03.20 um 00:35 schrieb Olivier Dion:
> > See <https://github.com/Linutronix/elbe/issues/254>.
> 
> Write a line "Fixes #254." instead to trigger the GitHub issue management.

Errm, lets do this correctly.

losetup has the -f option, which will make it seek for a "free" loop
device.

This will allow 2 jobs running in parallel sometime in the future.

I am also very interested in the cause of Issue 254.
i mean, we call losetup -d /dev/loop0 and afterwards, its busy ?
what is happening here ? is there some code running asyncronously,
that is still freeing the device ?


> 
> > 
> > Before setting up a loop device, poll it to see if it's busy and wait
> > until it's not.
> > 
> > Signed-off-by: Olivier Dion <dion at linutronix.de>
> > ---
> >  elbepack/fstab.py | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/elbepack/fstab.py b/elbepack/fstab.py
> > index 94f11d2f..3d9fd112 100644
> > --- a/elbepack/fstab.py
> > +++ b/elbepack/fstab.py
> > @@ -6,8 +6,10 @@
> >  # SPDX-License-Identifier: GPL-3.0-or-later
> >  
> >  import os
> > +import time
> > +import logging
> >  
> > -from elbepack.shellhelper import do
> > +from elbepack.shellhelper import do, get_command_out
> >  
> >  
> >  def get_mtdnum(xml, label):
> > @@ -141,6 +143,16 @@ class fstabentry(object):
> >          self.number = '{}{}'.format(disk.type, ppart.number)
> >  
> >      def losetup(self, loopdev):
> > +        while True:
> > +            is_busy = get_command_out("losetup -l /dev/%s -n --raw | "
> > +                                      "cut -d' ' -f6" % loopdev)
> > +
> > +            if is_busy == "\n" or is_busy == "":
> > +                break
> > +
> > +            time.sleep(0.1)
> > +            logging.warning("Device /dev/%s is busy .. retrying", loopdev)
> > +
> >          do('losetup -o%d --sizelimit %d /dev/%s "%s"' %
> >             (self.offset, self.size, loopdev, self.filename))
> >  
> > 
> 
> _______________________________________________
> 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