@@ -1118,14 +1118,14 @@ func (c *Controller) ReadAt(b []byte, off int64) (int, error) {
1118
1118
func (c * Controller ) UnmapAt (length uint32 , off int64 ) (int , error ) {
1119
1119
// TODO: Need to fail unmap requests
1120
1120
// if the volume is purging snapshots or creating backups.
1121
- c .RLock ()
1121
+ c .Lock ()
1122
1122
1123
1123
if off < 0 || off + int64 (length ) > c .size {
1124
1124
// This is a legitimate error (which is handled by tgt/liblonghorn at a higher level). Since tgt/liblonghorn
1125
1125
// does not actually print the error, print it here.
1126
1126
err := fmt .Errorf ("EOF: unmap of %v bytes at offset %v is beyond volume size %v" , length , off , c .size )
1127
1127
logrus .WithError (err ).Error ("Failed to unmap" )
1128
- c .RUnlock ()
1128
+ c .Unlock ()
1129
1129
return 0 , err
1130
1130
}
1131
1131
if c .hasWOReplica () {
@@ -1134,7 +1134,7 @@ func (c *Controller) UnmapAt(length uint32, off int64) (int, error) {
1134
1134
// will remain paused for the entire duration of the rebuild.
1135
1135
err := fmt .Errorf ("cannot unmap %v bytes at offset %v while rebuilding is in progress" , length , off )
1136
1136
logrus .WithError (err ).Warn ("Failed to unmap" )
1137
- c .RUnlock ()
1137
+ c .Unlock ()
1138
1138
return 0 , nil
1139
1139
}
1140
1140
if c .isExpanding {
@@ -1143,13 +1143,13 @@ func (c *Controller) UnmapAt(length uint32, off int64) (int, error) {
1143
1143
// trimmed, so it can try again.
1144
1144
err := fmt .Errorf ("cannot unmap %v bytes at offset %v while expansion in is progress" , length , off )
1145
1145
logrus .WithError (err ).Error ("Failed to unmap" )
1146
- c .RUnlock ()
1146
+ c .Unlock ()
1147
1147
return 0 , err
1148
1148
}
1149
1149
1150
1150
// startTime := time.Now()
1151
1151
n , err := c .backend .UnmapAt (length , off )
1152
- c .RUnlock ()
1152
+ c .Unlock ()
1153
1153
if err != nil {
1154
1154
return n , c .handleError (err )
1155
1155
}
0 commit comments