History

fscache: Fix invalidation/lookup race

If an NFS file is opened for writing and closed, fscache_invalidate() will be asked to invalidate the file - however, if the cookie is in the LOOKING_UP state (or the CREATING state), then request to invalidate doesn't get recorded for fscache_cookie_state_machine() to do something with. Fix this by making __fscache_invalidate() set a flag if it sees the cookie is in the LOOKING_UP state to indicate that we need to go to invalidation. Note that this requires a count on the n_accesses counter for the state machine, which that will release when it's done. fscache_cookie_state_machine() then shifts to the INVALIDATING state if it sees the flag. Without this, an nfs file can get corrupted if it gets modified locally and then read locally as the cache contents may not get updated.

David Howells committed 4 years ago

Commit 85e4ea11 parent 65aa5f62 files · +15 −1Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/fscache.h+1−0
@@ -130,6 +130,7 @@ struct fscache_cookie { · 129 unmodified lines
130#define FSCACHE_COOKIE_DO_PREP_TO_WRITE 12 /* T if cookie needs write preparation */130#define FSCACHE_COOKIE_DO_PREP_TO_WRITE 12 /* T if cookie needs write preparation */
131#define FSCACHE_COOKIE_HAVE_DATA 13 /* T if this cookie has data stored */131#define FSCACHE_COOKIE_HAVE_DATA 13 /* T if this cookie has data stored */
132#define FSCACHE_COOKIE_IS_HASHED 14 /* T if this cookie is hashed */132#define FSCACHE_COOKIE_IS_HASHED 14 /* T if this cookie is hashed */
133#define FSCACHE_COOKIE_DO_INVALIDATE 15 /* T if cookie needs invalidation */
133 134
134 enum fscache_cookie_state state;135 enum fscache_cookie_state state;
135 u8 advice; /* FSCACHE_ADV_* */136 u8 advice; /* FSCACHE_ADV_* */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t