From: Valerie Aurora <vaurora@xxxxxxxxxx> needs_lookup_union() tests if a path could possibly require a union lookup. --- fs/union.h | 17 +++++++++++++++++ include/linux/dcache.h | 2 ++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/fs/union.h b/fs/union.h index 89527b7..54427ba 100644 --- a/fs/union.h +++ b/fs/union.h @@ -64,6 +64,22 @@ struct path *union_find_dir(struct dentry *dentry, unsigned int layer) return &dentry->d_union_stack->u_dirs[layer]; } +static inline +int needs_lookup_union(struct path *parent_path, struct path *path) +{ + if (!IS_DIR_UNIONED(parent_path->dentry)) + return 0; + + /* Either already built or crossed a mountpoint to not-unioned mnt */ + /* XXX are bind mounts root? think not */ + if (IS_ROOT(path->dentry)) + return 0; + + /* 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 */ #define IS_MNT_UNION(x) (0) @@ -73,6 +89,7 @@ struct path *union_find_dir(struct dentry *dentry, unsigned int layer) #define union_add_dir(x, y, z) ({ BUG(); (0); }) #define union_find_dir(x, y) ({ BUG(); (NULL); }) #define union_create_topmost_dir(w, x, y, z) ({ BUG(); (0); }) +#define needs_lookup_union(x, y) ({ (0); }) #endif /* CONFIG_UNION_MOUNT */ #endif /* __KERNEL__ */ diff --git a/include/linux/dcache.h b/include/linux/dcache.h index eb8fbf8..f5442ec 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -244,6 +244,8 @@ struct dentry_operations { #define DCACHE_MANAGED_DENTRY \ (DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT) +#define DCACHE_UNION_LOOKUP_DONE 0x080000 /* 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