Skip to content

Conversation

@imsodin
Copy link
Member

@imsodin imsodin commented Sep 12, 2024

This would have addressed a recent issue that arose when re-ordering our "filesystem layers". Specifically moving the caseFilesystem to the outermost layer. The previous cache included the filesystem, and as such all the layers below. This isn't desirable (to put it mildly), as you can create different variants of filesystems with different layers for the same path and options. Concretely this did happen with the mtime layer, which isn't always present. A test for the mtime related breakage was added in #9687, and I intend to redo the caseFilesystem reordering after this.

Ref: #9677
Followup to: #9687

@imsodin
Copy link
Member Author

imsodin commented Sep 12, 2024

Not sure if this is really chore, might also be fix. It's just pre-emptive, as in it doesn't fix anything now, because the trigger of the issue was already reverted.

@calmh calmh changed the title chore(fs): Only cache the cache for case FS, not the entire FS chore(fs): only cache the cache for case FS, not the entire FS Sep 12, 2024
lib/fs/casefs.go Outdated
}

func newDefaultRealCaser(fs Filesystem) *defaultRealCaser {
type caseCache = *lru.TwoQueueCache[string, *caseNode]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This confused me up until reading this line, because the map[fskey]caseCache looks like a map of something not-pointer-shaped, and yet here we are with a pointer. I think I'd prefer the alias to not include the pointer star, and have that be visible at the places it's used instead...

Copy link
Member

@calmh calmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable, apart from clarity complaint

@imsodin imsodin force-pushed the fs/casefs-cache-cache branch from 3c64a68 to 86ca6ea Compare September 12, 2024 10:45
This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
@imsodin imsodin force-pushed the fs/casefs-cache-cache branch from 86ca6ea to 3297e86 Compare September 12, 2024 10:46
Copy link
Member

@calmh calmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right on

@calmh calmh merged commit ac8b334 into syncthing:main Sep 12, 2024
@imsodin imsodin deleted the fs/casefs-cache-cache branch September 12, 2024 20:09
@calmh calmh added this to the v1.28.0 milestone Sep 22, 2024
leoon-ding pushed a commit to leoon-ding/syncthing that referenced this pull request Mar 19, 2025
…hing#9701)

This would have addressed a recent issue that arose when re-ordering our
"filesystem layers". Specifically moving the caseFilesystem to the
outermost layer. The previous cache included the filesystem, and as such
all the layers below. This isn't desirable (to put it mildly), as you
can create different variants of filesystems with different layers for
the same path and options. Concretely this did happen with the mtime
layer, which isn't always present. A test for the mtime related breakage
was added in syncthing#9687, and I intend to redo the caseFilesystem reordering
after this.

Ref: syncthing#9677
Followup to: syncthing#9687
@calmh calmh added the chore label May 29, 2025
marbens-arch added a commit to marbens-arch/syncthing that referenced this pull request Aug 27, 2025
marbens-arch added a commit to marbens-arch/syncthing that referenced this pull request Oct 17, 2025
In syncthing#9701 there was a semi-unrelated change to bind the `getExpireAdd` mutex and `getExpireAdd` itself to
`defaultRealCaser`, instead of `caseCache`.
This is erroneous because multiple `defaultRealCaser`s can share the same `caseCache`.

Signed-off-by: Marcus B Spencer <marcus@marcusspencer.us>
imsodin pushed a commit that referenced this pull request Oct 18, 2025
)

In #9701 there was a change that put the mutex used for `getExpireAdd` directly in `defaultRealCaser`, which is erroneous because multiple filesystems can share the same `caseCache`.

### Purpose

Fixes #9836 and [Slow sync sending files from Android](https://forum.syncthing.net/t/slow-sync-sending-files-from-android/24208?u=marbens). There may be other issues caused by `getExpireAdd` conflicting with itself, though.

### Testing

Unit tests pass and the case cache and conflict detection _seem_ to behave correctly.

Signed-off-by: Marcus B Spencer <marcus@marcusspencer.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants