Skip to content

Commit fac45ce

Browse files
gjoyce-ibmigaw
authored andcommitted
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>
1 parent 962b197 commit fac45ce

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

plugins/sed/sedopal_cmd.c

+14-13
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,21 @@ int sedopal_cmd_lock(int fd)
251251
*/
252252
int sedopal_cmd_unlock(int fd)
253253
{
254+
int rc;
255+
256+
rc = sedopal_lock_unlock(fd, OPAL_RW);
257+
258+
/*
259+
* If the unlock was successful, force a re-read of the
260+
* partition table. Return rc of unlock operation.
261+
*/
262+
if (rc == 0) {
263+
if (ioctl(fd, BLKRRPART, 0) != 0)
264+
fprintf(stderr,
265+
"Warning: failed re-reading partition\n");
266+
}
254267

255-
return sedopal_lock_unlock(fd, OPAL_RW);
268+
return rc;
256269
}
257270

258271
/*
@@ -275,18 +288,6 @@ int sedopal_lock_unlock(int fd, int lock_state)
275288
if (rc != 0)
276289
fprintf(stderr,
277290
"Error: failed locking or unlocking - %d\n", rc);
278-
279-
/*
280-
* If the unlock was successful, force a re-read of the
281-
* partition table.
282-
*/
283-
if (rc == 0) {
284-
rc = ioctl(fd, BLKRRPART, 0);
285-
if (rc != 0)
286-
fprintf(stderr,
287-
"Error: failed re-reading partition\n");
288-
}
289-
290291
return rc;
291292
}
292293

0 commit comments

Comments
 (0)