diff options
| author | James Hartig <fastest963@gmail.com> | 2020-08-19 11:42:56 -0400 |
|---|---|---|
| committer | James Hartig <fastest963@gmail.com> | 2020-08-19 11:42:56 -0400 |
| commit | 3ccfa4c6adf967b550defea72c3691956e541e26 (patch) | |
| tree | 6ae6e995774fb4f7a554213202ff3300bf2b5bf8 /weed/storage/volume.go | |
| parent | 3b4b1d4a77f6ac57e35a47316cce1621010f0d7f (diff) | |
| download | seaweedfs-3ccfa4c6adf967b550defea72c3691956e541e26.tar.xz seaweedfs-3ccfa4c6adf967b550defea72c3691956e541e26.zip | |
Added VolumeMarkWritable and VolumeStatus grpc methods
This is necessary for copy to mark as read-only and then restore the
original state afterwards.
Diffstat (limited to 'weed/storage/volume.go')
| -rw-r--r-- | weed/storage/volume.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/weed/storage/volume.go b/weed/storage/volume.go index 73fdb417d..2d46fbcdf 100644 --- a/weed/storage/volume.go +++ b/weed/storage/volume.go @@ -27,6 +27,7 @@ type Volume struct { needleMapKind NeedleMapType noWriteOrDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete noWriteCanDelete bool // if readonly, either noWriteOrDelete or noWriteCanDelete + noWriteLock sync.RWMutex hasRemoteFile bool // if the volume has a remote file MemoryMapMaxSizeMb uint32 @@ -58,6 +59,8 @@ func NewVolume(dirname string, collection string, id needle.VolumeId, needleMapK } func (v *Volume) String() string { + v.noWriteLock.RLock() + defer v.noWriteLock.RUnlock() return fmt.Sprintf("Id:%v, dir:%s, Collection:%s, dataFile:%v, nm:%v, noWrite:%v canDelete:%v", v.Id, v.dir, v.Collection, v.DataBackend, v.nm, v.noWriteOrDelete || v.noWriteCanDelete, v.noWriteCanDelete) } @@ -245,5 +248,7 @@ func (v *Volume) RemoteStorageNameKey() (storageName, storageKey string) { } func (v *Volume) IsReadOnly() bool { + v.noWriteLock.RLock() + defer v.noWriteLock.RUnlock() return v.noWriteOrDelete || v.noWriteCanDelete || v.location.isDiskSpaceLow } |
