Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ Details: https://juicefs.com/docs/community/quick_start_guide`,
Value: 1,
Usage: "number of days after which removed files will be permanently deleted",
},
&cli.BoolFlag{
Name: "hash-prefix",
Usage: "give each object a hashed prefix",
},
&cli.BoolFlag{
Name: "force",
Usage: "overwrite existing format",
Expand Down Expand Up @@ -320,6 +324,7 @@ func format(c *cli.Context) error {
SecretKey: c.String("secret-key"),
EncryptKey: loadEncrypt(c.String("encrypt-rsa-key")),
Shards: c.Int("shards"),
HashPrefix: c.Bool("hash-prefix"),
Capacity: c.Uint64("capacity") << 30,
Inodes: c.Uint64("inodes"),
BlockSize: fixObjectSize(c.Int("block-size")),
Expand Down Expand Up @@ -361,6 +366,8 @@ func format(c *cli.Context) error {
format.Compression = c.String(flag)
case "shards":
format.Shards = c.Int(flag)
case "hash-prefix":
format.HashPrefix = c.Bool(flag)
case "storage":
format.Storage = c.String(flag)
case "encrypt-rsa-key":
Expand Down
5 changes: 3 additions & 2 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ func newStore(format *meta.Format, chunkConf *chunk.Config, registerer prometheu

func getChunkConf(c *cli.Context, format *meta.Format) *chunk.Config {
chunkConf := &chunk.Config{
BlockSize: format.BlockSize * 1024,
Compress: format.Compression,
BlockSize: format.BlockSize * 1024,
Compress: format.Compression,
HashPrefix: format.HashPrefix,

GetTimeout: time.Second * time.Duration(c.Int("get-timeout")),
PutTimeout: time.Second * time.Duration(c.Int("put-timeout")),
Expand Down
4 changes: 2 additions & 2 deletions pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (c *rChunk) blockSize(indx int) int {
}

func (c *rChunk) key(indx int) string {
if c.store.conf.Partitions > 1 {
if c.store.conf.HashPrefix {
return fmt.Sprintf("chunks/%02X/%v/%v_%v_%v", c.id%256, c.id/1000/1000, c.id, indx, c.blockSize(indx))
}
return fmt.Sprintf("chunks/%v/%v/%v_%v_%v", c.id/1000/1000, c.id/1000, c.id, indx, c.blockSize(indx))
Expand Down Expand Up @@ -623,7 +623,7 @@ type Config struct {
DownloadLimit int64 // bytes per second
Writeback bool
UploadDelay time.Duration
Partitions int
HashPrefix bool
BlockSize int
GetTimeout time.Duration
PutTimeout time.Duration
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/cached_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func TestStoreDelayed(t *testing.T) {
func TestStoreMultiBuckets(t *testing.T) {
mem, _ := object.CreateStorage("mem", "", "", "")
conf := defaultConf
conf.Partitions = 3
conf.HashPrefix = true
store := NewCachedStore(mem, conf, nil)
testStore(t, store)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Format struct {
BlockSize int
Compression string
Shards int
Partitions int
HashPrefix bool
Capacity uint64
Inodes uint64
EncryptKey string `json:",omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/metadata-sub.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"BlockSize": 4096,
"Compression": "none",
"Shards": 0,
"Partitions": 0,
"HashPrefix": false,
"Capacity": 0,
"Inodes": 0,
"EncryptKey": "AQSttslKOSE/hQT/gmaMniCsdPF8JdPRfoYK6zFkdUOnifYwBA==",
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/metadata.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"BlockSize": 4096,
"Compression": "none",
"Shards": 0,
"Partitions": 0,
"HashPrefix": false,
"Capacity": 0,
"Inodes": 0,
"EncryptKey": "AQSttslKOSE/hQT/gmaMniCsdPF8JdPRfoYK6zFkdUOnifYwBA==",
Expand Down
2 changes: 1 addition & 1 deletion sdk/java/libjfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func jfs_init(cname, jsonConf, user, group, superuser, supergroup *C.char) uintp
DownloadLimit: int64(jConf.DownloadLimit) * 1e6 / 8,
Prefetch: jConf.Prefetch,
Writeback: jConf.Writeback,
Partitions: format.Partitions,
HashPrefix: format.HashPrefix,
GetTimeout: time.Second * time.Duration(jConf.GetTimeout),
PutTimeout: time.Second * time.Duration(jConf.PutTimeout),
BufferSize: jConf.MemorySize << 20,
Expand Down