mount.go 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package command
  2. import (
  3. "os"
  4. "time"
  5. )
  6. type MountOptions struct {
  7. filer *string
  8. filerMountRootPath *string
  9. dir *string
  10. dirAutoCreate *bool
  11. collection *string
  12. collectionQuota *int
  13. replication *string
  14. diskType *string
  15. ttlSec *int
  16. chunkSizeLimitMB *int
  17. concurrentWriters *int
  18. cacheMetaTtlSec *int
  19. cacheDirForRead *string
  20. cacheDirForWrite *string
  21. cacheSizeMBForRead *int64
  22. dataCenter *string
  23. allowOthers *bool
  24. umaskString *string
  25. nonempty *bool
  26. volumeServerAccess *string
  27. uidMap *string
  28. gidMap *string
  29. readOnly *bool
  30. debug *bool
  31. debugPort *int
  32. localSocket *string
  33. disableXAttr *bool
  34. extraOptions []string
  35. fuseCommandPid int
  36. // RDMA acceleration options
  37. rdmaEnabled *bool
  38. rdmaSidecarAddr *string
  39. rdmaFallback *bool
  40. rdmaReadOnly *bool
  41. rdmaMaxConcurrent *int
  42. rdmaTimeoutMs *int
  43. }
  44. var (
  45. mountOptions MountOptions
  46. mountCpuProfile *string
  47. mountMemProfile *string
  48. mountReadRetryTime *time.Duration
  49. )
  50. func init() {
  51. cmdMount.Run = runMount // break init cycle
  52. mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "comma-separated weed filer location")
  53. mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
  54. mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
  55. mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
  56. mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
  57. mountOptions.collectionQuota = cmdMount.Flag.Int("collectionQuotaMB", 0, "quota for the collection")
  58. mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
  59. mountOptions.diskType = cmdMount.Flag.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
  60. mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
  61. mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
  62. mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers")
  63. mountOptions.cacheDirForRead = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
  64. mountOptions.cacheSizeMBForRead = cmdMount.Flag.Int64("cacheCapacityMB", 128, "file chunk read cache capacity in MB")
  65. mountOptions.cacheDirForWrite = cmdMount.Flag.String("cacheDirWrite", "", "buffer writes mostly for large files")
  66. mountOptions.cacheMetaTtlSec = cmdMount.Flag.Int("cacheMetaTtlSec", 60, "metadata cache validity seconds")
  67. mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
  68. mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
  69. mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
  70. mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
  71. mountOptions.volumeServerAccess = cmdMount.Flag.String("volumeServerAccess", "direct", "access volume servers by [direct|publicUrl|filerProxy]")
  72. mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
  73. mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
  74. mountOptions.readOnly = cmdMount.Flag.Bool("readOnly", false, "read only")
  75. mountOptions.debug = cmdMount.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2")
  76. mountOptions.debugPort = cmdMount.Flag.Int("debug.port", 6061, "http port for debugging")
  77. mountOptions.localSocket = cmdMount.Flag.String("localSocket", "", "default to /tmp/seaweedfs-mount-<mount_dir_hash>.sock")
  78. mountOptions.disableXAttr = cmdMount.Flag.Bool("disableXAttr", false, "disable xattr")
  79. mountOptions.fuseCommandPid = 0
  80. // RDMA acceleration flags
  81. mountOptions.rdmaEnabled = cmdMount.Flag.Bool("rdma.enabled", false, "enable RDMA acceleration for reads")
  82. mountOptions.rdmaSidecarAddr = cmdMount.Flag.String("rdma.sidecar", "", "RDMA sidecar address (e.g., localhost:8081)")
  83. mountOptions.rdmaFallback = cmdMount.Flag.Bool("rdma.fallback", true, "fallback to HTTP when RDMA fails")
  84. mountOptions.rdmaReadOnly = cmdMount.Flag.Bool("rdma.readOnly", false, "use RDMA for reads only (writes use HTTP)")
  85. mountOptions.rdmaMaxConcurrent = cmdMount.Flag.Int("rdma.maxConcurrent", 64, "max concurrent RDMA operations")
  86. mountOptions.rdmaTimeoutMs = cmdMount.Flag.Int("rdma.timeoutMs", 5000, "RDMA operation timeout in milliseconds")
  87. mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
  88. mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
  89. mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
  90. }
  91. var cmdMount = &Command{
  92. UsageLine: "mount -filer=localhost:8888 -dir=/some/dir",
  93. Short: "mount weed filer to a directory as file system in userspace(FUSE)",
  94. Long: `mount weed filer to userspace.
  95. Pre-requisites:
  96. 1) have SeaweedFS master and volume servers running
  97. 2) have a "weed filer" running
  98. These 2 requirements can be achieved with one command "weed server -filer=true"
  99. This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
  100. Linux, and OS X.
  101. On OS X, it requires OSXFUSE (https://osxfuse.github.io/).
  102. RDMA Acceleration:
  103. For ultra-fast reads, enable RDMA acceleration with an RDMA sidecar:
  104. weed mount -filer=localhost:8888 -dir=/mnt/seaweedfs \
  105. -rdma.enabled=true -rdma.sidecar=localhost:8081
  106. RDMA Options:
  107. -rdma.enabled=false Enable RDMA acceleration for reads
  108. -rdma.sidecar="" RDMA sidecar address (required if enabled)
  109. -rdma.fallback=true Fallback to HTTP when RDMA fails
  110. -rdma.readOnly=false Use RDMA for reads only (writes use HTTP)
  111. -rdma.maxConcurrent=64 Max concurrent RDMA operations
  112. -rdma.timeoutMs=5000 RDMA operation timeout in milliseconds
  113. `,
  114. }