Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
336 commits
Select commit Hold shift + click to select a range
31ab388
Make CreateDir only intercept calls when we are offline
foodprocessor Jan 23, 2025
87f973d
CreateDir: Do not lock flock. Improve log output.
foodprocessor Jan 23, 2025
ee26dfb
FC DeleteFile: Correct GetAttr call
foodprocessor Jan 24, 2025
3244cea
Tidy IsDirEmpty
foodprocessor Jan 28, 2025
53da64b
Add TODO for new API function
foodprocessor Jan 28, 2025
9001504
Keep and serve expired cache list segments when cloud is unreachable.
foodprocessor Jan 28, 2025
7c3fd1c
Only provide cached directory listings when we have a complete listin…
foodprocessor Jan 28, 2025
7bce1d1
Simplify DeleteDir logic
foodprocessor Feb 7, 2025
a3d2e8e
Finish RenameDir
foodprocessor Feb 7, 2025
116f241
Update pending cloud ops on rename (folder and file)
foodprocessor Feb 8, 2025
93b7291
CreateFile
foodprocessor Feb 8, 2025
0f628ca
Merge branch 'main' into network-fault-tolerance
foodprocessor Feb 8, 2025
9fb21fa
Merge main into network-fault-tolerance
foodprocessor Feb 11, 2025
e302deb
Merge fixup
foodprocessor Feb 11, 2025
30daaa4
DeleteFile
foodprocessor Feb 12, 2025
5c194f5
DeleteFile - finish and scrub
foodprocessor Feb 15, 2025
ab3efac
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor Apr 28, 2025
5885ed2
Fix merge
foodprocessor Apr 28, 2025
d5e06b6
Tidy up switch style
foodprocessor Apr 28, 2025
6c5f164
Use switch for readability
foodprocessor Apr 28, 2025
62073ff
Fix merge
foodprocessor May 1, 2025
5130fb5
Improve offline helper functions
foodprocessor May 2, 2025
de7ccc5
Simplify CreateDir offline logic
foodprocessor May 2, 2025
d91b8c3
Reorganize CreateDir switch
foodprocessor May 2, 2025
31bd29a
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor May 6, 2025
933188b
merge cleanup
foodprocessor May 6, 2025
f558a39
Set up first working mock test
foodprocessor May 6, 2025
5e8b86d
reduce diff
foodprocessor May 6, 2025
8eb58a0
fixup
foodprocessor May 6, 2025
2f6a1a3
DeleteDir
foodprocessor May 7, 2025
28da6af
simplify logic
foodprocessor May 7, 2025
916d6e4
Finished up to IsDirEmpty (WIP)
foodprocessor May 7, 2025
12d465a
Finished RenameDir (WIP)
foodprocessor May 8, 2025
28838a9
Recognize composite ErrNotExist errors returned by attribute cache
foodprocessor May 9, 2025
fdfc86b
offline logic - DeleteFile
foodprocessor May 9, 2025
15a069c
offline logic - OpenFile (WIP)
foodprocessor May 9, 2025
cff6084
Offline logic - openFileInternal
foodprocessor May 9, 2025
85ce661
Read, Write, Chmod, Flush, Close (WIP)
foodprocessor May 12, 2025
9e05148
GetAttr - simplify logic
foodprocessor May 12, 2025
18a31c3
Merge branch 'main' into network-fault-tolerance
foodprocessor May 12, 2025
2c485fc
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor May 13, 2025
abb9aa4
Finish offline logic
foodprocessor May 13, 2025
ac05fdc
Prevent eviction for offline operations
foodprocessor May 13, 2025
6e862e0
Lint
foodprocessor May 13, 2025
f4ab1f0
Lint
foodprocessor May 13, 2025
e7dd2db
Upload pending operations on a separate thread
foodprocessor May 15, 2025
e373554
Use log.Warn for offline rename
foodprocessor May 15, 2025
c0d6058
Add iptables scripts to test offline aceess (picked from async-cloud …
foodprocessor May 16, 2025
e7784c1
Expand rule to include all Lyve Cloud regions (at least in the US).
foodprocessor May 17, 2025
3a22a5a
Use empty values
foodprocessor May 17, 2025
ed80051
Handle directory case using stat
foodprocessor May 17, 2025
333ff38
Add log output
foodprocessor May 20, 2025
3f408f2
Detect quota exceeded error as an offline error
foodprocessor May 22, 2025
4a826fb
Prevent upload unless HeadBucket returns no error.
foodprocessor May 22, 2025
edc390c
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor May 28, 2025
4265f43
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor Jun 9, 2025
70a1484
Bugfix: allow case 2 for directories
foodprocessor Jun 21, 2025
3db1894
Merge file cache changes from exponential backoff branch
foodprocessor Jun 21, 2025
a566794
Merge branch 'main' into network-fault-tolerance
foodprocessor Jun 30, 2025
1829a95
Exponential backoff offline cloud (#600)
foodprocessor Jul 8, 2025
409a641
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor Aug 24, 2025
cb3eaac
Improve scheduler concurrency
foodprocessor Aug 24, 2025
f5ebe95
Declare start and stop where they are used instead of passing them.
foodprocessor Aug 24, 2025
4dfe3f7
When initializing during an open window, start uploading immediately,…
foodprocessor Aug 24, 2025
a42727f
Test initializing during an active window.
foodprocessor Aug 24, 2025
457f09f
Fix minor logging bug
foodprocessor Aug 24, 2025
40a1be8
Merge branch 'improve-scheduler' into network-fault-tolerance
foodprocessor Aug 24, 2025
6f74269
Optimize tests
foodprocessor Aug 25, 2025
78b1c60
Merge branch 'improve-scheduler' into network-fault-tolerance
foodprocessor Aug 25, 2025
5daa46a
Merge Log collector cmd into network-fault-tolerance
foodprocessor Sep 26, 2025
bf7409c
Merge commit '0fe5caf8f8247542cbcee0c3a287f362c0b8cdb6' into network-…
foodprocessor Sep 26, 2025
c47f7c0
Merge commit '7f50d2348cc2da3bf392085b772143cc9faa4138' into network-…
foodprocessor Sep 26, 2025
df34ff8
Merge #661 into network-fault-tolerance
foodprocessor Sep 26, 2025
9f660a3
Merge commit '769c2481355d7d5e1f3a6ed00b10200bea94b27a' into network-…
foodprocessor Sep 26, 2025
9aa47fb
Merge improve scheduler into network-fault-tolerance
foodprocessor Sep 27, 2025
f5bc63a
Merge branch 'main' into network-fault-tolerance
foodprocessor Sep 27, 2025
d341051
Make network fault tolerance respect the scheduler's window.
foodprocessor Sep 28, 2025
49d7182
Stop async uploads on exit.
foodprocessor Sep 29, 2025
fd88abb
Don't lazy write when async uploading
foodprocessor Sep 29, 2025
6d3e940
Merge offline and scheduler logic
foodprocessor Sep 29, 2025
e1540b9
Make invalid schedule fail the mount
foodprocessor Sep 29, 2025
6e973a0
Lint
foodprocessor Sep 29, 2025
8daa843
Save SyncPending flag states
foodprocessor Sep 30, 2025
014da68
Remove SyncPending flag from flock, since it's only used in file_cache.
foodprocessor Sep 30, 2025
6cb434a
Merge commit '1481eae3' into network-fault-tolerance
foodprocessor Mar 26, 2026
e24ba6d
Merge commit main upto #793 (adf367e1) into network-fault-tolerance
foodprocessor Mar 26, 2026
11e65b7
Merge commit 'c8c3346a' into network-fault-tolerance
foodprocessor Mar 26, 2026
2dd3bef
Merge commit '83fb543faf2a14f25c77ef0e8676c74ac7f22112' into network-…
foodprocessor Mar 26, 2026
46baaf3
Merge commit 'e70fa5716e33a47dd31e525647638b70cdfbe4b6' into network-…
foodprocessor Mar 26, 2026
914abb6
Merge commit 'b23743f08d161e22ac7514167650acfaeae2b96d' into network-…
foodprocessor Mar 26, 2026
77ef9f1
Merge commit '84d30ca32ab907d0db5b5960ad6e164616660955' into network-…
foodprocessor Mar 26, 2026
412d55b
Merge commit '7f5bf7c8d92f9dec8129326848107dbc28a330c8' into network-…
foodprocessor Mar 26, 2026
52b732e
Merge commit '1c9fb976cb1f6e546c00abb380ad41cb07b7270e' into network-…
foodprocessor Mar 26, 2026
84ad117
Merge commit 'd1afdb4d145b7c70aa4775900805335a1de9da43' into network-…
foodprocessor Mar 26, 2026
f7198e7
Merge commit '0be96bbe4cd27b1f8f30cc3032ab84f59fdad200' into network-…
foodprocessor Mar 27, 2026
7ab05cb
Merge commit 'e51ad2eebf5a001fdf56f7afd9b71bfc30b99688' into network-…
foodprocessor Mar 27, 2026
d564c87
Merge commit 'ad195e0bb60f9781478deaf1214f5176f8367835' into network-…
foodprocessor Mar 27, 2026
e7a6f0a
Merge commit '94995a7e93b3fe6d72eab8193f0aba538e16b2d3' into network-…
foodprocessor Mar 27, 2026
1cc5425
Merge commit '87bbb2ec35d93b5ff6b6e03dd8cf704e9d7a567f' into network-…
foodprocessor Mar 27, 2026
f296c3b
Merge commit 'fa83cafec59f7f0857ee7438d85dac704ce6b50d' into network-…
foodprocessor Mar 27, 2026
5808875
Merge commit '2ae0fc09aba35398b8dcd3f2cbdad56cd3426f26' into network-…
foodprocessor Mar 27, 2026
9fea0f8
Merge commit '3de9bfde29a4fa014de0f46b0f6d8cadfccd359e' into network-…
foodprocessor Mar 27, 2026
e7335b7
Fix merge bugs
foodprocessor Mar 27, 2026
a3a4858
Fix mutex merge bug
foodprocessor Mar 27, 2026
f4f7dcb
Fix merge bug
foodprocessor Mar 27, 2026
15eb813
Test file cache path should be random
foodprocessor Mar 31, 2026
8f2a47b
Initialize pendingOps for testing
foodprocessor Mar 31, 2026
cc3efd8
Improve flushFileInternal logic.
foodprocessor Apr 4, 2026
7ab2d1e
Drop unneeded function
foodprocessor Apr 4, 2026
20daf12
Provide more context when checking cloud state.
foodprocessor Apr 17, 2026
64dcbba
DeleteDir: allow pending object deletion
foodprocessor Apr 17, 2026
46cf033
Simplify ExtendDirName
foodprocessor Apr 17, 2026
2b39e3a
Add directory (but not file) deletion to service pending ops.
foodprocessor Apr 18, 2026
86b8da5
Include trailing slash for directory names in flock.
foodprocessor Apr 18, 2026
6a7fe92
Add file deletion to service pending ops.
foodprocessor Apr 18, 2026
a7624e7
Add pending op flags.
foodprocessor Apr 18, 2026
8e80d53
Remove AsyncUpload flag and don't reuse flushFileInternal
foodprocessor Apr 18, 2026
dfc666a
Create uploadFile helper and use it in async.
foodprocessor Apr 19, 2026
2f377fe
Drop unused code.
foodprocessor Apr 19, 2026
30449e9
Remove redundant file handle.
foodprocessor Apr 19, 2026
912d25c
When a pending op has no local file, drop the op.
foodprocessor Apr 20, 2026
30c5a35
Change DeleteDir to just delete the marker.
foodprocessor Apr 20, 2026
587a297
Add new offline rename semantics (source must be cached).
foodprocessor Apr 20, 2026
d2e5b75
Always delete directory markers, even if disabled.
foodprocessor Apr 20, 2026
5e18aa7
Update unit tests for DeleteDir
foodprocessor Apr 20, 2026
18831d9
Update CreateFile & DeleteFile with new offline semantics
foodprocessor Apr 20, 2026
306e82f
Update comment
foodprocessor Apr 20, 2026
db7127e
Block offline open when offline access is disabled
foodprocessor Apr 20, 2026
cca76fb
isDownloadRequired: clean up logic and don't refresh when offline
foodprocessor Apr 21, 2026
3ed64da
Rewrite open to allow offline overwrites and simplify logic.
foodprocessor Apr 21, 2026
203bee0
Use cloud component state cache to simplify logic
foodprocessor Apr 21, 2026
e0f5841
Fix flock race in flush logic.
foodprocessor Apr 21, 2026
17d1e8a
tidy
foodprocessor Apr 22, 2026
9dcd53e
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor Apr 22, 2026
e2902b2
fixup
foodprocessor Apr 22, 2026
1e5fd24
Fix pending op test to work with deletion flag.
foodprocessor Apr 22, 2026
c5c3a27
clean up createdir logic in attribute cache
foodprocessor Apr 22, 2026
e19cf3e
Remove redundant stat checks and tidy up
foodprocessor Apr 22, 2026
d79c8a9
Add another redundant check.
foodprocessor Apr 22, 2026
ea07aab
Optimize directory GetAttr listing by looking for markers first.
foodprocessor Apr 22, 2026
e24736e
Fix print format
foodprocessor Apr 23, 2026
081ad1b
When a local file exists, return local stat info from GetAttr even wh…
foodprocessor Apr 23, 2026
d441705
Improve logic
foodprocessor Apr 23, 2026
4df9022
Improve notInCloud to handle directory structure
foodprocessor Apr 24, 2026
d4aa92b
scrub RenameFile
foodprocessor Apr 24, 2026
016069a
Improve GetAttr logic to handle subfolders
foodprocessor Apr 24, 2026
f72abb1
Serve partial directory listings when offline.
foodprocessor Apr 24, 2026
ce97690
Add directory drill up logic to attribute cache GetAttr
foodprocessor Apr 25, 2026
ba597a2
Now drop attr cache logic back out of checkCloud
foodprocessor Apr 25, 2026
d83a034
Simplify StreamDir logic
foodprocessor Apr 25, 2026
ad9d9f8
Give the hard limit its own helper
foodprocessor Apr 27, 2026
e344531
Wrap error when returning
foodprocessor Apr 27, 2026
253ada8
TruncateFile
foodprocessor Apr 27, 2026
65c3889
Update Chmod logic for new offline semantics
foodprocessor Apr 27, 2026
de32af1
Update chown logic to new offline semantics
foodprocessor Apr 27, 2026
e6b51a3
Do not call chmod from open unless O_CREAT is high.
foodprocessor Apr 28, 2026
2ae3958
Use a helper to avoid future copy paste errors with the deprecated os…
foodprocessor Apr 28, 2026
d1090d1
Don't allow lazy open when offline.
foodprocessor Apr 28, 2026
927c1d2
Add missing protections to CreateFile and DeleteDir.
foodprocessor Apr 30, 2026
eed564f
Improve variable names for clarity
foodprocessor Apr 30, 2026
606bbba
Improve chmod & chown logic.
foodprocessor May 1, 2026
59c6c7b
scrub updateObject
foodprocessor May 1, 2026
c4bf8c0
scrub TruncateDirName
foodprocessor May 1, 2026
e0f2cd4
Fix offline "drilling up..." bug
foodprocessor May 1, 2026
7fe7696
Add context.DeadlineExceeded as another trigger for offline recognition.
foodprocessor May 1, 2026
ab8bdca
Accept local directories into listing
foodprocessor May 1, 2026
3d71969
Copilot Create Delete
foodprocessor May 4, 2026
caddda2
Copilot unit tests for StreamDir, RenameDir, RenameFile, OpenFile, an…
foodprocessor May 5, 2026
b81178f
Copilot deadlock fix
foodprocessor May 5, 2026
23d118b
Add handle locks to prevent a data race on handle.Path.
foodprocessor May 5, 2026
63aceaf
Fix panic in updateObject
foodprocessor May 5, 2026
a780153
Don't extend dir names for pendingOps. That's what the isDir flag is …
foodprocessor May 5, 2026
de2a990
Include cached entries in StreamDir listings even when cloud state is…
foodprocessor May 5, 2026
700c455
Add more offline unit tests.
foodprocessor May 5, 2026
9023cfb
Don't delete objects which we already know don't exist.
foodprocessor May 5, 2026
23aa539
Remove obsolete scheduler test for previous design behavior.
foodprocessor May 5, 2026
ac2733f
Use isDeletion flag to update pending ops when deleting during schedu…
foodprocessor May 5, 2026
073e5da
Fix chown bugs.
foodprocessor May 5, 2026
2cc77d6
Update scheduled deletion test.
foodprocessor May 5, 2026
5ab1cbe
Add more nuance to chown to deal with nil-returning clouds.
foodprocessor May 5, 2026
0465cd0
Add eventual-assert pattern for better consistency and to speed up te…
foodprocessor May 5, 2026
6a710ee
Fix nil deref error
foodprocessor May 5, 2026
3f8c3e5
Return CloudUnreachableError when offline.
foodprocessor May 5, 2026
92f7044
Scrub attribute cache and add listingComplete flag.
foodprocessor May 6, 2026
446948b
Scrub attribute cache and add listingComplete flag.
foodprocessor May 6, 2026
fd74656
Merge remote-tracking branch 'origin/main' into network-fault-tolerance
foodprocessor May 6, 2026
d9b4884
Merge branch 'listing-complete-flag' into network-fault-tolerance
foodprocessor May 6, 2026
1069d8c
Add context and connection state to cloud storage components.
foodprocessor May 6, 2026
0327b9f
revert extra changes
foodprocessor May 6, 2026
51b7b30
Merge fixup
foodprocessor May 6, 2026
eca525f
First shot at persistence for the new pendingOp flag values.
foodprocessor May 6, 2026
5f8c564
fixup
foodprocessor May 7, 2026
dc967fa
Prevent async validate calls from resurrecting deleted nodes.
foodprocessor May 7, 2026
4ece5da
Change listingComplete to a timestamp so it can expire
foodprocessor May 8, 2026
900eee8
Revert "Change listingComplete to a timestamp so it can expire"
foodprocessor May 8, 2026
0ed88ac
Use timeout for listingComplete.
foodprocessor May 8, 2026
03bf432
Add unit tests for lstingComplete expiration.
foodprocessor May 8, 2026
bf0fdc1
Add GetAttr listingComplete test
foodprocessor May 8, 2026
30c69c1
Merge branch 'main' into listing-complete-flag
foodprocessor May 8, 2026
16fbff1
Merge remote-tracking branch 'origin/main' into stateful-cloud-storage
foodprocessor May 8, 2026
2d474b3
Merge branch 'dont-resurrect-deleted-nodes' into network-fault-tolerance
foodprocessor May 8, 2026
660bdb3
Merge branch 'stateful-cloud-storage' into network-fault-tolerance
foodprocessor May 8, 2026
9403dd0
Merge branch 'listing-complete-flag' into network-fault-tolerance
foodprocessor May 8, 2026
3ebdf56
Use heroics in IsDirEmpty to probe attribute cache for information.
foodprocessor May 8, 2026
d933a5d
Prevent attribute cache cleanup when offline.
foodprocessor May 8, 2026
25c367b
Add unit tests for IsDirEmpty heroics
foodprocessor May 8, 2026
b648ac8
Remove duplicate entries from StreamDir
foodprocessor May 8, 2026
0821538
Add documentation
foodprocessor May 8, 2026
74a729d
Correct unit test
foodprocessor May 8, 2026
6d95eea
CI fix: Cleanup shared space after each test
foodprocessor May 8, 2026
ce158c4
Check mount success before running end-to-end tests.
foodprocessor May 8, 2026
2ba79bd
Extend CI mount timeout to improve reliability.
foodprocessor May 9, 2026
6a75e83
Merge branch 'main' into listing-complete-flag
foodprocessor May 9, 2026
ffaebf8
Soften bucket cleanup failures, since they're so common.
foodprocessor May 9, 2026
4ae7257
Fix scheduler CI race
foodprocessor May 9, 2026
c14de73
Merge remote-tracking branch 'origin/main' into listing-complete-flag
foodprocessor May 9, 2026
3a51f38
Use cacheDirs flag consistently with listingComplete
foodprocessor May 14, 2026
7083bd5
Use type inference
foodprocessor May 14, 2026
d54de0b
Shorten IsDirEmpty cacheLock critical section
foodprocessor May 14, 2026
cb92363
Revert to switch
foodprocessor May 14, 2026
4ebac41
Merge branch 'listing-complete-flag' into network-fault-tolerance
foodprocessor May 14, 2026
1754fde
Fix silly logic bug
foodprocessor May 15, 2026
a9f0795
Enable console log output for CI failures
foodprocessor May 15, 2026
7d0dbf4
explicitly change log output to stdout
foodprocessor May 15, 2026
d5a8d57
Fix error type bug (!)
foodprocessor May 15, 2026
16d73b9
Copilot still trying to get log output in CI
foodprocessor May 15, 2026
783d429
Improve readability in cachedData(err)
foodprocessor May 15, 2026
7b42a80
Don't overwrite err before checking it for logging!
foodprocessor May 15, 2026
46f2c87
Update offline documentation to be more foreboding, and describe the …
foodprocessor May 15, 2026
774a18d
Disable SDK logging and increase log output lines
foodprocessor May 15, 2026
6996880
Add reassuring comment about polling CloudConnected
foodprocessor May 15, 2026
1e65a9f
Add apologetic comment about janky code
foodprocessor May 15, 2026
d6e63fa
Log GetAttr ENOENT to Debug
foodprocessor May 15, 2026
4ddef51
Add more logging
foodprocessor May 15, 2026
6c019af
Fix CommitData's semaphore abuse (RUnlock)
foodprocessor May 15, 2026
4f683f8
Add unit test for CommitData
foodprocessor May 15, 2026
a2b0b91
Improve semaphore protection in addDirsNotInCloudToListing
foodprocessor May 15, 2026
d178dbd
Revert debug changes
foodprocessor May 16, 2026
8a96334
fixup
foodprocessor May 16, 2026
6177c71
Fix identical logic bug in FlushFile
foodprocessor May 16, 2026
f0bc39e
Fix actual bug
foodprocessor May 16, 2026
cbeab18
Revert bogus fixes
foodprocessor May 16, 2026
9377654
Add missing env var on Windows coverage
foodprocessor May 16, 2026
912cd08
Merge branch 'listing-complete-flag' into network-fault-tolerance
foodprocessor May 16, 2026
c0eb7e2
Merge branch 'main' into network-fault-tolerance
foodprocessor May 16, 2026
52a73f3
Fix unit tests
foodprocessor May 16, 2026
7b94774
Add unit tests for offline functionality.
foodprocessor May 16, 2026
70ed311
Shorten timeouts and wait times.
foodprocessor May 16, 2026
cf00f5e
Fix unit test (listings are sorted)
foodprocessor May 16, 2026
9eab21c
Lint
foodprocessor May 16, 2026
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Cloudfuse supports clouds with an S3 or Azure interface.
- [From Source](#from-source)
- [Basic Use](#basic-use)
- [Health Monitor](#health-monitor)
- [Offline Access (New)](#offline-access-new)
- [Command Line Interface](#command-line-interface)
- [Limitations](#limitations)
- [License](#license)
Expand Down Expand Up @@ -307,6 +308,12 @@ Cloudfuse also supports a health monitor.
The health monitor allows customers gain more insight into how their Cloudfuse instance is behaving with the rest of their machine.
Visit [here](https://github.com/Seagate/cloudfuse/wiki/Health-Monitor) to set it up.

## Offline Access (New)

Cloudfuse now supports offline access through the `file_cache` component. When cloud storage is unreachable, reads and writes continue against the local cache and are flushed to cloud storage once connectivity is restored. The feature is **enabled by default** and can be disabled via the `block-offline-access` flag.

> **Note:** Cloudfuse uses eventual consistency with last-writer-wins semantics. Offline access can extend the consistency window indefinitely and **increases the risk of data conflicts in multi-client setups!** See [component/file_cache/OfflineAccess.md](component/file_cache/OfflineAccess.md) for full details and configuration guidance.

## Limitations

### NOTICE
Expand Down
3 changes: 1 addition & 2 deletions common/lock_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ type LockMapItem struct {
mtx sync.RWMutex
downloadTime time.Time
// track if file is in lazy open state
LazyOpen bool
SyncPending bool
LazyOpen bool
}

// Map holding locks for all the files
Expand Down
22 changes: 22 additions & 0 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,28 @@ func (e CloudUnreachableError) Is(target error) bool {
return ok
}

type NoCachedDataError struct {
Message string
CacheError error
}

func NewNoCachedDataError(originalError error) NoCachedDataError {
return NoCachedDataError{
Message: "Failed to connect to cloud storage",
CacheError: originalError,
}
}
func (e NoCachedDataError) Error() string {
return fmt.Sprintf("%s. Here's why: %v", e.Message, e.CacheError)
}
func (e NoCachedDataError) Unwrap() error {
return e.CacheError
}
func (e NoCachedDataError) Is(target error) bool {
_, ok := target.(*NoCachedDataError)
return ok
}

var DefaultWorkDir string
var DefaultLogFilePath string
var StatsConfigFilePath string
Expand Down
92 changes: 62 additions & 30 deletions component/attr_cache/attr_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ package attr_cache

import (
"context"
"errors"
"fmt"
"os"
"path"
Expand All @@ -36,6 +37,7 @@ import (
"syscall"
"time"

"github.com/Seagate/cloudfuse/common"
"github.com/Seagate/cloudfuse/common/config"
"github.com/Seagate/cloudfuse/common/log"
"github.com/Seagate/cloudfuse/internal"
Expand Down Expand Up @@ -403,6 +405,10 @@ func (ac *AttrCache) backgroundCleanup() {
// cleanupExpiredEntries: removes expired entries from the cache map
// This runs in a background goroutine to prevent memory leaks
func (ac *AttrCache) cleanupExpiredEntries() {
// do not cleanup when offline
if !ac.NextComponent().CloudConnected() {
return
}
// First pass: collect keys to delete under read lock to minimize write lock duration
var keysToDelete []string

Expand Down Expand Up @@ -577,6 +583,25 @@ func (ac *AttrCache) StreamDir(
options.Name, numAdded, len(pathList))
}
}
} else if errors.Is(err, &common.CloudUnreachableError{}) {
// return expired cachedPathList
if cachedPathList != nil {
pathList = cachedPathList
nextToken = cachedToken
} else {
// return whatever entries we have (but only if the token is empty)
entry, found := ac.cache.get(options.Name)
if options.Token == "" && found {
for _, v := range entry.children {
if v.exists() && v.valid() {
pathList = append(pathList, v.attr)
}
}
} else {
// the cloud is unavailable, and we have nothing to provide
err = common.NewNoCachedDataError(err)
}
}
}
// values should be returned in ascending order by key, without duplicates
// sort
Expand Down Expand Up @@ -627,7 +652,9 @@ func (ac *AttrCache) fetchCachedDirList(
listDirCache, found := ac.cache.get(path)
if !found {
log.Warn("AttrCache::fetchCachedDirList : %s directory not found in cache", path)
return nil, "", fmt.Errorf("%s directory not found in cache", path)
return nil, "", common.NewNoCachedDataError(
fmt.Errorf("%s directory not found in cache", path),
)
}
// is the requested data cached?
cachedListSegment, found := listDirCache.listCache[token]
Expand All @@ -640,9 +667,7 @@ func (ac *AttrCache) fetchCachedDirList(
// check timeout
if time.Since(cachedListSegment.cachedAt).Seconds() >= float64(ac.cacheTimeout) {
log.Info("AttrCache::fetchCachedDirList : %s listing segment %s cache expired", path, token)
// drop the invalid segment from the list cache
delete(listDirCache.listCache, token)
return nil, "", fmt.Errorf(
return cachedListSegment.entries, "", fmt.Errorf(
"%s directory listing segment %s cache expired",
path,
token,
Expand Down Expand Up @@ -714,12 +739,6 @@ func (ac *AttrCache) cacheListSegment(
}
// add the new entry
listDirItem.listCache[token] = newListCacheSegment
// scan the listing cache and remove expired entries
for k, v := range listDirItem.listCache {
if currTime.Sub(v.cachedAt).Seconds() >= float64(ac.cacheTimeout) {
delete(listDirItem.listCache, k)
}
}
log.Trace("AttrCache::cacheListSegment : %s cached list entries \"%s\"-\"%s\" (%d items)",
listDirPath, token, nextToken, len(pathList))
}
Expand Down Expand Up @@ -1175,20 +1194,23 @@ func (ac *AttrCache) GetAttr(options internal.GetAttrOptions) (*internal.ObjAttr
var errFromCache error
ac.cacheLock.RLock()
value, found := ac.cache.get(options.Name)
if found && value.valid() && time.Since(value.cachedAt).Seconds() < float64(ac.cacheTimeout) {
// Serve the request from the attribute cache
respondFromCache = true
if found && value.valid() {
// record cache response
if !value.exists() {
// log.Debug("AttrCache::GetAttr : %s found, (ENOENT) served from cache", options.Name)
errFromCache = syscall.ENOENT
} else {
// log.Debug("AttrCache::GetAttr : %s found, served from cache", options.Name)
attrFromCache = value.attr
}
} else if ac.cacheDirs {
// only serve this response if it's not expired
if time.Since(value.cachedAt).Seconds() < float64(ac.cacheTimeout) {
respondFromCache = true
}
}
if ac.cacheDirs && !respondFromCache {
// drill up for the nearest valid parent directory attribute cache
parent, found := ac.cache.getCachedParent(options.Name)
if found && time.Since(parent.cachedAt).Seconds() < float64(ac.cacheTimeout) {
if parent, found := ac.cache.getCachedParent(options.Name); found {
// Remember, we have no entry for options.Name
// parent is its nearest valid ancestor
// So, if parent doesn't exist, options.Name must not exist
Expand All @@ -1200,8 +1222,9 @@ func (ac *AttrCache) GetAttr(options internal.GetAttrOptions) (*internal.ObjAttr
// options.Name,
// parent.exists(),
// )
respondFromCache = true
errFromCache = syscall.ENOENT
// only serve this response if it's not expired
respondFromCache = time.Since(parent.cachedAt).Seconds() < float64(ac.cacheTimeout)
}
}
}
Expand All @@ -1213,18 +1236,12 @@ func (ac *AttrCache) GetAttr(options internal.GetAttrOptions) (*internal.ObjAttr
// The answer is not cached, or it's expired
// Get the attributes from next component
pathAttr, err := ac.NextComponent().GetAttr(options)
// return unexpected errors immediately (no valid response to cache)
if err != nil && !os.IsNotExist(err) {
log.Debug("AttrCache::GetAttr : %s encountered error [%v]", options.Name, err)
return pathAttr, err
}
// response is valid - cache it
ac.cacheLock.Lock()
defer ac.cacheLock.Unlock()
switch err {
case nil:
log.Debug("AttrCache::GetAttr : %s got attributes from cloud, caching result", options.Name)
switch {
case err == nil:
// Retrieved attributes so cache them
log.Debug("AttrCache::GetAttr : %s Caching record from cloud", options.Name)
ac.cacheLock.Lock()
defer ac.cacheLock.Unlock()
ac.cache.insert(insertOptions{
attr: pathAttr,
exists: true,
Expand All @@ -1233,14 +1250,29 @@ func (ac *AttrCache) GetAttr(options internal.GetAttrOptions) (*internal.ObjAttr
if ac.cacheDirs {
ac.markAncestorsInCloud(getParentDir(options.Name), time.Now())
}
case syscall.ENOENT:
log.Debug("AttrCache::GetAttr : %s not found, caching ENOENT result", options.Name)
case err == syscall.ENOENT:
// cache this entity not existing
log.Debug("AttrCache::GetAttr : %s Caching ENOENT from cloud", options.Name)
ac.cacheLock.Lock()
defer ac.cacheLock.Unlock()
ac.cache.insert(insertOptions{
attr: internal.CreateObjAttr(options.Name, 0, time.Now()),
exists: false,
cachedAt: time.Now(),
})
case errors.Is(err, &common.CloudUnreachableError{}):
// the cloud connection is down
// do we have an expired response from cache? Let's serve that.
haveExpiredResponse := attrFromCache != nil || errFromCache != nil
if haveExpiredResponse {
log.Warn("AttrCache::GetAttr : %s Serving expired cached data (offline)", options.Name)
return attrFromCache, errors.Join(errFromCache, err)
} else {
log.Err("AttrCache::GetAttr : %s No cached data (offline)", options.Name)
return nil, common.NewNoCachedDataError(err)
}
default:
log.Err("AttrCache::GetAttr : %s encountered error [%v]", options.Name, err)
}
return pathAttr, err
}
Expand Down
Loading
Loading