From mboxrd@z Thu Jan 1 00:00:00 1970 From: Valerie Aurora Subject: [PATCH 35/74] union-mount: Create needs_lookup_union() Date: Tue, 22 Mar 2011 18:59:11 -0700 Message-ID: <1300845590-14184-36-git-send-email-valerie.aurora@gmail.com> References: <1300845590-14184-1-git-send-email-valerie.aurora@gmail.com> Cc: viro@zeniv.linux.org.uk, Valerie Aurora , Valerie Aurora To: linux-fsdevel@vger.kernel.org, linux@vger.kernel.org Return-path: Received: from mail-iw0-f174.google.com ([209.85.214.174]:40264 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756178Ab1CWCBw (ORCPT ); Tue, 22 Mar 2011 22:01:52 -0400 In-Reply-To: <1300845590-14184-1-git-send-email-valerie.aurora@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Valerie Aurora needs_lookup_union() tests if a path could possibly require a union lookup. Signed-off-by: Valerie Aurora --- fs/union.h | 16 ++++++++++++++++ include/linux/dcache.h | 1 + 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/fs/union.h b/fs/union.h index c496823..9efb177 100644 --- a/fs/union.h +++ b/fs/union.h @@ -57,6 +57,21 @@ extern int union_add_dir(struct path *, struct path *, unsigned int); extern int union_create_topmost_dir(struct path *, struct qstr *, struct path *, struct path *); +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); +} + static inline struct path *union_find_dir(struct dentry *dentry, unsigned int layer) { BUG_ON(layer >= dentry->d_sb->s_union_count); @@ -72,6 +87,7 @@ static inline struct path *union_find_dir(struct dentry *dentry, #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 ddf3d2d..c37b621 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -209,6 +209,7 @@ d_iput: no no no yes #define DCACHE_WHITEOUT 0x0200 /* Stop lookup in a unioned file system */ #define DCACHE_FALLTHRU 0x0400 /* Continue lookup below an opaque dir */ +#define DCACHE_UNION_LOOKUP_DONE 0x0800 /* Union lookup was called on this dentry */ extern spinlock_t dcache_lock; extern seqlock_t rename_lock; -- 1.7.0.4