Bruce
4 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
522 additions and
496 deletions
-
weed/pb/volume_server.proto
-
weed/pb/volume_server_pb/volume_server.pb.go
-
weed/storage/store.go
-
weed/storage/volume.go
-
weed/storage/volume_loading.go
|
|
@ -480,6 +480,7 @@ message VolumeInfo { |
|
|
|
uint32 BytesOffset = 4; |
|
|
|
int64 dat_file_size = 5; // used for EC encoded volumes to store the original file size |
|
|
|
uint64 DestroyTime = 6; // used to record the destruction time of ec volume |
|
|
|
bool read_only = 7; |
|
|
|
} |
|
|
|
|
|
|
|
// tiered storage |
|
|
|
|
|
@ -477,6 +477,7 @@ func (s *Store) MarkVolumeReadonly(i needle.VolumeId) error { |
|
|
|
} |
|
|
|
v.noWriteLock.Lock() |
|
|
|
v.noWriteOrDelete = true |
|
|
|
v.PersistReadOnly(true) |
|
|
|
v.noWriteLock.Unlock() |
|
|
|
return nil |
|
|
|
} |
|
|
@ -488,6 +489,7 @@ func (s *Store) MarkVolumeWritable(i needle.VolumeId) error { |
|
|
|
} |
|
|
|
v.noWriteLock.Lock() |
|
|
|
v.noWriteOrDelete = false |
|
|
|
v.PersistReadOnly(false) |
|
|
|
v.noWriteLock.Unlock() |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
@ -48,6 +48,7 @@ type Volume struct { |
|
|
|
isCompacting bool |
|
|
|
isCommitCompacting bool |
|
|
|
|
|
|
|
volumeInfoRWLock sync.RWMutex |
|
|
|
volumeInfo *volume_server_pb.VolumeInfo |
|
|
|
location *DiskLocation |
|
|
|
|
|
|
@ -358,3 +359,10 @@ func (v *Volume) IsReadOnly() bool { |
|
|
|
defer v.noWriteLock.RUnlock() |
|
|
|
return v.noWriteOrDelete || v.noWriteCanDelete || v.location.isDiskSpaceLow |
|
|
|
} |
|
|
|
|
|
|
|
func (v *Volume) PersistReadOnly(readOnly bool) { |
|
|
|
v.volumeInfoRWLock.RLock() |
|
|
|
defer v.volumeInfoRWLock.RUnlock() |
|
|
|
v.volumeInfo.ReadOnly = readOnly |
|
|
|
v.SaveVolumeInfo() |
|
|
|
} |
|
|
@ -43,6 +43,11 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind |
|
|
|
|
|
|
|
hasVolumeInfoFile := v.maybeLoadVolumeInfo() |
|
|
|
|
|
|
|
if v.volumeInfo.ReadOnly && !v.HasRemoteFile() { |
|
|
|
// this covers the case where the volume is marked as read-only and has no remote file
|
|
|
|
v.noWriteOrDelete = true |
|
|
|
} |
|
|
|
|
|
|
|
if v.HasRemoteFile() { |
|
|
|
v.noWriteCanDelete = true |
|
|
|
v.noWriteOrDelete = false |
|
|
|