Skip to content

Commit

Permalink
sed: only re-read partition table after unlock.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gjoyce-ibm authored and igaw committed May 13, 2024
1 parent 962b197 commit fac45ce
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions plugins/sed/sedopal_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand All @@ -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;
}

Expand Down

0 comments on commit fac45ce

Please sign in to comment.