mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cephfs: Avoid hanging lock in volume mutex lock
This patch allows to avoid hanging mutex lock scenario when fscrypt fails to unlock. Prevents uncessary delays Signed-off-by: Sunnatillo <sunnat.samadov@est.tech>
This commit is contained in:
parent
c875483f8a
commit
d46b7d7ff4
@ -164,13 +164,8 @@ func maybeUnlockFileEncryption(
|
||||
}
|
||||
log.DebugLog(ctx, "Lock successfully created for volume ID %s", volID)
|
||||
|
||||
log.DebugLog(ctx, "cephfs: unlocking fscrypt on volume %q path %s", volID, stagingTargetPath)
|
||||
err = fscrypt.Unlock(ctx, volOptions.Encryption, stagingTargetPath, string(volID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ret, err := ioctx.Unlock(string(volID), lockName, lockCookie)
|
||||
defer func() {
|
||||
ret, unlockErr := ioctx.Unlock(string(volID), lockName, lockCookie)
|
||||
switch ret {
|
||||
case 0:
|
||||
log.DebugLog(ctx, "Lock %s successfully released ", lockName)
|
||||
@ -178,7 +173,14 @@ func maybeUnlockFileEncryption(
|
||||
log.DebugLog(ctx, "Lock is not held by the specified %s, %s pair", lockCookie, lockName)
|
||||
default:
|
||||
log.ErrorLog(ctx, "Failed to release following lock, this will lead to orphan lock %s: %v",
|
||||
lockName, err)
|
||||
lockName, unlockErr)
|
||||
}
|
||||
}()
|
||||
|
||||
log.DebugLog(ctx, "cephfs: unlocking fscrypt on volume %q path %s", volID, stagingTargetPath)
|
||||
err = fscrypt.Unlock(ctx, volOptions.Encryption, stagingTargetPath, string(volID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user