diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-22 20:42:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-22 20:42:14 -0500 |
commit | be5e6616dd74e17fdd8e16ca015cfef94d49b467 (patch) | |
tree | a18826e557f0d6636f1e05a4ec30d584ed981a2b /include | |
parent | 90c453ca2214394eec602d98e6cb92d151908493 (diff) | |
parent | 0a280962dc6e117e0e4baa668453f753579265d9 (diff) |
Merge branch 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more vfs updates from Al Viro:
"Assorted stuff from this cycle. The big ones here are multilayer
overlayfs from Miklos and beginning of sorting ->d_inode accesses out
from David"
* 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (51 commits)
autofs4 copy_dev_ioctl(): keep the value of ->size we'd used for allocation
procfs: fix race between symlink removals and traversals
debugfs: leave freeing a symlink body until inode eviction
Documentation/filesystems/Locking: ->get_sb() is long gone
trylock_super(): replacement for grab_super_passive()
fanotify: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
Cachefiles: Fix up scripted S_ISDIR/S_ISREG/S_ISLNK conversions
VFS: (Scripted) Convert S_ISLNK/DIR/REG(dentry->d_inode) to d_is_*(dentry)
SELinux: Use d_is_positive() rather than testing dentry->d_inode
Smack: Use d_is_positive() rather than testing dentry->d_inode
TOMOYO: Use d_is_dir() rather than d_inode and S_ISDIR()
Apparmor: Use d_is_positive/negative() rather than testing dentry->d_inode
Apparmor: mediated_filesystem() should use dentry->d_sb not inode->i_sb
VFS: Split DCACHE_FILE_TYPE into regular and special types
VFS: Add a fallthrough flag for marking virtual dentries
VFS: Add a whiteout dentry type
VFS: Introduce inode-getting helpers for layered/unioned fs environments
Infiniband: Fix potential NULL d_inode dereference
posix_acl: fix reference leaks in posix_acl_create
autofs4: Wrong format for printing dentry
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dcache.h | 103 |
1 files changed, 96 insertions, 7 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 92c08cf7670e..d8358799c594 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -215,13 +215,16 @@ struct dentry_operations { | |||
215 | #define DCACHE_LRU_LIST 0x00080000 | 215 | #define DCACHE_LRU_LIST 0x00080000 |
216 | 216 | ||
217 | #define DCACHE_ENTRY_TYPE 0x00700000 | 217 | #define DCACHE_ENTRY_TYPE 0x00700000 |
218 | #define DCACHE_MISS_TYPE 0x00000000 /* Negative dentry */ | 218 | #define DCACHE_MISS_TYPE 0x00000000 /* Negative dentry (maybe fallthru to nowhere) */ |
219 | #define DCACHE_DIRECTORY_TYPE 0x00100000 /* Normal directory */ | 219 | #define DCACHE_WHITEOUT_TYPE 0x00100000 /* Whiteout dentry (stop pathwalk) */ |
220 | #define DCACHE_AUTODIR_TYPE 0x00200000 /* Lookupless directory (presumed automount) */ | 220 | #define DCACHE_DIRECTORY_TYPE 0x00200000 /* Normal directory */ |
221 | #define DCACHE_SYMLINK_TYPE 0x00300000 /* Symlink */ | 221 | #define DCACHE_AUTODIR_TYPE 0x00300000 /* Lookupless directory (presumed automount) */ |
222 | #define DCACHE_FILE_TYPE 0x00400000 /* Other file type */ | 222 | #define DCACHE_REGULAR_TYPE 0x00400000 /* Regular file type (or fallthru to such) */ |
223 | #define DCACHE_SPECIAL_TYPE 0x00500000 /* Other file type (or fallthru to such) */ | ||
224 | #define DCACHE_SYMLINK_TYPE 0x00600000 /* Symlink (or fallthru to such) */ | ||
223 | 225 | ||
224 | #define DCACHE_MAY_FREE 0x00800000 | 226 | #define DCACHE_MAY_FREE 0x00800000 |
227 | #define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */ | ||
225 | 228 | ||
226 | extern seqlock_t rename_lock; | 229 | extern seqlock_t rename_lock; |
227 | 230 | ||
@@ -423,6 +426,16 @@ static inline unsigned __d_entry_type(const struct dentry *dentry) | |||
423 | return dentry->d_flags & DCACHE_ENTRY_TYPE; | 426 | return dentry->d_flags & DCACHE_ENTRY_TYPE; |
424 | } | 427 | } |
425 | 428 | ||
429 | static inline bool d_is_miss(const struct dentry *dentry) | ||
430 | { | ||
431 | return __d_entry_type(dentry) == DCACHE_MISS_TYPE; | ||
432 | } | ||
433 | |||
434 | static inline bool d_is_whiteout(const struct dentry *dentry) | ||
435 | { | ||
436 | return __d_entry_type(dentry) == DCACHE_WHITEOUT_TYPE; | ||
437 | } | ||
438 | |||
426 | static inline bool d_can_lookup(const struct dentry *dentry) | 439 | static inline bool d_can_lookup(const struct dentry *dentry) |
427 | { | 440 | { |
428 | return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE; | 441 | return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE; |
@@ -443,14 +456,25 @@ static inline bool d_is_symlink(const struct dentry *dentry) | |||
443 | return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE; | 456 | return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE; |
444 | } | 457 | } |
445 | 458 | ||
459 | static inline bool d_is_reg(const struct dentry *dentry) | ||
460 | { | ||
461 | return __d_entry_type(dentry) == DCACHE_REGULAR_TYPE; | ||
462 | } | ||
463 | |||
464 | static inline bool d_is_special(const struct dentry *dentry) | ||
465 | { | ||
466 | return __d_entry_type(dentry) == DCACHE_SPECIAL_TYPE; | ||
467 | } | ||
468 | |||
446 | static inline bool d_is_file(const struct dentry *dentry) | 469 | static inline bool d_is_file(const struct dentry *dentry) |
447 | { | 470 | { |
448 | return __d_entry_type(dentry) == DCACHE_FILE_TYPE; | 471 | return d_is_reg(dentry) || d_is_special(dentry); |
449 | } | 472 | } |
450 | 473 | ||
451 | static inline bool d_is_negative(const struct dentry *dentry) | 474 | static inline bool d_is_negative(const struct dentry *dentry) |
452 | { | 475 | { |
453 | return __d_entry_type(dentry) == DCACHE_MISS_TYPE; | 476 | // TODO: check d_is_whiteout(dentry) also. |
477 | return d_is_miss(dentry); | ||
454 | } | 478 | } |
455 | 479 | ||
456 | static inline bool d_is_positive(const struct dentry *dentry) | 480 | static inline bool d_is_positive(const struct dentry *dentry) |
@@ -458,10 +482,75 @@ static inline bool d_is_positive(const struct dentry *dentry) | |||
458 | return !d_is_negative(dentry); | 482 | return !d_is_negative(dentry); |
459 | } | 483 | } |
460 | 484 | ||
485 | extern void d_set_fallthru(struct dentry *dentry); | ||
486 | |||
487 | static inline bool d_is_fallthru(const struct dentry *dentry) | ||
488 | { | ||
489 | return dentry->d_flags & DCACHE_FALLTHRU; | ||
490 | } | ||
491 | |||
492 | |||
461 | extern int sysctl_vfs_cache_pressure; | 493 | extern int sysctl_vfs_cache_pressure; |
462 | 494 | ||
463 | static inline unsigned long vfs_pressure_ratio(unsigned long val) | 495 | static inline unsigned long vfs_pressure_ratio(unsigned long val) |
464 | { | 496 | { |
465 | return mult_frac(val, sysctl_vfs_cache_pressure, 100); | 497 | return mult_frac(val, sysctl_vfs_cache_pressure, 100); |
466 | } | 498 | } |
499 | |||
500 | /** | ||
501 | * d_inode - Get the actual inode of this dentry | ||
502 | * @dentry: The dentry to query | ||
503 | * | ||
504 | * This is the helper normal filesystems should use to get at their own inodes | ||
505 | * in their own dentries and ignore the layering superimposed upon them. | ||
506 | */ | ||
507 | static inline struct inode *d_inode(const struct dentry *dentry) | ||
508 | { | ||
509 | return dentry->d_inode; | ||
510 | } | ||
511 | |||
512 | /** | ||
513 | * d_inode_rcu - Get the actual inode of this dentry with ACCESS_ONCE() | ||
514 | * @dentry: The dentry to query | ||
515 | * | ||
516 | * This is the helper normal filesystems should use to get at their own inodes | ||
517 | * in their own dentries and ignore the layering superimposed upon them. | ||
518 | */ | ||
519 | static inline struct inode *d_inode_rcu(const struct dentry *dentry) | ||
520 | { | ||
521 | return ACCESS_ONCE(dentry->d_inode); | ||
522 | } | ||
523 | |||
524 | /** | ||
525 | * d_backing_inode - Get upper or lower inode we should be using | ||
526 | * @upper: The upper layer | ||
527 | * | ||
528 | * This is the helper that should be used to get at the inode that will be used | ||
529 | * if this dentry were to be opened as a file. The inode may be on the upper | ||
530 | * dentry or it may be on a lower dentry pinned by the upper. | ||
531 | * | ||
532 | * Normal filesystems should not use this to access their own inodes. | ||
533 | */ | ||
534 | static inline struct inode *d_backing_inode(const struct dentry *upper) | ||
535 | { | ||
536 | struct inode *inode = upper->d_inode; | ||
537 | |||
538 | return inode; | ||
539 | } | ||
540 | |||
541 | /** | ||
542 | * d_backing_dentry - Get upper or lower dentry we should be using | ||
543 | * @upper: The upper layer | ||
544 | * | ||
545 | * This is the helper that should be used to get the dentry of the inode that | ||
546 | * will be used if this dentry were opened as a file. It may be the upper | ||
547 | * dentry or it may be a lower dentry pinned by the upper. | ||
548 | * | ||
549 | * Normal filesystems should not use this to access their own dentries. | ||
550 | */ | ||
551 | static inline struct dentry *d_backing_dentry(struct dentry *upper) | ||
552 | { | ||
553 | return upper; | ||
554 | } | ||
555 | |||
467 | #endif /* __LINUX_DCACHE_H */ | 556 | #endif /* __LINUX_DCACHE_H */ |