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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
support write once read many
chrislueb02946c977b
diff --git a/weed/command/mount.go b/weed/command/mount.goindex f5972fd300..bdc0638c99 100644--- a/weed/command/mount.go+++ b/weed/command/mount.go@@ -33,6 +33,7 @@ type MountOptions struct {localSocket *stringdisableXAttr *boolextraOptions []string+ writeOnceReadMany *bool}var (@@ -70,6 +71,7 @@ func init() {mountOptions.debugPort = cmdMount.Flag.Int("debug.port", 6061, "http port for debugging")mountOptions.localSocket = cmdMount.Flag.String("localSocket", "", "default to /tmp/seaweedfs-mount-<mount_dir_hash>.sock")mountOptions.disableXAttr = cmdMount.Flag.Bool("disableXAttr", false, "disable xattr")+ mountOptions.writeOnceReadMany = cmdMount.Flag.Bool("writeOnceReadMany", false, "write once, read many times")mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")diff --git a/weed/command/mount_std.go b/weed/command/mount_std.goindex f85e7386d0..53357eba60 100644--- a/weed/command/mount_std.go+++ b/weed/command/mount_std.go@@ -247,6 +247,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {Cipher: cipher,UidGidMapper: uidGidMapper,DisableXAttr: *option.disableXAttr,+ WriteOnceReadMany: *option.writeOnceReadMany,})// create mount rootdiff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.goindex a9fbd93804..3ad938699b 100644--- a/weed/mount/weedfs.go+++ b/weed/mount/weedfs.go@@ -46,6 +46,8 @@ type Option struct {Quota int64DisableXAttr bool+ WriteOnceReadMany bool+MountUid uint32MountGid uint32MountMode os.FileModediff --git a/weed/mount/weedfs_file_io.go b/weed/mount/weedfs_file_io.goindex 7039b14ec6..c6fcb8a146 100644--- a/weed/mount/weedfs_file_io.go+++ b/weed/mount/weedfs_file_io.go@@ -62,7 +62,7 @@ import (*/func (wfs *WFS) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut) (status fuse.Status) {var fileHandle *FileHandle- fileHandle, status = wfs.AcquireHandle(in.NodeId, in.Uid, in.Gid)+ fileHandle, status = wfs.AcquireHandle(in.NodeId, in.Flags, in.Uid, in.Gid)if status == fuse.OK {out.Fh = uint64(fileHandle.fh)// TODO https://github.com/libfuse/libfuse/blob/master/include/fuse_common.h#L64diff --git a/weed/mount/weedfs_filehandle.go b/weed/mount/weedfs_filehandle.goindex 4845654eda..99b54850a0 100644--- a/weed/mount/weedfs_filehandle.go+++ b/weed/mount/weedfs_filehandle.go@@ -3,12 +3,20 @@ package mountimport ("github.com/hanwen/go-fuse/v2/fuse""github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"+ "time")-func (wfs *WFS) AcquireHandle(inode uint64, uid, gid uint32) (fileHandle *FileHandle, status fuse.Status) {+func (wfs *WFS) AcquireHandle(inode uint64, flags, uid, gid uint32) (fileHandle *FileHandle, status fuse.Status) {var entry *filer_pb.Entry_, _, entry, status = wfs.maybeReadEntry(inode)if status == fuse.OK {+ if entry != nil && wfs.option.WriteOnceReadMany {+ if entry.Attributes.Mtime+10 < time.Now().Unix() {+ if flags&fuse.O_ANYWRITE != 0 {+ return nil, fuse.EPERM+ }+ }+ }// need to AcquireFileHandle again to ensure correct handle counterfileHandle = wfs.fhmap.AcquireFileHandle(wfs, inode, entry)}