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
Handle daylight savings time changes with FAT filesystems #9227
Comments
And don't FAT filesystems have only two-second granularity? |
I think one potential problem with Android may be that it is impossible to know for sure whether the filesystem is FAT. The current code only checks whether the filesystem is one of the |
They do, but I don't think that affects this.
I don't think we have to care. A better filesystem will have better timestamp precision, rendering false positives due to chance exceedingly unlikely, so we can just use the same logic always. (ext3 being the exception I guess, having only one-second precision, it's possible we would miss precisely one file update if it happened precisely 3600 seconds since the previous change, and didn't change file size or anything else we look at.) |
Do we really want to add these hacks to support a 30 year old filesystem? Similarly like we kind of don't support old os'es, I don't see why we should add hacks for old filesystem, especially where the "doesn't work" is an event that happens twice a year, in some places, and just burns some cpu cyclea for some time. |
We do. "Inclusive" is rather high on our Goals list, (unfortunately?)
Agreed. Unless we can reliably detect that both a) the filesystem is affected (i.e. FAT) and b) timezone is affected (i.e. not UTC or any other TZ with no DST), it's a bad idea to implement this. That said, the fact that a timezone can be unaffected by DST now but change it the next year (or vice versa), opens a can of worms of the size I wouldn't want to deal with.
I second that. However, I can envision a change occuring at the same time, and a wrong state winning and propagating due to "wrong" timestamp in a setup where one system has this time-shift issue and another one doesn't… |
I'm with @AudriusButkevicius on this one. The beneficiary of this hack would be Android, and only for SD cards, which are being phased out by most manufacturers. |
I guess my words were wrong. The filesystem is already supported, for some definition of supported, but I think there is already enough code working around the sadness of FAT. Some of it is kind of fundamental for the application to function, but this one is a mild inconvenience at best, and I'm happy for it to stay there to nudge people onto newer better supported things. |
Not only for SD cards. FAT is used for all user storage on Android, including internal and external. In other words, this problem basically affects all Syncthing users on Android. |
"It's an old filesystem" is true, but doesn't carry much water when it's used as the primary storage in the latest and greatest version of platforms we supposedly support. Unless the point is that Android users should upgrade to iOS, thus avoiding the hassle of both FAT and Syncthing simultaneously. To me this sounds like a one or two-line hack that will make things better for a non-negligible subset of users, while having no significant real-word downsides. |
Are you sure? |
Is this for the Just to avoid confusion, |
@calmh Agreed. My thought was we could use gopsutil's PartitionStat.Fstype to see if the mount is a FAT variant. If that fails (or is non-determinitive), we could see if the filesystem supports sub-two-second timestamp granularity. |
Pretty sure that the whole |
Thanks for clarification! My information was a bit outdated then. I would only add that the above seems to only be applicable to devices that came out with Android 11 out of the box. For example, my phone runs Android 11 but was originally released with Android 9, and the filesystem is still |
I'm the author of the original suggestion, I recommend reading the link in the first post as to why this is an annoying problem from my perspective and experience. All my mobile phones have had and will always have some sort of memory card, now 0.5TB (Android 9 + MIUI) and 1TB (Android 13 + MIUI) micro SDXC cards, and I believe mobile phones with SD cards will not die out! I have also used root and am not about to resign to my backup and data workflow needs. So let's not address that it's an outdated file system, that not enough people use it, that the Android API is bad, that there won't be SD cards in mobile phones, or that people don't travel (see below), thank you. First, ST rescan on FAT affects not only daylight saving time, but also travel/changes between time zones, and in that case the first solution proposed by calmh is completely unusable, because there are time zones in the world even like UTC+5:30 (India) or UTC+5:45 (Nepal), so purely 1 or X hour offset is not a solution. Second, if there is already timestamp virtualization via FAT using mtimefs, then in my opinion it is sufficient to add one correction "constant" to correct the ST and rescan behavior according to the current time offset detection. Time offset detection methods:
Maybe you can come up with other algorithms, but I think these three in some combination can provide a high level of prevention of false and unnecessary rescans and unnecessary synchronization of misleading metadata to other clients. Especially when I have hundreds of GB of data on my SD cards. BTW: If anyone has tried exFAT or some other file format to solve the described problems, I'd be happy to try it for myself (without root for now!). |
FAT filesystems store timestamps in reference to whatever the computer considers local time. This means that when time changes due to daylight savings the timestamps all shift by one hour in some direction, causing files to be rehashed and resynced (at least metadata wise).
Discussion: https://forum.syncthing.net/t/unwanted-full-rescan-resync-sd-card-syncthing-android-after-timezone-daylight-saving-change/21064
It's of course also possible for "local time" to be UTC or another zone that doesn't shift, or the filesystem can be mounted with
tz=UTC
to store timestamps in UTC. But this is not the most common setup on Windows or Android where FAT is more common.One solution to all this, implemented by OwnCloud and possibly other sync programs, is to ignore timestamp changes of precisely one hour. We could do the same. We even have a good place to do it -- the mtimefs. We already virtualize the timestamp on top of what's actually on the filesystem, we would more or less just need to accept differences of precisely one hour where we check for equality.
In theory this means some changes might not get picked up, but it will be rare in practice. On filesystems with better than second timestamp precision it would be essentially impossible to trigger by mistake.
The text was updated successfully, but these errors were encountered: