-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Filestore Implementation #2634
Closed
+7,707
−125
Closed
Changes from all commits
Commits
Show all changes
209 commits
Select commit
Hold shift + click to select a range
929b49f
In the measure package don't return ErrInvalidType in batch Put.
kevina d8c1ccf
New "multi" datastore.
kevina a4ffdaf
Create a new AdvReader interface.
kevina f4ad3ba
Basic implementation of "add --no-copy".
kevina 28d18ce
Add basic tests for "add --no-copy".
kevina 0f3f2e9
When reconstructing block always verify the result.
kevina 7f1bf41
Add Basic Query and "Direct" commands to filestore. Needs Testing.
kevina cc30fa6
Save ref to Filestore in repo for future direct access.
kevina be4649b
Add Self() method to be able to get to FSRepo.
kevina 7853241
Add "filestore" commands to list contents and verify filestore.
kevina 4fc46db
Disable failing test.
kevina 725fb99
Refactor.
kevina 5e1897f
Add temp. utility command to find dangling pins.
kevina cc65b61
Add "filestore rm" command.
kevina 4a2807f
"filestore ls": add "--quiet" option
kevina a7a2e55
"filestore verify": change "invalid" status to "changed".
kevina 889f470
Check if the WholeFile flag should be set for leaf nodes in filestore…
kevina d028645
Add "filestore rm-invalid" command.
kevina 958e344
"filestore ls": add help text and rework output
kevina 07a292c
"filestore verify": only verify leaf nodes, add help text
kevina b0a6468
Add sharness tests for new "filestore" commands.
kevina a2610b2
Report an error when trying to use "--no-copy" when daemon is online.
kevina 1203021
Fix bug in LevelDB datastore's Delete() method.
kevina b5a89f1
In the filestore, reconstruct the block directly when retrieving.
kevina caf89fb
Refactor filestore utility commands.
kevina 5e20d47
Enhance "filestore rm" to give better output.
kevina 92170c9
Filestore: Change DataObj struct to use bit flags.
kevina 8f136fd
Filestore: Only verify contents of block if the file's mod-time has c…
kevina c7f9757
Filestore: Get the modification time from the file before it is first…
kevina e649788
Move filestore utility commands into their own package.
kevina 85cae36
Redo "filestore verify" to check more than if blocks can be read.
kevina ebca489
New command "filestore clean", replaces obsolete "... rm-invalid" com…
kevina d9f3844
Add "filestore fix-pins", remove obsolete "filestore find-dangling-pi…
kevina 38eb47c
New command: "filestore repin".
kevina 43bb5f4
Tweak help text for filestore commands.
kevina 1f2fda7
Filestore: Refactor
kevina 9022879
Rewrite "filestore rm" for greater functionality and to correctly han…
kevina f08ea6b
Change "repin" to "unpinned" and just list the unpinned objects.
kevina 6f97efd
"filestore rm": Avoid checking for indirect pins when "--force" is used.
kevina 7db64c4
New command "filestore rm-dups"
kevina ee9d941
Filestore: Todo list.
kevina 70f4453
Enhance filestore testcases.
kevina 53f499f
"filestore repin": Add --skip-root option.
kevina df10f8e
Filestore: Add README.
kevina 906320f
Fix a compile error in a test case.
kevina f9896fa
Do not use separate absolute Path, just make the FullPath absolute.
kevina c2df48e
Add way to add files on the API server's filesystem without sending t…
kevina f37c326
Filestore: Refactor test cases.
kevina 7991036
Filestore: Update README and add testcase using new add-ss functionally
kevina 4313c4f
Filestore: Refactor fsutil.List
kevina 2b09cb4
"filestore rm": Do not delete blocks that are shared with another pin…
kevina d97b42e
New command "filestore ls-files"
kevina 1ded141
Add Filestore.Verify config option to control when block are verified.
kevina 9f689fa
Filestore: Remove todo list.
kevina f40117f
Gofmt
kevina ff4ee54
Filestore: Expand tests.
kevina af94888
Create an alternative blockstore for use with the filestore.
kevina 3d3b544
Factor out filestore specific code from DagServices.
kevina 6153f43
Keep track of offsets in the DAG builder and not the splitter.
kevina c0fe98f
Filestore: Change FileRoot constant to Internal
kevina 72fb3c6
Simplify "multi" datastore. Move logic into filestore's blockstore.
kevina 976635a
In the fsrepo, provide ways to get sub-datastore by name.
kevina 47962cc
Gofmt and clean up diff noise.
kevina c82a9cf
New command "filestore upgrade"
kevina 951df45
New command: "filestore mv"
kevina 490026c
Filestore: Minor Refactor.
kevina d168f04
"filestore ls": enhance
kevina d44c892
Filestore: res.Request() => req
kevina 2fe38b3
"filestore verify": add ability to specify hashes to verify
kevina fd077d3
Filestore: Prevent server crash when DataPtr.PosInfo is not set.
kevina 293e848
Fix multi-file add so it works as expected.
kevina aafc61d
Filestore: Cleanup.
kevina b643748
Filestore: change "add --no-copy" to "filestore add"
kevina 0cdf270
Rework "filestore add" command. Absolute paths now always required.
kevina 30a11ce
Handle errors returned by the splitter in the DAG builder.
kevina d4f1638
Filestore: Add support for "porcelain" output.
kevina 07376d8
Filestore: Add another '-v' level to "filestore verify".
kevina 7ddf150
Filestore: Allow adds when server is online.
kevina 3676047
Filestore: Don't Store Empty Files in Filestore
kevina 4827fa7
Filestore: new func CleanPath like filepath.Clean but leaves '..' alone
kevina c449829
Filestore: Readd support for realtive directories with '-P' and '-l' …
kevina e69a33a
Filestore: Update README.
kevina 6eb4f0d
Filestore: Add example script. Update README.
kevina 53cb291
Filestore: Use filepath.IsAbs() not path.IsAbs().
kevina ea3716f
Filestore: Fix -P to work as expected on Windows.
kevina 26416a4
Filestore: Fix add-dir.sh script
kevina 2bf9260
Filestore: Update README
kevina 0106446
Filestore: Make sure to explicitly close files to avoid a file handle…
kevina 629803e
Move multi-datastore out of go-datastore.
kevina d3bf502
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina d5ef180
Filestore: Eliminate need for DataPtr
kevina b454ba0
Filestore: Generalize Reconstruct() function
kevina 7a64523
Filestore: Rewrite Optimized version of Reconstruct().
kevina 1135469
Store PosInfo in BasicBlock, eliminate NodeToBlock hook in DAGService.
kevina e976430
Diff noise cleanup.
kevina 6ff54cf
Filestore: Cleanup.
kevina b5c3561
Filestore: Cleanup
kevina 382e1a6
Filestore: Simplify the specialized Blockstore
kevina 02a6f2a
Filestore: Clean up Errors and Command Line help text.
kevina cdb8ea5
Filestore: More Error message cleanup.
kevina a9cc988
Filestore: Clean up Errors and documentation.
kevina 36a9948
Filestore: Remove spurious ".EnableStdin()."
kevina 09e3da1
Filestore: Use LevelDB directly.
kevina a861ad7
Filestore: Documentation: Change README
djdv f82b39e
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina 3c3f02c
Filestore: Enhance "filestore upgrade" to convert keys to base32.
kevina 3ffc5f1
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina 270e402
Replace the multi-datastore with a multi-blockstore.
kevina a482ee1
Implement multiblockstore.AllKeysChan(), GC now uses the first mount.
kevina 5a73226
Add DAGService.GetLinks() method and use it in the GC and elsewhere.
kevina 7697929
Filestore: Don't pin by default when adding files.
kevina a8f0c9f
Add "block locate" command.
kevina 8bcc429
Pinner: Providing Pinned.String() method and use it in "block rm"
kevina c4fefd5
Filestore: Simplify "filestore rm" removing pinning commands.
kevina 75baf15
Filestore: Update README to reflect reality.
kevina 33099b2
"blockstore rm": move core functionally into blockstore_util package
kevina f9acb13
Filestore: Use "block rm" to remove blocks.
kevina f68bba7
"block/filestore rm": Allow removal of pinned but duplicate blocks.
kevina e9ba1fb
"add": add "--allow-dup" option.
kevina 68f7240
Filestore: kill "rm-dups" replace it by a more flexable "dups".
kevina 9542730
Filestore: Update README.
kevina 5917f56
Filestore: Fix typos in README.md
kevina 68ece81
Filestore: Remove note about managled hashed from README.
kevina ec3ac46
Filestore: Enhance "filestore ls-files" command.
kevina 0b6dc58
Filestore: Add (failing) tests that paths are not modified.
kevina 9090771
Revert "Resolve symlink if it is directly referenced in cli (#2897)"
kevina 6c99d37
Filestore: Path tests now work.
kevina 0c3c9b5
Filestore: Output full paths when added.
kevina 8b396fd
Bug fix for "Add DAGService.GetLinks() method..."
kevina d8a17f0
Filestore: Add better example script.
kevina df3f170
Filestore: Add new verification level, Refactor.
kevina 75e61f3
"filestore verify": adjust porcelain output.
kevina 12631ee
Filestore: Fix new example script so it is more correct.
kevina f4d6a9f
Filestore: Minor Refactor
kevina b34fd9c
Distinguish between Offline and Local Mode.
kevina 5fd8d6a
Filestore: Store empty files in the filestore itself.
kevina cdb4951
Filestore: Minor enhancement to example script.
kevina 83f9ec8
Require filestore to be enabled with "filestore enable".
kevina 5e2cac2
Blockstore: Minor refactor of RmBlocks.
kevina ebf86f2
Adder: Don't hold the PinLock when not pinning.
kevina ba8060d
Filestore: Bug fix when adding files in "online" mode.
kevina 8f342a7
Filestore: Fix a race condition when updating DataObj
kevina 84e73c3
Filestore: Better logic in Update() method
kevina 5cd6a93
Filestore: Fix maintenance commands so they are safe to run Online
kevina 38ad631
Filestore: Remove OrigData from ListRes and use iterators instead
kevina e318684
Filestore: Use iterator in VerifyFull. Other refactoring.
kevina 602abc0
Filestore: Rework list filtering so it also works on verify command.
kevina c75bca3
Filestore: Enhance add-dir.py script to work without cache file.
kevina 3ac9b1a
Filestore: Clarify verify levels, minor refactor
kevina 5238994
Filestore: Remove unused function.
kevina 4c8950e
Filestore: Redo "clean" command so it works again and related changes.
kevina c515ca0
"filestore clean": Avoid blocking while holidng the GCLock
kevina c27121b
Filestore: Bug fix to example script.
kevina 4f6a43a
"block rm": Just return "error" in ProcRmOutput.
kevina 5ab877b
"block rm": Document RemovedBlock, rename CheckPins to FilterPinned.
kevina 9871144
Filestore: Rename example script. Update README. Document Filestore.V…
kevina 15e6ec7
Adder: Make sure errors from addAllAndPin make it to the client
kevina 6857aec
Filestore: Fail cleanly when adding symlinks with daemon running.
kevina 4cf2e8c
Merge commit '19779b3707827355f3b9d6c5fbd17e924ea42e91' into kevina/f…
kevina 43bdd07
Merge commit '8ffab98d55628cf590f363ab203da2d4ba160ba2' into kevina/f…
kevina 580fb9f
Merge commit '8830aae9bcef257b11401b7c9e834a3aa107386a' into kevina/f…
kevina 157055b
Merge commit '531b89abc980d2a0080baa0baa0b41638e559b3a' into kevina/f…
kevina 7728d47
Redo 582e5dee3a97f994e7d204ed23960f5752f86553
kevina 97f1ca2
Merge branch 'blockservice-fix' into kevina/filestore
kevina 43d7d8e
Merge commit '87ecb92fceb58497268f7460ac1c877a97b056df' into blockser…
kevina 9709cb5
Merge branch 'blockservice-fix' into kevina/filestore
kevina 3f6214b
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina f478548
Run gofmt on some files, other diff noise cleanup.
kevina 73130fe
Don't use a separate LinkService for DAGService.GetLinks()
kevina 3af102a
Fix EnumerateChildren & hasChild to take a *cid.Cid instead of []*mda…
kevina 739e27c
Revert "Adder: Make sure errors from addAllAndPin make it to the client"
kevina 24cff3a
Revert "Redo 582e5dee3a97f994e7d204ed23960f5752f86553"
kevina a855ab3
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina e74f619
Filestore: Use the new write-though block service.
kevina 241d10d
Filestore: Disable config.Filestore.APIServerSidePaths for now.
kevina 51f71e1
Clean up diff noise.
kevina 0e045c6
Clarify reason for Has() in Put() in MultiBlockstore.
kevina 5c3b48b
In NewBlockstoreWPrefix don't assume "" is the default value.
kevina 3d0f2e0
Add test that PosInfo() is getting set.
kevina ba807ea
blockstore: use helper func to convert from Cid to DsKey and the reverse
kevina d3f0a59
Adder: Disallow adding multiple directories unless "-w" is used.
kevina 85908c2
Adder: fixups
kevina 15fa70a
Filestore: Accommodate systems without sub-second mod-times in tests
kevina a32f091
Filestore: bug fix, go 'case' does not fall-through
kevina b9ad427
Filestore: Change the default value of Filestore.Verify to 'Always'
kevina db6c9e8
Filestore: Verify level 6 behavior now depends on Filestore.Verify
kevina 97933ac
Filestore: Fix sharness test.
kevina 2c58788
Filestore: Fix comment.
kevina d283e7e
Merge remote-tracking branch 'upstream/kevina/posinfo-2' into kevina/…
kevina 85f1089
Gofmt and other diff noise cleanup.
kevina 9e6636d
Filestore: Support Raw Blocks.
kevina f080bdb
Merge remote-tracking branch 'upstream/master' into kevina/filestore
kevina 0313956
Filestore: Enable default LevelDB Compression By Default
kevina 77bf0c3
Filestore: Move custom version of filepath.Clean() into its own package.
kevina f3d5399
Filestore: Use the CidToDsKey form ds-help package.
kevina 3a2b2a0
Filestore: Implement Key struct for future multi DataObj per hash sup…
kevina b028088
Filestore: Move snapshot related code into its own file.
kevina c69cd67
Filestore: Remove support for old format and Upgrade command.
kevina cdd0b69
Filestore: Prep work for multi DataObj per hash support.
kevina b0e2d0d
Filestore: Enhance Key structure.
kevina 4bd48f8
Filestore: Basic support for multiple DataObjs per hash
kevina 4da34e4
Filestore: Fix maintenance commands.
kevina 6d292b8
Filestore: Remove seperate veirfy-post-orphan command.
kevina dfc5342
Filestore: enhance "ls" and "verify" command
kevina 4bd3d40
Filestore: Enhance "rm" command.
kevina 12d62f4
Filestore: Documentation updates and improvements.
kevina c64c0e6
Filestore "ls": Enhance "w/type" format.
kevina ae0f4a9
Filestore: Improve shareness test descriptions.
kevina 9215a1e
Revert "Filestore: Disable config.Filestore.APIServerSidePaths for now."
kevina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package blockstore | ||
|
||
// A very simple multi-blockstore that analogous to a unionfs Put and | ||
// DeleteBlock only go to the first blockstore all others are | ||
// considered readonly. | ||
|
||
import ( | ||
//"errors" | ||
"context" | ||
|
||
blocks "github.com/ipfs/go-ipfs/blocks" | ||
cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid" | ||
dsq "gx/ipfs/QmbzuUusHqaLLoNTDEVLcSF6vZDHZDLPC7p4bztRvvkXxU/go-datastore/query" | ||
) | ||
|
||
type LocateInfo struct { | ||
Prefix string | ||
Error error | ||
} | ||
|
||
type MultiBlockstore interface { | ||
Blockstore | ||
GCLocker | ||
FirstMount() Blockstore | ||
Mounts() []string | ||
Mount(prefix string) Blockstore | ||
Locate(*cid.Cid) []LocateInfo | ||
} | ||
|
||
type Mount struct { | ||
Prefix string | ||
Blocks Blockstore | ||
} | ||
|
||
func NewMultiBlockstore(mounts ...Mount) *multiblockstore { | ||
return &multiblockstore{ | ||
mounts: mounts, | ||
} | ||
} | ||
|
||
type multiblockstore struct { | ||
mounts []Mount | ||
gclocker | ||
} | ||
|
||
func (bs *multiblockstore) FirstMount() Blockstore { | ||
return bs.mounts[0].Blocks | ||
} | ||
|
||
func (bs *multiblockstore) Mounts() []string { | ||
mounts := make([]string, 0, len(bs.mounts)) | ||
for _, mnt := range bs.mounts { | ||
mounts = append(mounts, mnt.Prefix) | ||
} | ||
return mounts | ||
} | ||
|
||
func (bs *multiblockstore) Mount(prefix string) Blockstore { | ||
for _, m := range bs.mounts { | ||
if m.Prefix == prefix { | ||
return m.Blocks | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (bs *multiblockstore) DeleteBlock(key *cid.Cid) error { | ||
return bs.mounts[0].Blocks.DeleteBlock(key) | ||
} | ||
|
||
func (bs *multiblockstore) Has(c *cid.Cid) (bool, error) { | ||
var firstErr error | ||
for _, m := range bs.mounts { | ||
have, err := m.Blocks.Has(c) | ||
if have && err == nil { | ||
return have, nil | ||
} | ||
if err != nil && firstErr == nil { | ||
firstErr = err | ||
} | ||
} | ||
return false, firstErr | ||
} | ||
|
||
func (bs *multiblockstore) Get(c *cid.Cid) (blocks.Block, error) { | ||
var firstErr error | ||
for _, m := range bs.mounts { | ||
blk, err := m.Blocks.Get(c) | ||
if err == nil { | ||
return blk, nil | ||
} | ||
if firstErr == nil || firstErr == ErrNotFound { | ||
firstErr = err | ||
} | ||
} | ||
return nil, firstErr | ||
} | ||
|
||
func (bs *multiblockstore) Locate(c *cid.Cid) []LocateInfo { | ||
res := make([]LocateInfo, 0, len(bs.mounts)) | ||
for _, m := range bs.mounts { | ||
_, err := m.Blocks.Get(c) | ||
res = append(res, LocateInfo{m.Prefix, err}) | ||
} | ||
return res | ||
} | ||
|
||
func (bs *multiblockstore) Put(blk blocks.Block) error { | ||
// First call Has() to make sure the block doesn't exist in any of | ||
// the sub-blockstores, otherwise we could end with data being | ||
// duplicated in two blockstores. | ||
exists, err := bs.Has(blk.Cid()) | ||
if err == nil && exists { | ||
return nil // already stored | ||
} | ||
return bs.mounts[0].Blocks.Put(blk) | ||
} | ||
|
||
func (bs *multiblockstore) PutMany(blks []blocks.Block) error { | ||
stilladd := make([]blocks.Block, 0, len(blks)) | ||
// First call Has() to make sure the block doesn't exist in any of | ||
// the sub-blockstores, otherwise we could end with data being | ||
// duplicated in two blockstores. | ||
for _, blk := range blks { | ||
exists, err := bs.Has(blk.Cid()) | ||
if err == nil && exists { | ||
continue // already stored | ||
} | ||
stilladd = append(stilladd, blk) | ||
} | ||
if len(stilladd) == 0 { | ||
return nil | ||
} | ||
return bs.mounts[0].Blocks.PutMany(stilladd) | ||
} | ||
|
||
func (bs *multiblockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) { | ||
//return bs.mounts[0].Blocks.AllKeysChan(ctx) | ||
//return nil, errors.New("Unimplemented") | ||
in := make([]<-chan *cid.Cid, 0, len(bs.mounts)) | ||
for _, m := range bs.mounts { | ||
ch, err := m.Blocks.AllKeysChan(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
in = append(in, ch) | ||
} | ||
out := make(chan *cid.Cid, dsq.KeysOnlyBufSize) | ||
go func() { | ||
defer close(out) | ||
for _, in0 := range in { | ||
for key := range in0 { | ||
out <- key | ||
} | ||
} | ||
}() | ||
return out, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aww, renaming this from
RawBlock
toBasicBlock
makes the diff so noisy... I was hoping to avoid that by getting that change merged separatelyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that change as it was in a separate commit. Let me know if you know if you want me to do anything about it, like submitting this change separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whyrusleeping, this rename is only in one file, it is exported because I might eventually refactor my Filestore specific changes to blocks/blocks.go into another file.