Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

797 B
Raw Blame
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())
}