History

fs/namei.c: keep track of nd->root refcount status

The rules for nd->root are messy: * if we have LOOKUP_ROOT, it doesn't contribute to refcounts * if we have LOOKUP_RCU, it doesn't contribute to refcounts * if nd->root.mnt is NULL, it doesn't contribute to refcounts * otherwise it does contribute terminate_walk() needs to drop the references if they are contributing. So everything else should be careful not to confuse it, leading to rather convoluted code. It's easier to keep track of whether we'd grabbed the reference(s) explicitly. Use a new flag for that. Don't bother with zeroing nd->root.mnt on unlazy failures and in terminate_walk - it's not needed anymore (terminate_walk() won't care and the next path_init() will zero nd->root in !LOOKUP_ROOT case anyway). Resulting rules for nd->root refcounts are much simpler: they are contributing iff LOOKUP_ROOT_GRABBED is set in nd->flags.

Al Viro committed 7 years ago

Commit 84a2bd31 parent ee594bf2 files · +16 −26Browse files

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

Unified · Split

include/linux/namei.h+1−0
@@ -37,6 +37,7 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND}; · 36 unmodified lines
3737 #define LOOKUP_NO_REVAL 0x0080
3838 #define LOOKUP_JUMPED 0x1000
3939 #define LOOKUP_ROOT 0x2000
40+#define LOOKUP_ROOT_GRABBED 0x0008
4041
4142 extern int path_pts(struct path *path);
4243

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