Fix VFS cache consistency race
Accessing the same file on the lower filesystem (via ContentResolver)
and the upper filesystem (via FUSE file path with VFS caching) can
lead to file corrpution.
I94c8cbed32567e807259d67a6a9a4ea470158d9e fixed this issue with a
clever use of file locks, however there is a potential race:
T1: is_file_locked {use_cache: true} //1
T2: node->HasCachedHandle //2
T1: h = new handle(use_cache); node->AddHandle(h) //3
T2: set_file_locked {use_fuse: false} //4
Now, T1 is accessing the file over file path with VFS cache and T2 is
accessing the same file over ContentResolver.
Fixed by ensuring the following operations are atomic: 1-3 and 2-4
This also prevents the following bug:
T1: node->LookupAbsolutePath
T2: delete node
T1: node->HasCachedHandle
Test: m
Bug: 148709965
Change-Id: I54844f0c21084955c107dc76d346b79919635263
1 file changed