mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-01-18 14:41:31 +08:00
always keep the manifest list of chunks
This commit is contained in:
parent
c1d1677a28
commit
51346a5930
@ -253,12 +253,7 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
|
|||||||
glog.V(4).Infof("%s chunks %d: %v [%d,%d)", fh.f.fullpath(), i, chunk.GetFileIdString(), chunk.Offset, chunk.Offset+int64(chunk.Size))
|
glog.V(4).Infof("%s chunks %d: %v [%d,%d)", fh.f.fullpath(), i, chunk.GetFileIdString(), chunk.Offset, chunk.Offset+int64(chunk.Size))
|
||||||
}
|
}
|
||||||
|
|
||||||
var nonManifestChunks []*filer_pb.FileChunk
|
manifestChunks, nonManifestChunks := filer2.SeparateManifestChunks(fh.f.entry.Chunks)
|
||||||
for _, c := range fh.f.entry.Chunks {
|
|
||||||
if !c.IsChunkManifest {
|
|
||||||
nonManifestChunks = append(nonManifestChunks, c)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chunks, _ := filer2.CompactFileChunks(filer2.LookupFn(fh.f.wfs), nonManifestChunks)
|
chunks, _ := filer2.CompactFileChunks(filer2.LookupFn(fh.f.wfs), nonManifestChunks)
|
||||||
chunks, manifestErr := filer2.MaybeManifestize(fh.f.wfs.saveDataAsChunk(fh.f.dir.FullPath()), chunks)
|
chunks, manifestErr := filer2.MaybeManifestize(fh.f.wfs.saveDataAsChunk(fh.f.dir.FullPath()), chunks)
|
||||||
@ -266,7 +261,7 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
|
|||||||
// not good, but should be ok
|
// not good, but should be ok
|
||||||
glog.V(0).Infof("MaybeManifestize: %v", manifestErr)
|
glog.V(0).Infof("MaybeManifestize: %v", manifestErr)
|
||||||
}
|
}
|
||||||
fh.f.entry.Chunks = append(chunks, nonManifestChunks...)
|
fh.f.entry.Chunks = append(chunks, manifestChunks...)
|
||||||
fh.f.entryViewCache = nil
|
fh.f.entryViewCache = nil
|
||||||
|
|
||||||
if err := filer_pb.CreateEntry(client, request); err != nil {
|
if err := filer_pb.CreateEntry(client, request); err != nil {
|
||||||
|
@ -241,22 +241,20 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FilerServer) cleanupChunks(existingEntry *filer2.Entry, newEntry *filer_pb.Entry) (chunks, garbage []*filer_pb.FileChunk, err error) {
|
func (fs *FilerServer) cleanupChunks(existingEntry *filer2.Entry, newEntry *filer_pb.Entry) (chunks, garbage []*filer_pb.FileChunk, err error) {
|
||||||
chunks = newEntry.Chunks
|
|
||||||
|
|
||||||
// remove old chunks if not included in the new ones
|
// remove old chunks if not included in the new ones
|
||||||
if existingEntry != nil {
|
if existingEntry != nil {
|
||||||
garbage, err = filer2.MinusChunks(fs.lookupFileId, existingEntry.Chunks, newEntry.Chunks)
|
garbage, err = filer2.MinusChunks(fs.lookupFileId, existingEntry.Chunks, newEntry.Chunks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return chunks, nil, fmt.Errorf("MinusChunks: %v", err)
|
return newEntry.Chunks, nil, fmt.Errorf("MinusChunks: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// files with manifest chunks are usually large and append only, skip calculating covered chunks
|
// files with manifest chunks are usually large and append only, skip calculating covered chunks
|
||||||
var coveredChunks []*filer_pb.FileChunk
|
manifestChunks, nonManifestChunks := filer2.SeparateManifestChunks(newEntry.Chunks)
|
||||||
if !filer2.HasChunkManifest(newEntry.Chunks) {
|
|
||||||
chunks, coveredChunks = filer2.CompactFileChunks(fs.lookupFileId, newEntry.Chunks)
|
chunks, coveredChunks := filer2.CompactFileChunks(fs.lookupFileId, nonManifestChunks)
|
||||||
garbage = append(garbage, coveredChunks...)
|
garbage = append(garbage, coveredChunks...)
|
||||||
}
|
|
||||||
|
|
||||||
chunks, err = filer2.MaybeManifestize(fs.saveAsChunk(
|
chunks, err = filer2.MaybeManifestize(fs.saveAsChunk(
|
||||||
newEntry.Attributes.Replication,
|
newEntry.Attributes.Replication,
|
||||||
@ -268,6 +266,9 @@ func (fs *FilerServer) cleanupChunks(existingEntry *filer2.Entry, newEntry *file
|
|||||||
// not good, but should be ok
|
// not good, but should be ok
|
||||||
glog.V(0).Infof("MaybeManifestize: %v", err)
|
glog.V(0).Infof("MaybeManifestize: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunks = append(chunks, manifestChunks...)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user