mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-06 06:22:05 +02:00
AsInode derives inodes from HashStringToLong, which is uniform over int64, so roughly half of the derived values land above math.MaxInt64 once they are converted to uint64. The Elasticsearch store indexes Entry.Attr.Inode as a signed long, so those values are rejected with HTTP 400 and the metadata entry is never written, which the filer then retries forever. Fold the sign bit off in one place, util.NormalizeInode, and route both derivation sites through it: FullPath.AsInode (path plus creation time) and the hard-link branch in ensureEntryInode (HardLinkId hash). Masking keeps the other 63 hash bits, so distinct paths still get distinct inodes, and it applies identically to the FUSE mount, which derives the same value. Co-authored-by: Yi-111-a <34116709+0-xiaosu@users.noreply.github.com>
27 lines
797 B
Go
27 lines
797 B
Go
package filer
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
// ensureEntryInode derives a stable inode the same way the FUSE mount does, so
|
|
// the filer-stored value matches what a mount would otherwise compute and no
|
|
// per-object reverse index is required. Hard links hash their shared
|
|
// HardLinkId, so every link resolves to one inode; other entries hash the path
|
|
// and creation time.
|
|
func (f *Filer) ensureEntryInode(entry *Entry) {
|
|
if entry == nil || entry.Attr.Inode != 0 {
|
|
return
|
|
}
|
|
if entry.Attr.Crtime.IsZero() {
|
|
entry.Attr.Crtime = time.Now()
|
|
}
|
|
if len(entry.HardLinkId) > 0 {
|
|
entry.Attr.Inode = util.NormalizeInode(uint64(util.HashStringToLong(string(entry.HardLinkId))))
|
|
return
|
|
}
|
|
entry.Attr.Inode = entry.FullPath.AsInode(entry.Attr.Crtime.Unix())
|
|
}
|