Fix sed locking of namespaces

Resolves: RHEL-38372

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
This commit is contained in:
Maurizio Lombardi 2024-08-06 10:53:33 +02:00
parent 885a96f17b
commit c2d8437fca
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,63 @@
From fac45ce03315479b0d30e71316e669d9d4ffb31c Mon Sep 17 00:00:00 2001
From: Greg Joyce <gjoyce@linux.ibm.com>
Date: Fri, 10 May 2024 14:23:11 -0500
Subject: [PATCH] sed: only re-read partition table after unlock.
The partition table was being re-read after both lock and
unlock operations. The re-read would fail with an error
message after a lock since the partition was no longer readable.
Signed-off-by: Greg Joyce <gjoyce@linux.ibm.com>
---
plugins/sed/sedopal_cmd.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/plugins/sed/sedopal_cmd.c b/plugins/sed/sedopal_cmd.c
index 21ebd360c219..221f62b15186 100644
--- a/plugins/sed/sedopal_cmd.c
+++ b/plugins/sed/sedopal_cmd.c
@@ -251,8 +251,21 @@ int sedopal_cmd_lock(int fd)
*/
int sedopal_cmd_unlock(int fd)
{
+ int rc;
+
+ rc = sedopal_lock_unlock(fd, OPAL_RW);
+
+ /*
+ * If the unlock was successful, force a re-read of the
+ * partition table. Return rc of unlock operation.
+ */
+ if (rc == 0) {
+ if (ioctl(fd, BLKRRPART, 0) != 0)
+ fprintf(stderr,
+ "Warning: failed re-reading partition\n");
+ }
- return sedopal_lock_unlock(fd, OPAL_RW);
+ return rc;
}
/*
@@ -275,18 +288,6 @@ int sedopal_lock_unlock(int fd, int lock_state)
if (rc != 0)
fprintf(stderr,
"Error: failed locking or unlocking - %d\n", rc);
-
- /*
- * If the unlock was successful, force a re-read of the
- * partition table.
- */
- if (rc == 0) {
- rc = ioctl(fd, BLKRRPART, 0);
- if (rc != 0)
- fprintf(stderr,
- "Error: failed re-reading partition\n");
- }
-
return rc;
}
--
2.43.0

View File

@ -3,7 +3,7 @@
Name: nvme-cli
Version: 2.9.1
Release: 4%{?dist}
Release: 5%{?dist}
Summary: NVMe management command line interface
License: GPL-2.0-only
@ -15,6 +15,7 @@ Patch0: 0001-Revert-fabrics-Use-corresponding-hostid-when-hostnqn.patch
Patch1: 0002-nvme-telemetry-report-the-correct-error-if-the-ioctl.patch
# https://issues.redhat.com/browse/RHEL-37601
Patch2: nvme-cli-2.10-nbft-discovery.patch
Patch3: 0003-sed-only-re-read-partition-table-after-unlock.patch
BuildRequires: meson >= 0.50.0
BuildRequires: gcc gcc-c++
@ -39,6 +40,7 @@ nvme-cli provides NVM-Express user space tooling for Linux.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir}
@ -99,6 +101,9 @@ if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then
fi
%changelog
* Tue Aug 06 2024 Maurizio Lombardi <mlombard@redhat.com> - 2.9.1-5
- Fix RHEL-38372
* Wed Jul 24 2024 Tomas Bzatek <tbzatek@redhat.com> - 2.9.1-4
- Backport NBFT discovery support (RHEL-37601)