diff options
author | David Howells <dhowells@redhat.com> | 2013-09-12 14:22:53 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:30 -0500 |
commit | b18825a7c8e37a7cf6abb97a12a6ad71af160de7 (patch) | |
tree | c3556fc0195f15382d636188f3d4e5fa418d7379 /include/linux/dcache.h | |
parent | afabada957a6b28abfd37eb52efeefdfe6871c4b (diff) |
VFS: Put a small type field into struct dentry::d_flags
Put a type field into struct dentry::d_flags to indicate if the dentry is one
of the following types that relate particularly to pathwalk:
Miss (negative dentry)
Directory
"Automount" directory (defective - no i_op->lookup())
Symlink
Other (regular, socket, fifo, device)
The type field is set to one of the first five types on a dentry by calls to
__d_instantiate() and d_obtain_alias() from information in the inode (if one is
given).
The type is cleared by dentry_unlink_inode() when it reconstitutes an existing
dentry as a negative dentry.
Accessors provided are:
d_set_type(dentry, type)
d_is_directory(dentry)
d_is_autodir(dentry)
d_is_symlink(dentry)
d_is_file(dentry)
d_is_negative(dentry)
d_is_positive(dentry)
A bunch of checks in pathname resolution switched to those.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/dcache.h')
-rw-r--r-- | include/linux/dcache.h | 103 |
1 files changed, 83 insertions, 20 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 716c3760ee39..57e87e749a48 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -169,13 +169,13 @@ struct dentry_operations { | |||
169 | */ | 169 | */ |
170 | 170 | ||
171 | /* d_flags entries */ | 171 | /* d_flags entries */ |
172 | #define DCACHE_OP_HASH 0x0001 | 172 | #define DCACHE_OP_HASH 0x00000001 |
173 | #define DCACHE_OP_COMPARE 0x0002 | 173 | #define DCACHE_OP_COMPARE 0x00000002 |
174 | #define DCACHE_OP_REVALIDATE 0x0004 | 174 | #define DCACHE_OP_REVALIDATE 0x00000004 |
175 | #define DCACHE_OP_DELETE 0x0008 | 175 | #define DCACHE_OP_DELETE 0x00000008 |
176 | #define DCACHE_OP_PRUNE 0x0010 | 176 | #define DCACHE_OP_PRUNE 0x00000010 |
177 | 177 | ||
178 | #define DCACHE_DISCONNECTED 0x0020 | 178 | #define DCACHE_DISCONNECTED 0x00000020 |
179 | /* This dentry is possibly not currently connected to the dcache tree, in | 179 | /* This dentry is possibly not currently connected to the dcache tree, in |
180 | * which case its parent will either be itself, or will have this flag as | 180 | * which case its parent will either be itself, or will have this flag as |
181 | * well. nfsd will not use a dentry with this bit set, but will first | 181 | * well. nfsd will not use a dentry with this bit set, but will first |
@@ -186,30 +186,38 @@ struct dentry_operations { | |||
186 | * dentry into place and return that dentry rather than the passed one, | 186 | * dentry into place and return that dentry rather than the passed one, |
187 | * typically using d_splice_alias. */ | 187 | * typically using d_splice_alias. */ |
188 | 188 | ||
189 | #define DCACHE_REFERENCED 0x0040 /* Recently used, don't discard. */ | 189 | #define DCACHE_REFERENCED 0x00000040 /* Recently used, don't discard. */ |
190 | #define DCACHE_RCUACCESS 0x0080 /* Entry has ever been RCU-visible */ | 190 | #define DCACHE_RCUACCESS 0x00000080 /* Entry has ever been RCU-visible */ |
191 | 191 | ||
192 | #define DCACHE_CANT_MOUNT 0x0100 | 192 | #define DCACHE_CANT_MOUNT 0x00000100 |
193 | #define DCACHE_GENOCIDE 0x0200 | 193 | #define DCACHE_GENOCIDE 0x00000200 |
194 | #define DCACHE_SHRINK_LIST 0x0400 | 194 | #define DCACHE_SHRINK_LIST 0x00000400 |
195 | 195 | ||
196 | #define DCACHE_OP_WEAK_REVALIDATE 0x0800 | 196 | #define DCACHE_OP_WEAK_REVALIDATE 0x00000800 |
197 | 197 | ||
198 | #define DCACHE_NFSFS_RENAMED 0x1000 | 198 | #define DCACHE_NFSFS_RENAMED 0x00001000 |
199 | /* this dentry has been "silly renamed" and has to be deleted on the last | 199 | /* this dentry has been "silly renamed" and has to be deleted on the last |
200 | * dput() */ | 200 | * dput() */ |
201 | #define DCACHE_COOKIE 0x2000 /* For use by dcookie subsystem */ | 201 | #define DCACHE_COOKIE 0x00002000 /* For use by dcookie subsystem */ |
202 | #define DCACHE_FSNOTIFY_PARENT_WATCHED 0x4000 | 202 | #define DCACHE_FSNOTIFY_PARENT_WATCHED 0x00004000 |
203 | /* Parent inode is watched by some fsnotify listener */ | 203 | /* Parent inode is watched by some fsnotify listener */ |
204 | 204 | ||
205 | #define DCACHE_MOUNTED 0x10000 /* is a mountpoint */ | 205 | #define DCACHE_DENTRY_KILLED 0x00008000 |
206 | #define DCACHE_NEED_AUTOMOUNT 0x20000 /* handle automount on this dir */ | 206 | |
207 | #define DCACHE_MANAGE_TRANSIT 0x40000 /* manage transit from this dirent */ | 207 | #define DCACHE_MOUNTED 0x00010000 /* is a mountpoint */ |
208 | #define DCACHE_NEED_AUTOMOUNT 0x00020000 /* handle automount on this dir */ | ||
209 | #define DCACHE_MANAGE_TRANSIT 0x00040000 /* manage transit from this dirent */ | ||
208 | #define DCACHE_MANAGED_DENTRY \ | 210 | #define DCACHE_MANAGED_DENTRY \ |
209 | (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) | 211 | (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) |
210 | 212 | ||
211 | #define DCACHE_LRU_LIST 0x80000 | 213 | #define DCACHE_LRU_LIST 0x00080000 |
212 | #define DCACHE_DENTRY_KILLED 0x100000 | 214 | |
215 | #define DCACHE_ENTRY_TYPE 0x00700000 | ||
216 | #define DCACHE_MISS_TYPE 0x00000000 /* Negative dentry */ | ||
217 | #define DCACHE_DIRECTORY_TYPE 0x00100000 /* Normal directory */ | ||
218 | #define DCACHE_AUTODIR_TYPE 0x00200000 /* Lookupless directory (presumed automount) */ | ||
219 | #define DCACHE_SYMLINK_TYPE 0x00300000 /* Symlink */ | ||
220 | #define DCACHE_FILE_TYPE 0x00400000 /* Other file type */ | ||
213 | 221 | ||
214 | extern seqlock_t rename_lock; | 222 | extern seqlock_t rename_lock; |
215 | 223 | ||
@@ -394,6 +402,61 @@ static inline bool d_mountpoint(const struct dentry *dentry) | |||
394 | return dentry->d_flags & DCACHE_MOUNTED; | 402 | return dentry->d_flags & DCACHE_MOUNTED; |
395 | } | 403 | } |
396 | 404 | ||
405 | /* | ||
406 | * Directory cache entry type accessor functions. | ||
407 | */ | ||
408 | static inline void __d_set_type(struct dentry *dentry, unsigned type) | ||
409 | { | ||
410 | dentry->d_flags = (dentry->d_flags & ~DCACHE_ENTRY_TYPE) | type; | ||
411 | } | ||
412 | |||
413 | static inline void __d_clear_type(struct dentry *dentry) | ||
414 | { | ||
415 | __d_set_type(dentry, DCACHE_MISS_TYPE); | ||
416 | } | ||
417 | |||
418 | static inline void d_set_type(struct dentry *dentry, unsigned type) | ||
419 | { | ||
420 | spin_lock(&dentry->d_lock); | ||
421 | __d_set_type(dentry, type); | ||
422 | spin_unlock(&dentry->d_lock); | ||
423 | } | ||
424 | |||
425 | static inline unsigned __d_entry_type(const struct dentry *dentry) | ||
426 | { | ||
427 | return dentry->d_flags & DCACHE_ENTRY_TYPE; | ||
428 | } | ||
429 | |||
430 | static inline bool d_is_directory(const struct dentry *dentry) | ||
431 | { | ||
432 | return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE; | ||
433 | } | ||
434 | |||
435 | static inline bool d_is_autodir(const struct dentry *dentry) | ||
436 | { | ||
437 | return __d_entry_type(dentry) == DCACHE_AUTODIR_TYPE; | ||
438 | } | ||
439 | |||
440 | static inline bool d_is_symlink(const struct dentry *dentry) | ||
441 | { | ||
442 | return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE; | ||
443 | } | ||
444 | |||
445 | static inline bool d_is_file(const struct dentry *dentry) | ||
446 | { | ||
447 | return __d_entry_type(dentry) == DCACHE_FILE_TYPE; | ||
448 | } | ||
449 | |||
450 | static inline bool d_is_negative(const struct dentry *dentry) | ||
451 | { | ||
452 | return __d_entry_type(dentry) == DCACHE_MISS_TYPE; | ||
453 | } | ||
454 | |||
455 | static inline bool d_is_positive(const struct dentry *dentry) | ||
456 | { | ||
457 | return !d_is_negative(dentry); | ||
458 | } | ||
459 | |||
397 | extern int sysctl_vfs_cache_pressure; | 460 | extern int sysctl_vfs_cache_pressure; |
398 | 461 | ||
399 | static inline unsigned long vfs_pressure_ratio(unsigned long val) | 462 | static inline unsigned long vfs_pressure_ratio(unsigned long val) |