From: Valerie Aurora <vaurora@xxxxxxxxxx> needs_lookup_union() tests if a path could possibly require a union lookup. Original-author: Valerie Aurora <vaurora@xxxxxxxxxx> Signed-off-by: David Howells <dhowells@xxxxxxxxxx> --- fs/union.h | 25 +++++++++++++++++++++++++ include/linux/dcache.h | 2 ++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/fs/union.h b/fs/union.h index 990dd16..757f28c 100644 --- a/fs/union.h +++ b/fs/union.h @@ -73,6 +73,26 @@ struct path *union_find_dir(struct dentry *dentry, unsigned int layer) return &dentry->d_union_stack->u_dirs[layer]; } +/* + * Determine whether we need to perform unionmount traversal or the copyup of a + * dentry. + */ +static inline +bool needs_lookup_union(struct path *parent_path, struct path *path) +{ + if (!IS_DIR_UNIONED(parent_path->dentry)) + return false; + + /* Either already built or crossed a mountpoint to not-unioned mnt */ + /* XXX are bind mounts root? think not */ + if (IS_ROOT(path->dentry)) + return false; + + /* It's okay not to have the lock; will recheck in lookup_union() */ + /* XXX set for root dentry at mount? */ + return !(path->dentry->d_flags & DCACHE_UNION_LOOKUP_DONE); +} + #else /* CONFIG_UNION_MOUNT */ static inline @@ -100,4 +120,9 @@ static inline int union_create_topmost_dir(struct path *parent, struct qstr *nam return 0; } +static inline bool needs_lookup_union(struct path *parent_path, struct path *path) +{ + return false; +} + #endif /* CONFIG_UNION_MOUNT */ diff --git a/include/linux/dcache.h b/include/linux/dcache.h index e2d44e1..79833ae 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -245,6 +245,8 @@ struct dentry_operations { #define DCACHE_MANAGED_DENTRY \ (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) +#define DCACHE_UNION_LOOKUP_DONE 0x100000 /* Union lookup was called on this dentry */ + extern seqlock_t rename_lock; static inline int dname_external(struct dentry *dentry) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html