Art test#50
Open
aivillio wants to merge 36 commits into
Open
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ert, merged conflicts from angelo
…ndependent and other small changes
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR replaces the directory entry storage from a Go map to an Adaptive Radix Tree (ART) and wires it into the FUSE filesystem implementation.
Changes:
- Introduce an internal
artpackage (insert/search/delete/traversal) with tests and a demo command. - Refactor
internal/fsdirectory operations to useart.Treeand RWMutexes instead of amap[string]fs.Node. - Add a filesystem-level rename test and update existing fs tests to reflect the ART-backed directory representation.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/fs/fs.go | Initialize root directory with an ART and insert the initial hello.txt file. |
| internal/fs/dir.go | Switch directory CRUD operations (Lookup/ReadDirAll/Mkdir/Create/Remove/Rename) to ART APIs and RWMutexes. |
| internal/fs/file.go | Update locking for Attr and fix slice allocation type conversions. |
| internal/fs/fs_test.go | Update tests to query the ART tree and add a rename test. |
| internal/art/* | Add ART implementation (nodes, insert/search/delete, traversal/print helpers) plus unit tests. |
| cmd/radFS/arttest/main.go | Add a standalone command for manual ART growth/shrink verification. |
| docs/weekly/angelo/week_4.md | Add weekly progress notes related to ART work. |
Comments suppressed due to low confidence (2)
internal/fs/dir.go:1
- The previous implementation updated the parent directory’s
mtime/ctimewhen creating a child; this version no longer updates them inMkdir. If timestamps are part of your filesystem semantics, updated.mtimeandd.ctimeafter inserting the new entry (similar toRemove).`
package fs
internal/fs/dir.go:1
- Similar to
Mkdir,Createno longer updates the containing directory’smtime/ctimeafter adding an entry. Consider restoring the parent timestamp update to preserve expected directory metadata behavior.`
package fs
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
55
to
+61
| func (d *Dir) Lookup(ctx context.Context, name string) (fs.Node, error) { | ||
| d.fs.DebugPrint("LOOKUP", "fetching", name) | ||
|
|
||
| d.mu.Lock() | ||
| defer d.mu.Unlock() | ||
| d.mu.RLock() | ||
| defer d.mu.RUnlock() | ||
|
|
||
| node, ok := d.Nodes[name] | ||
| v, ok := d.tree.Search([]byte(name)) |
Comment on lines
66
to
+68
| d.atime = time.Now() | ||
|
|
||
| return node, nil | ||
| return v.(fs.Node), nil |
Comment on lines
72
to
92
| func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) { | ||
| d.fs.DebugPrint("READDIR", "inode", d.inode) | ||
|
|
||
| d.mu.Lock() | ||
| defer d.mu.Unlock() | ||
| d.mu.RLock() | ||
| defer d.mu.RUnlock() | ||
|
|
||
| var entries []fuse.Dirent | ||
| for name, node := range d.Nodes { | ||
| var dt fuse.DirentType | ||
|
|
||
| switch node.(type) { | ||
| d.tree.ForEach(func(b []byte, i interface{}) { //traverses tree and appends the dirent to entries | ||
| name := string(b) | ||
| var dtype fuse.DirentType | ||
| switch i.(type) { | ||
| case *File: | ||
| dtype = fuse.DT_File | ||
| case *Dir: | ||
| dt = fuse.DT_Dir | ||
| default: | ||
| dt = fuse.DT_File | ||
| } | ||
| dtype = fuse.DT_Dir | ||
|
|
||
| entries = append(entries, fuse.Dirent{Name: name, Type: dt}) | ||
| } | ||
| } | ||
| entries = append(entries, fuse.Dirent{Name: name, Type: dtype}) | ||
| }) | ||
|
|
||
| d.atime = time.Now() |
Comment on lines
+81
to
+89
| var dtype fuse.DirentType | ||
| switch i.(type) { | ||
| case *File: | ||
| dtype = fuse.DT_File | ||
| case *Dir: | ||
| dt = fuse.DT_Dir | ||
| default: | ||
| dt = fuse.DT_File | ||
| } | ||
| dtype = fuse.DT_Dir | ||
|
|
||
| entries = append(entries, fuse.Dirent{Name: name, Type: dt}) | ||
| } | ||
| } | ||
| entries = append(entries, fuse.Dirent{Name: name, Type: dtype}) |
Comment on lines
+128
to
+137
| func removechild(n *Node, k byte) *Node { | ||
| in := n.innerNode | ||
| _, pos := findchild(k, n) | ||
|
|
||
| // If child doesn't exist, return original node (search loop only for node 4 and 16) | ||
| if pos == -1 && in.nodeType <= Node16 { | ||
| return n | ||
| } | ||
|
|
||
| switch in.nodeType { |
Comment on lines
+8
to
+13
| if isleaf(n) { | ||
| if string(n.leaf.key) == string(key) { | ||
| return n | ||
| } | ||
| return nil | ||
| } |
Comment on lines
7
to
+10
| "time" | ||
|
|
||
| "bazil.org/fuse/fs" | ||
| "github.com/acmpesuecc/radFS/internal/art" |
Comment on lines
+45
to
+46
| uid: uint32(os.Getuid()), //permissions implemnet based on userid | ||
| gid: uint32(os.Getgid()), //permissions implement based on groupid |
| atime: time.Now(), | ||
| mtime: time.Now(), | ||
| ctime: time.Now(), | ||
| uid: uint32(os.Getuid()), //permissions implemnet based on userid |
Comment on lines
+224
to
+235
| // if destination exists → overwrite | ||
| if existing, exists := newParent.tree.Search([]byte(req.NewName)); exists { | ||
| // if it's a directory, check if empty | ||
| if dir, ok := existing.(*Dir); ok { | ||
| dir.mu.RLock() | ||
| defer dir.mu.RUnlock() | ||
| if !dir.tree.Empty() { | ||
| return syscall.ENOTEMPTY | ||
| } | ||
| } | ||
| newParent.tree.Delete([]byte(req.NewName)) | ||
| } |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Art test
Description
TO test all of Art's CRUD functions and some edge cases, fixed a tiny bug with insert where it would not update the same key if they had different values
Changes
Tests
Ran the art test suite