chrislu
2 years ago
13 changed files with 74 additions and 62 deletions
-
40weed/mount/filehandle.go
-
2weed/mount/filehandle_map.go
-
2weed/mount/filehandle_read.go
-
42weed/mount/locked_entry.go
-
6weed/mount/weedfs_attr.go
-
8weed/mount/weedfs_dir_lookup.go
-
2weed/mount/weedfs_dir_read.go
-
4weed/mount/weedfs_file_copy_range.go
-
4weed/mount/weedfs_file_lseek.go
-
5weed/mount/weedfs_file_sync.go
-
2weed/mount/weedfs_file_write.go
-
7weed/mount/weedfs_rename.go
-
12weed/mount/weedfs_xattr.go
@ -0,0 +1,42 @@ |
|||||
|
package mount |
||||
|
|
||||
|
import ( |
||||
|
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" |
||||
|
"sync" |
||||
|
) |
||||
|
|
||||
|
type LockedEntry struct { |
||||
|
*filer_pb.Entry |
||||
|
sync.RWMutex |
||||
|
} |
||||
|
|
||||
|
func (le *LockedEntry) GetEntry() *filer_pb.Entry { |
||||
|
le.RLock() |
||||
|
defer le.RUnlock() |
||||
|
return le.Entry |
||||
|
} |
||||
|
|
||||
|
func (le *LockedEntry) SetEntry(entry *filer_pb.Entry) { |
||||
|
le.Lock() |
||||
|
defer le.Unlock() |
||||
|
le.Entry = entry |
||||
|
} |
||||
|
|
||||
|
func (le *LockedEntry) UpdateEntry(fn func(entry *filer_pb.Entry)) *filer_pb.Entry { |
||||
|
le.Lock() |
||||
|
defer le.Unlock() |
||||
|
fn(le.Entry) |
||||
|
return le.Entry |
||||
|
} |
||||
|
|
||||
|
func (le *LockedEntry) GetChunks() []*filer_pb.FileChunk { |
||||
|
le.RLock() |
||||
|
defer le.RUnlock() |
||||
|
return le.Entry.Chunks |
||||
|
} |
||||
|
|
||||
|
func (le *LockedEntry) AppendChunks(newChunks []*filer_pb.FileChunk) { |
||||
|
le.Lock() |
||||
|
defer le.Unlock() |
||||
|
le.Entry.Chunks = append(le.Entry.Chunks, newChunks...) |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue