RESOLVED FIXED 225767
Introduce FileSystem::hardLinkCount()
https://bugs.webkit.org/show_bug.cgi?id=225767
Summary Introduce FileSystem::hardLinkCount()
Chris Dumez
Reported 2021-05-13 08:56:15 PDT
Introduce FileSystem::hardLinkCount() to replace our platform-specific implementation in NetworkCacheBlobStorage.
Attachments
Patch (7.20 KB, patch)
2021-05-13 09:16 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (7.14 KB, patch)
2021-05-13 09:56 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (7.16 KB, patch)
2021-05-13 10:32 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (7.16 KB, patch)
2021-05-13 10:37 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2021-05-13 09:16:20 PDT
Chris Dumez
Comment 2 2021-05-13 09:56:47 PDT
Chris Dumez
Comment 3 2021-05-13 10:32:30 PDT
Chris Dumez
Comment 4 2021-05-13 10:37:34 PDT
Darin Adler
Comment 5 2021-05-13 12:09:23 PDT
Comment on attachment 428530 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=428530&action=review > Source/WTF/wtf/FileSystem.h:172 > +WTF_EXPORT_PRIVATE Optional<uint64_t> hardLinkCount(const String& path); We could consider in future using Expected instead of Optional here if callers might need to know what specific error occurred. > Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp:71 > + if (linkCount && *linkCount == 1) > + FileSystem::deleteFile(path); Does this single failure of hardLinkCount orphan a file forever and mean it will never get cleaned up? Obviously not new to this refactoring.
Chris Dumez
Comment 6 2021-05-13 12:17:51 PDT
(In reply to Darin Adler from comment #5) > Comment on attachment 428530 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=428530&action=review > > > Source/WTF/wtf/FileSystem.h:172 > > +WTF_EXPORT_PRIVATE Optional<uint64_t> hardLinkCount(const String& path); > > We could consider in future using Expected instead of Optional here if > callers might need to know what specific error occurred. > > > Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp:71 > > + if (linkCount && *linkCount == 1) > > + FileSystem::deleteFile(path); > > Does this single failure of hardLinkCount orphan a file forever and mean it > will never get cleaned up? Obviously not new to this refactoring. Antti is in cc and I believe he wrote this code. I am not sure how to best deal with this so I am not planning to address it in this patch. There could be several issues for hardLinkCount() to fail: 1. The file doesn't exist: No harm in this case not to delete the file 2. Permission issue: What are the odds deleteFile() is going to succeed then? Also, if we fail to get the hardlink count, there is really no way for sure for us to know the file is not useful anymore and is safe to be deleted.
Darin Adler
Comment 7 2021-05-13 12:23:39 PDT
(In reply to Chris Dumez from comment #6) > 1. The file doesn't exist: No harm in this case not to delete the file Agreed. > 2. Permission issue: What are the odds deleteFile() is going to succeed then? The question for us to ask is: Why would this happen in practice? What would we want for a user affected by this? > Also, if we fail to get the hardlink count, there is really no way for sure > for us to know the file is not useful anymore and is safe to be deleted. Absolutely, that’s right. We still have to ask the bigger question and figure out if there’s any issue here that has to be dealt with; that doesn’t necessarily mean this code would change.
EWS
Comment 8 2021-05-13 12:43:45 PDT
Committed r277446 (237694@main): <https://commits.webkit.org/237694@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 428530 [details].
Radar WebKit Bug Importer
Comment 9 2021-05-13 12:44:18 PDT
Antti Koivisto
Comment 10 2021-05-14 00:15:20 PDT
> Does this single failure of hardLinkCount orphan a file forever and mean it > will never get cleaned up? Obviously not new to this refactoring. No, we'll just try again on next synchronize(). The most likely reason this would fail is probably that the file already got deleted (by another instance of NetworkProcess running in the same cache directory for example). This is ok.
Note You need to log in before you can comment on or make changes to this bug.