Skip to content

Commit f09bd5c

Browse files
Merge pull request #3608 from ipfs/feat/new-flatfs-sharding
Use newer flatfs sharding scheme
2 parents a90c508 + 1366795 commit f09bd5c

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@
213213
},
214214
{
215215
"author": "whyrusleeping",
216-
"hash": "Qmbx2KUs8mUbDUiiESzC1ms7mdmh4pRu8X1V1tffC46M4n",
216+
"hash": "Qmcdc2Str4Dkc8yVCzzUFpnxmkS9AZXnpfo6jbhjjtXXkB",
217217
"name": "go-ds-flatfs",
218-
"version": "1.0.1"
218+
"version": "1.1.0"
219219
},
220220
{
221221
"author": "whyrusleeping",

repo/fsrepo/defaultds.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
levelds "gx/ipfs/QmaHHmfEozrrotyhyN44omJouyuEtx6ahddqV6W5yRaUSQ/go-ds-leveldb"
1414
ldbopts "gx/ipfs/QmbBhyDKsY4mbY6xsKt3qu9Y7FPvMJ6qbD8AMjYYvPRw1g/goleveldb/leveldb/opt"
1515
measure "gx/ipfs/QmbUSMTQtK9GRrUbD4ngqJwSzHsquUc8nyDubRWp4vPybH/go-ds-measure"
16-
"gx/ipfs/Qmbx2KUs8mUbDUiiESzC1ms7mdmh4pRu8X1V1tffC46M4n/go-ds-flatfs"
16+
"gx/ipfs/Qmcdc2Str4Dkc8yVCzzUFpnxmkS9AZXnpfo6jbhjjtXXkB/go-ds-flatfs"
1717
)
1818

1919
const (
@@ -33,9 +33,10 @@ func openDefaultDatastore(r *FSRepo) (repo.Datastore, error) {
3333
}
3434

3535
syncfs := !r.config.Datastore.NoSync
36-
// 5 bytes of prefix gives us 25 bits of freedom, 16 of which are taken by
37-
// by the Qm prefix. Leaving us with 9 bits, or 512 way sharding
38-
blocksDS, err := flatfs.New(path.Join(r.path, flatfsDirectory), 5, syncfs)
36+
37+
// 2 characters of base32 suffix gives us 10 bits of freedom.
38+
// Leaving us with 10 bits, or 1024 way sharding
39+
blocksDS, err := flatfs.CreateOrOpen(path.Join(r.path, flatfsDirectory), flatfs.NextToLast(2), syncfs)
3940
if err != nil {
4041
return nil, fmt.Errorf("unable to open flatfs datastore: %v", err)
4142
}

repo/fsrepo/fsrepo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
var log = logging.Logger("fsrepo")
3030

3131
// version number that we are currently expecting to see
32-
var RepoVersion = 4
32+
var RepoVersion = 5
3333

3434
var migrationInstructions = `See https://github.com/ipfs/fs-repo-migrations/blob/master/run.md
3535
Sorry for the inconvenience. In the future, these will run automatically.`

repo/fsrepo/migrations/migrations.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func migrationsBinName() string {
3535
}
3636

3737
func RunMigration(newv int) error {
38+
if newv == 5 {
39+
return fmt.Errorf("No automatic migrations yet for repo version 5. You will have to build them from source.\nSee https://github.com/ipfs/fs-repo-migrations")
40+
}
3841
migrateBin := migrationsBinName()
3942

4043
fmt.Println(" => Looking for suitable fs-repo-migrations binary.")

test/sharness/t0066-migration.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ test_expect_success "ipfs daemon --migrate=true runs migration" '
3535
'
3636

3737
test_expect_success "output looks good" '
38-
grep "Running: " true_out > /dev/null &&
39-
grep "Success: fs-repo has been migrated to version 4." true_out > /dev/null
38+
#grep "Running: " true_out > /dev/null &&
39+
#grep "Success: fs-repo has been migrated to version 4." true_out > /dev/null
40+
grep "No automatic migrations yet" true_out > /dev/null
4041
'
4142

4243
test_expect_success "'ipfs daemon' prompts to auto migrate" '

test/sharness/t0084-repo-read-rehash.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ test_init_ipfs
1616
H_BLOCK1=$(echo "Block 1" | ipfs add -q)
1717
H_BLOCK2=$(echo "Block 2" | ipfs add -q)
1818

19-
BS_BLOCK1="CIQPD/CIQPDDQH5PDJTF4QSNMPFC45FQZH5MBSWCX2W254P7L7HGNHW5MQXZA.data"
20-
BS_BLOCK2="CIQNY/CIQNYWBOKHY7TCY7FUOBXKVJ66YRMARDT3KC7PPY6UWWPZR4YA67CKQ.data"
19+
BS_BLOCK1="XZ/CIQPDDQH5PDJTF4QSNMPFC45FQZH5MBSWCX2W254P7L7HGNHW5MQXZA.data"
20+
BS_BLOCK2="CK/CIQNYWBOKHY7TCY7FUOBXKVJ66YRMARDT3KC7PPY6UWWPZR4YA67CKQ.data"
2121

2222

2323
test_expect_success 'blocks are swapped' '

0 commit comments

Comments
 (0)