Skip to content

Commit

Permalink
VFS: Add a fallthrough flag for marking virtual dentries
Browse files Browse the repository at this point in the history
Add a DCACHE_FALLTHRU flag to indicate that, in a layered filesystem, this is
a virtual dentry that covers another one in a lower layer that should be used
instead.  This may be recorded on medium if directory integration is stored
there.

The flag can be set with d_set_fallthru() and tested with d_is_fallthru().

Original-author: Valerie Aurora <[email protected]>
Signed-off-by: David Howells <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
dhowells authored and Al Viro committed Feb 22, 2015
1 parent e7f7d22 commit df1a085
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 18 additions & 1 deletion fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,22 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
}
EXPORT_SYMBOL(d_set_d_op);


/*
* d_set_fallthru - Mark a dentry as falling through to a lower layer
* @dentry - The dentry to mark
*
* Mark a dentry as falling through to the lower layer (as set with
* d_pin_lower()). This flag may be recorded on the medium.
*/
void d_set_fallthru(struct dentry *dentry)
{
spin_lock(&dentry->d_lock);
dentry->d_flags |= DCACHE_FALLTHRU;
spin_unlock(&dentry->d_lock);
}
EXPORT_SYMBOL(d_set_fallthru);

static unsigned d_flags_for_inode(struct inode *inode)
{
unsigned add_flags = DCACHE_FILE_TYPE;
Expand Down Expand Up @@ -1691,7 +1707,8 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
unsigned add_flags = d_flags_for_inode(inode);

spin_lock(&dentry->d_lock);
__d_set_type(dentry, add_flags);
dentry->d_flags &= ~(DCACHE_ENTRY_TYPE | DCACHE_FALLTHRU);
dentry->d_flags |= add_flags;
if (inode)
hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
dentry->d_inode = inode;
Expand Down
9 changes: 9 additions & 0 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ struct dentry_operations {
#define DCACHE_FILE_TYPE 0x00500000 /* Other file type (or fallthru to such) */

#define DCACHE_MAY_FREE 0x00800000
#define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */

extern seqlock_t rename_lock;

Expand Down Expand Up @@ -470,6 +471,14 @@ static inline bool d_is_positive(const struct dentry *dentry)
return !d_is_negative(dentry);
}

extern void d_set_fallthru(struct dentry *dentry);

static inline bool d_is_fallthru(const struct dentry *dentry)
{
return dentry->d_flags & DCACHE_FALLTHRU;
}


extern int sysctl_vfs_cache_pressure;

static inline unsigned long vfs_pressure_ratio(unsigned long val)
Expand Down

0 comments on commit df1a085

Please sign in to comment.