mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 06:57:23 +08:00
properly lock file.entry object
fix https://github.com/chrislusf/seaweedfs/issues/1882
This commit is contained in:
@@ -35,15 +35,20 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// update old file to hardlink mode
|
||||
if len(oldFile.entry.HardLinkId) == 0 {
|
||||
oldFile.entry.HardLinkId = append(util.RandomBytes(16), HARD_LINK_MARKER)
|
||||
oldFile.entry.HardLinkCounter = 1
|
||||
oldEntry := oldFile.getEntry()
|
||||
if oldEntry == nil {
|
||||
return nil, fuse.EIO
|
||||
}
|
||||
oldFile.entry.HardLinkCounter++
|
||||
|
||||
// update old file to hardlink mode
|
||||
if len(oldEntry.HardLinkId) == 0 {
|
||||
oldEntry.HardLinkId = append(util.RandomBytes(16), HARD_LINK_MARKER)
|
||||
oldEntry.HardLinkCounter = 1
|
||||
}
|
||||
oldEntry.HardLinkCounter++
|
||||
updateOldEntryRequest := &filer_pb.UpdateEntryRequest{
|
||||
Directory: oldFile.dir.FullPath(),
|
||||
Entry: oldFile.entry,
|
||||
Entry: oldEntry,
|
||||
Signatures: []int32{dir.wfs.signature},
|
||||
}
|
||||
|
||||
@@ -53,11 +58,11 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f
|
||||
Entry: &filer_pb.Entry{
|
||||
Name: req.NewName,
|
||||
IsDirectory: false,
|
||||
Attributes: oldFile.entry.Attributes,
|
||||
Chunks: oldFile.entry.Chunks,
|
||||
Extended: oldFile.entry.Extended,
|
||||
HardLinkId: oldFile.entry.HardLinkId,
|
||||
HardLinkCounter: oldFile.entry.HardLinkCounter,
|
||||
Attributes: oldEntry.Attributes,
|
||||
Chunks: oldEntry.Chunks,
|
||||
Extended: oldEntry.Extended,
|
||||
HardLinkId: oldEntry.HardLinkId,
|
||||
HardLinkCounter: oldEntry.HardLinkCounter,
|
||||
},
|
||||
Signatures: []int32{dir.wfs.signature},
|
||||
}
|
||||
|
Reference in New Issue
Block a user