mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 16:47:24 +08:00
switch hardlink id from int64 to bytes
This commit is contained in:
@@ -64,7 +64,7 @@ func (entry *Entry) ToProtoEntry() *filer_pb.Entry {
|
||||
Attributes: EntryAttributeToPb(entry),
|
||||
Chunks: entry.Chunks,
|
||||
Extended: entry.Extended,
|
||||
HardLinkId: int64(entry.HardLinkId),
|
||||
HardLinkId: entry.HardLinkId,
|
||||
HardLinkCounter: entry.HardLinkCounter,
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ func (entry *Entry) EncodeAttributesAndChunks() ([]byte, error) {
|
||||
Attributes: EntryAttributeToPb(entry),
|
||||
Chunks: entry.Chunks,
|
||||
Extended: entry.Extended,
|
||||
HardLinkId: int64(entry.HardLinkId),
|
||||
HardLinkId: entry.HardLinkId,
|
||||
HardLinkCounter: entry.HardLinkCounter,
|
||||
}
|
||||
return proto.Marshal(message)
|
||||
@@ -36,7 +36,7 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
|
||||
|
||||
entry.Chunks = message.Chunks
|
||||
|
||||
entry.HardLinkId = HardLinkId(message.HardLinkId)
|
||||
entry.HardLinkId = message.HardLinkId
|
||||
entry.HardLinkCounter = message.HardLinkCounter
|
||||
|
||||
return nil
|
||||
@@ -116,7 +116,7 @@ func EqualEntry(a, b *Entry) bool {
|
||||
}
|
||||
}
|
||||
|
||||
if a.HardLinkId != b.HardLinkId {
|
||||
if !bytes.Equal(a.HardLinkId, b.HardLinkId) {
|
||||
return false
|
||||
}
|
||||
if a.HardLinkCounter != b.HardLinkCounter {
|
||||
|
@@ -10,12 +10,7 @@ import (
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
type HardLinkId int64
|
||||
func (hardLinkId HardLinkId) Key() []byte{
|
||||
bytes := make([]byte, 8)
|
||||
util.Uint64toBytes(bytes, uint64(hardLinkId))
|
||||
return bytes
|
||||
}
|
||||
type HardLinkId []byte
|
||||
|
||||
func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isFromOtherCluster bool, signatures []int32) (err error) {
|
||||
if p == "/" {
|
||||
@@ -95,7 +90,7 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
||||
hardlinkIds = append(hardlinkIds, dirHardLinkIds...)
|
||||
} else {
|
||||
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks, isFromOtherCluster, nil)
|
||||
if sub.HardLinkId != 0 {
|
||||
if len(sub.HardLinkId) != 0 {
|
||||
// hard link chunk data are deleted separately
|
||||
hardlinkIds = append(hardlinkIds, sub.HardLinkId)
|
||||
} else {
|
||||
|
@@ -135,7 +135,7 @@ func (fsw *FilerStoreWrapper) DeleteEntry(ctx context.Context, fp util.FullPath)
|
||||
if findErr == filer_pb.ErrNotFound {
|
||||
return nil
|
||||
}
|
||||
if existingEntry.HardLinkId != 0 {
|
||||
if len(existingEntry.HardLinkId) != 0 {
|
||||
// remove hard link
|
||||
if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil {
|
||||
return err
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package filer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
@@ -8,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func (fsw *FilerStoreWrapper) handleUpdateToHardLinks(ctx context.Context, entry *Entry) error {
|
||||
if entry.HardLinkId == 0 {
|
||||
if len(entry.HardLinkId) == 0 {
|
||||
return nil
|
||||
}
|
||||
// handle hard links
|
||||
@@ -23,7 +24,7 @@ func (fsw *FilerStoreWrapper) handleUpdateToHardLinks(ctx context.Context, entry
|
||||
}
|
||||
|
||||
// remove old hard link
|
||||
if err == nil && existingEntry.HardLinkId != entry.HardLinkId {
|
||||
if err == nil && bytes.Compare(existingEntry.HardLinkId, entry.HardLinkId) != 0 {
|
||||
if err = fsw.DeleteHardLink(ctx, existingEntry.HardLinkId); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -32,10 +33,10 @@ func (fsw *FilerStoreWrapper) handleUpdateToHardLinks(ctx context.Context, entry
|
||||
}
|
||||
|
||||
func (fsw *FilerStoreWrapper) setHardLink(ctx context.Context, entry *Entry) error {
|
||||
if entry.HardLinkId == 0 {
|
||||
if len(entry.HardLinkId) == 0 {
|
||||
return nil
|
||||
}
|
||||
key := entry.HardLinkId.Key()
|
||||
key := entry.HardLinkId
|
||||
|
||||
newBlob, encodeErr := entry.EncodeAttributesAndChunks()
|
||||
if encodeErr != nil {
|
||||
@@ -46,10 +47,10 @@ func (fsw *FilerStoreWrapper) setHardLink(ctx context.Context, entry *Entry) err
|
||||
}
|
||||
|
||||
func (fsw *FilerStoreWrapper) maybeReadHardLink(ctx context.Context, entry *Entry) error {
|
||||
if entry.HardLinkId == 0 {
|
||||
if len(entry.HardLinkId) == 0 {
|
||||
return nil
|
||||
}
|
||||
key := entry.HardLinkId.Key()
|
||||
key := entry.HardLinkId
|
||||
|
||||
value, err := fsw.KvGet(ctx, key)
|
||||
if err != nil {
|
||||
@@ -66,7 +67,7 @@ func (fsw *FilerStoreWrapper) maybeReadHardLink(ctx context.Context, entry *Entr
|
||||
}
|
||||
|
||||
func (fsw *FilerStoreWrapper) DeleteHardLink(ctx context.Context, hardLinkId HardLinkId) error {
|
||||
key := hardLinkId.Key()
|
||||
key := hardLinkId
|
||||
value, err := fsw.KvGet(ctx, key)
|
||||
if err == ErrKvNotFound {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user