diff --git a/backport-Close-fd-if-it-fails-to-read-the-device.patch b/backport-Close-fd-if-it-fails-to-read-the-device.patch new file mode 100644 index 0000000000000000000000000000000000000000..dee5c8ec46bcf487bb93384cc08b04f5a5d1461e --- /dev/null +++ b/backport-Close-fd-if-it-fails-to-read-the-device.patch @@ -0,0 +1,33 @@ +From 1383e61211aaeee106b29f2e408fdda8f92370df Mon Sep 17 00:00:00 2001 +From: Nijin Ashok +Date: Tue, 15 Sep 2020 18:15:32 +0530 +Subject: [PATCH] Close fd if it fails to read the device + +If the device is unmapped from the storage side, the os.read will +fail with i/o error. However, it's not closing the fd and any +process using the blivet module will hold the device indefeniely. This +prevents administrator from removing the device from multipath +layer. + +Conflict:NA +Reference:https://github.com/storaged-project/blivet/commit/1383e61211aaeee106b29f2e408fdda8f92370df +--- + blivet/devicelibs/edd.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py +index a661f73..f64c4e5 100644 +--- a/blivet/devicelibs/edd.py ++++ b/blivet/devicelibs/edd.py +@@ -679,6 +679,8 @@ def collect_mbrs(devices, root=None): + testdata_log.debug("device %s data[440:443] raised %s", path, e) + log.error("edd: could not read mbrsig from disk %s: %s", + dev.name, str(e)) ++ if fd: ++ os.close(fd) + continue + + mbrsig_str = "0x%08x" % mbrsig +-- +2.23.0 + diff --git a/backport-Fix-UnboundLocalError.patch b/backport-Fix-UnboundLocalError.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e0bea721f1b2c68c8b8f9476ae5c5958f7e7386 --- /dev/null +++ b/backport-Fix-UnboundLocalError.patch @@ -0,0 +1,39 @@ +From 7709298a2b5ab0eb3a2990bb2fd4ead7d1b29674 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 18 Sep 2020 13:18:06 +0200 +Subject: [PATCH] edd: Fix UnboundLocalError when trying to close fd in + collect_mbrs + +The "fd" variable is not defined when the "os.open" fails (e.g. +when the device we try to open doesn't exist). + +Conflict:NA +Reference:https://github.com/storaged-project/blivet/commit/7709298a2b5ab0eb3a2990bb2fd4ead7d1b29674 +--- + blivet/devicelibs/edd.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/blivet/devicelibs/edd.py b/blivet/devicelibs/edd.py +index f64c4e5..67b7186 100644 +--- a/blivet/devicelibs/edd.py ++++ b/blivet/devicelibs/edd.py +@@ -664,6 +664,7 @@ def collect_mbrs(devices, root=None): + """ + mbr_dict = {} + for dev in devices: ++ fd = -1 + try: + path = util.Path("/dev", root=root) + dev.name + fd = os.open(path.ondisk, os.O_RDONLY) +@@ -679,7 +680,7 @@ def collect_mbrs(devices, root=None): + testdata_log.debug("device %s data[440:443] raised %s", path, e) + log.error("edd: could not read mbrsig from disk %s: %s", + dev.name, str(e)) +- if fd: ++ if fd > 0: + os.close(fd) + continue + +-- +2.23.0 + diff --git a/python-blivet.spec b/python-blivet.spec index c376422e2f1f721e43848e19d1b0d3bd08c71f38..82810fc79e91b28d10ca9aa32513f9b78b8e96e1 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -3,7 +3,7 @@ Name: python-blivet Version: 3.2.2 -Release: 4 +Release: 5 Epoch: 1 Summary: A python module for system storage configuration License: LGPLv2+ @@ -21,6 +21,8 @@ Patch0: 0001-force-lvm-plugin.patch Patch1: Fix-name-resolution-for-MD-devices-and-partitions-on.patch Patch9000: fix-the-long-hostname.patch Patch6000: backport-Account-for-pmspare-grow-when-adjusting-thinpool-metadata.patch +Patch6001: backport-Close-fd-if-it-fails-to-read-the-device.patch +Patch6002: backport-Fix-UnboundLocalError.patch %description The python-blivet package is a python module for examining and modifying @@ -121,6 +123,12 @@ make PYTHON=%{__python2} DESTDIR=%{buildroot} install %doc README %changelog +* Tue Jun 08 2021 liuyumeng - 3.2.2-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Close fd if fails to read the device,Fix UnboundLocalError + * Tue May 25 2021 yanan - 3.2.2-4 - Type:bugfix - ID:NA