[elbe-devel] [PATCH] fstab: retry losetup, when it with EAGAIN
Torben Hohn
torben.hohn at linutronix.de
Thu Apr 30 12:11:55 CEST 2020
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 @@
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
More information about the elbe-devel
mailing list