head	1.1;
access;
symbols
	LKML-branch:1.1.0.2;
locks; strict;
comment	@# @;


1.1
date	2006.10.24.06.14.17;	author jsipek;	state dead;
branches
	1.1.2.1;
next	;

1.1.2.1
date	2006.10.24.06.14.17;	author jsipek;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2006.11.07.06.13.33;	author jsipek;	state Exp;
branches;
next	1.1.2.3;

1.1.2.3
date	2006.11.28.08.06.50;	author jsipek;	state Exp;
branches;
next	1.1.2.4;

1.1.2.4
date	2006.11.28.08.17.51;	author jsipek;	state Exp;
branches;
next	1.1.2.5;

1.1.2.5
date	2006.11.28.08.30.13;	author jsipek;	state Exp;
branches;
next	1.1.2.6;

1.1.2.6
date	2006.12.01.02.28.38;	author jsipek;	state Exp;
branches;
next	1.1.2.7;

1.1.2.7
date	2006.12.01.02.36.12;	author jsipek;	state Exp;
branches;
next	1.1.2.8;

1.1.2.8
date	2006.12.03.21.49.41;	author jsipek;	state Exp;
branches;
next	1.1.2.9;

1.1.2.9
date	2006.12.11.14.23.59;	author jsipek;	state Exp;
branches;
next	1.1.2.10;

1.1.2.10
date	2007.01.04.22.12.00;	author jsipek;	state Exp;
branches;
next	1.1.2.11;

1.1.2.11
date	2007.01.21.23.59.13;	author jsipek;	state Exp;
branches;
next	;


desc
@@


1.1
log
@file lookup was initially added on branch LKML-branch.
@
text
@@


1.1.2.1
log
@Move unionfs specific bits into a subdir
@
text
@a0 521
Unionfs: Lookup helper functions

From: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>

This patch provides helper functions for the lookup operations in Unionfs.

Signed-off-by: Josef "Jeff" Sipek <jsipek@@cs.sunysb.edu>
Signed-off-by: David Quigley <dquigley@@fsl.cs.sunysb.edu>
Signed-off-by: Erez Zadok <ezk@@cs.sunysb.edu>

diff -r 7690631e814d fs/unionfs/lookup.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/unionfs/lookup.c	Sat Oct 07 00:29:47 2006 -0400
@@@@ -0,0 +1,507 @@@@
+/*
+ * Copyright (c) 2003-2006 Erez Zadok
+ * Copyright (c) 2003-2006 Charles P. Wright
+ * Copyright (c) 2005-2006 Josef 'Jeff' Sipek
+ * Copyright (c) 2005-2006 Junjiro Okajima
+ * Copyright (c) 2005      Arun M. Krishnakumar
+ * Copyright (c) 2004-2006 David P. Quigley
+ * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
+ * Copyright (c) 2003      Puja Gupta
+ * Copyright (c) 2003      Harikesavan Krishnan
+ * Copyright (c) 2003-2006 Stony Brook University
+ * Copyright (c) 2003-2006 The Research Foundation of State University of New York
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "union.h"
+
+static int is_opaque_dir(struct dentry *dentry, int bindex);
+static int is_validname(const char *name);
+
+struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd, int lookupmode)
+{
+	int err = 0;
+	struct dentry *hidden_dentry = NULL;
+	struct dentry *wh_hidden_dentry = NULL;
+	struct dentry *hidden_dir_dentry = NULL;
+	struct dentry *parent_dentry = NULL;
+	int bindex, bstart, bend, bopaque;
+	int dentry_count = 0;	/* Number of positive dentries. */
+	int first_dentry_offset = -1;
+	struct dentry *first_hidden_dentry = NULL;
+	struct vfsmount *first_hidden_mnt = NULL;
+	int locked_parent = 0;
+	int locked_child = 0;
+
+	int opaque;
+	char *whname = NULL;
+	const char *name;
+	int namelen;
+
+	/* We should already have a lock on this dentry in the case of a
+	 * partial lookup, or a revalidation. Otherwise it is returned from
+	 * new_dentry_private_data already locked.  */
+	if (lookupmode == INTERPOSE_PARTIAL || lookupmode == INTERPOSE_REVAL
+	    || lookupmode == INTERPOSE_REVAL_NEG)
+		verify_locked(dentry);
+	else {
+		BUG_ON(dtopd_nocheck(dentry) != NULL);
+		locked_child = 1;
+	}
+	if (lookupmode != INTERPOSE_PARTIAL)
+		if ((err = new_dentry_private_data(dentry)))
+			goto out;
+	/* must initialize dentry operations */
+	dentry->d_op = &unionfs_dops;
+
+	parent_dentry = dget_parent(dentry);
+	/* We never partial lookup the root directory. */
+	if (parent_dentry != dentry) {
+		lock_dentry(parent_dentry);
+		locked_parent = 1;
+	} else {
+		dput(parent_dentry);
+		parent_dentry = NULL;
+		goto out;
+	}
+
+	name = dentry->d_name.name;
+	namelen = dentry->d_name.len;
+
+	/* No dentries should get created for possible whiteout names. */
+	if (!is_validname(name)) {
+		err = -EPERM;
+		goto out_free;
+	}
+
+	/* Now start the actual lookup procedure. */
+	bstart = dbstart(parent_dentry);
+	bend = dbend(parent_dentry);
+	bopaque = dbopaque(parent_dentry);
+	BUG_ON(bstart < 0);
+
+	/* It would be ideal if we could convert partial lookups to only have
+	 * to do this work when they really need to.  It could probably improve
+	 * performance quite a bit, and maybe simplify the rest of the code. */
+	if (lookupmode == INTERPOSE_PARTIAL) {
+		bstart++;
+		if ((bopaque != -1) && (bopaque < bend))
+			bend = bopaque;
+	}
+
+	for (bindex = bstart; bindex <= bend; bindex++) {
+		hidden_dentry = dtohd_index(dentry, bindex);
+		if (lookupmode == INTERPOSE_PARTIAL && hidden_dentry)
+			continue;
+		BUG_ON(hidden_dentry != NULL);
+
+		hidden_dir_dentry = dtohd_index(parent_dentry, bindex);
+
+		/* if the parent hidden dentry does not exist skip this */
+		if (!(hidden_dir_dentry && hidden_dir_dentry->d_inode))
+			continue;
+
+		/* also skip it if the parent isn't a directory. */
+		if (!S_ISDIR(hidden_dir_dentry->d_inode->i_mode))
+			continue;
+
+		/* Reuse the whiteout name because its value doesn't change. */
+		if (!whname) {
+			whname = alloc_whname(name, namelen);
+			if (IS_ERR(whname)) {
+				err = PTR_ERR(whname);
+				goto out_free;
+			}
+		}
+
+		/* check if whiteout exists in this branch: lookup .wh.foo */
+		wh_hidden_dentry = lookup_one_len(whname, hidden_dir_dentry,
+						  namelen + UNIONFS_WHLEN);
+		if (IS_ERR(wh_hidden_dentry)) {
+			dput(first_hidden_dentry);
+			mntput(first_hidden_mnt);
+			err = PTR_ERR(wh_hidden_dentry);
+			goto out_free;
+		}
+
+		if (wh_hidden_dentry->d_inode) {
+			/* We found a whiteout so lets give up. */
+			if (S_ISREG(wh_hidden_dentry->d_inode->i_mode)) {
+				set_dbend(dentry, bindex);
+				set_dbopaque(dentry, bindex);
+				dput(wh_hidden_dentry);
+				break;
+			}
+			err = -EIO;
+			printk(KERN_NOTICE "EIO: Invalid whiteout entry type"
+			       " %d.\n", wh_hidden_dentry->d_inode->i_mode);
+			dput(wh_hidden_dentry);
+			dput(first_hidden_dentry);
+			mntput(first_hidden_mnt);
+			goto out_free;
+		}
+
+		dput(wh_hidden_dentry);
+		wh_hidden_dentry = NULL;
+
+		/* Now do regular lookup; lookup foo */
+		nd->dentry = dtohd_index(dentry, bindex);
+		/* FIXME: fix following line for mount point crossing */
+		nd->mnt = dtohm_index(parent_dentry, bindex);
+
+		hidden_dentry = lookup_one_len_nd(name, hidden_dir_dentry,
+					       namelen, nd);
+		if (IS_ERR(hidden_dentry)) {
+			dput(first_hidden_dentry);
+			mntput(first_hidden_mnt);
+			err = PTR_ERR(hidden_dentry);
+			goto out_free;
+		}
+
+		/* Store the first negative dentry specially, because if they
+		 * are all negative we need this for future creates. */
+		if (!hidden_dentry->d_inode) {
+			if (!first_hidden_dentry && (dbstart(dentry) == -1)) {
+				first_hidden_dentry = hidden_dentry;
+				/* FIXME: following line needs to be changed
+				 * to allow mountpoint crossing */
+				first_hidden_mnt = mntget(dtohm_index(parent_dentry, bindex));
+				first_dentry_offset = bindex;
+			} else
+				dput(hidden_dentry);
+
+			continue;
+		}
+
+		/* number of positive dentries */
+		dentry_count++;
+
+		/* store underlying dentry */
+		if (dbstart(dentry) == -1)
+			set_dbstart(dentry, bindex);
+		set_dtohd_index(dentry, bindex, hidden_dentry);
+		/* FIXME: the following line needs to get fixed to allow
+		 * mountpoint crossing */
+		set_dtohm_index(dentry, bindex, mntget(dtohm_index(parent_dentry, bindex)));
+		set_dbend(dentry, bindex);
+
+		/* update parent directory's atime with the bindex */
+		fist_copy_attr_atime(parent_dentry->d_inode,
+				     hidden_dir_dentry->d_inode);
+
+		/* We terminate file lookups here. */
+		if (!S_ISDIR(hidden_dentry->d_inode->i_mode)) {
+			if (lookupmode == INTERPOSE_PARTIAL)
+				continue;
+			if (dentry_count == 1)
+				goto out_positive;
+			/* This can only happen with mixed D-*-F-* */
+			BUG_ON(!S_ISDIR(dtohd(dentry)->d_inode->i_mode));
+			continue;
+		}
+
+		opaque = is_opaque_dir(dentry, bindex);
+		if (opaque < 0) {
+			dput(first_hidden_dentry);
+			mntput(first_hidden_mnt);
+			err = opaque;
+			goto out_free;
+		}
+		if (opaque) {
+			set_dbend(dentry, bindex);
+			set_dbopaque(dentry, bindex);
+			break;
+		}
+	}
+
+	if (dentry_count)
+		goto out_positive;
+	else
+		goto out_negative;
+
+out_negative:
+	if (lookupmode == INTERPOSE_PARTIAL)
+		goto out;
+
+	/* If we've only got negative dentries, then use the leftmost one. */
+	if (lookupmode == INTERPOSE_REVAL) {
+		if (dentry->d_inode)
+			itopd(dentry->d_inode)->uii_stale = 1;
+
+		goto out;
+	}
+	/* This should only happen if we found a whiteout. */
+	if (first_dentry_offset == -1) {
+		nd->dentry = dentry;
+		/* FIXME: fix following line for mount point crossing */
+		nd->mnt = dtohm_index(parent_dentry, bindex);
+
+		first_hidden_dentry = lookup_one_len_nd(name, hidden_dir_dentry,
+						     namelen, nd);
+		first_dentry_offset = bindex;
+		if (IS_ERR(first_hidden_dentry)) {
+			err = PTR_ERR(first_hidden_dentry);
+			goto out;
+		}
+		
+		/* FIXME: the following line needs to be changed to allow
+		 * mountpoint crossing */
+		first_hidden_mnt = mntget(dtohm_index(dentry, bindex));
+	}
+	set_dtohd_index(dentry, first_dentry_offset, first_hidden_dentry);
+	set_dtohm_index(dentry, first_dentry_offset, first_hidden_mnt);
+	set_dbstart(dentry, first_dentry_offset);
+	set_dbend(dentry, first_dentry_offset);
+
+	if (lookupmode == INTERPOSE_REVAL_NEG)
+		BUG_ON(dentry->d_inode != NULL);
+	else
+		d_add(dentry, NULL);
+	goto out;
+
+/* This part of the code is for positive dentries. */
+out_positive:
+	BUG_ON(dentry_count <= 0);
+
+	/* If we're holding onto the first negative dentry & corresponding
+	 * vfsmount - throw it out. */
+	dput(first_hidden_dentry);
+	mntput(first_hidden_mnt);
+
+	/* Partial lookups need to reinterpose, or throw away older negs. */
+	if (lookupmode == INTERPOSE_PARTIAL) {
+		if (dentry->d_inode) {
+			unionfs_reinterpose(dentry);
+			goto out;
+		}
+
+		/* This somehow turned positive, so it is as if we had a
+		 * negative revalidation.  */
+		lookupmode = INTERPOSE_REVAL_NEG;
+
+		update_bstart(dentry);
+		bstart = dbstart(dentry);
+		bend = dbend(dentry);
+	}
+
+	err = unionfs_interpose(dentry, dentry->d_sb, lookupmode);
+	if (err)
+		goto out_drop;
+
+	goto out;
+
+out_drop:
+	d_drop(dentry);
+
+out_free:
+	/* should dput all the underlying dentries on error condition */
+	bstart = dbstart(dentry);
+	if (bstart >= 0) {
+		bend = dbend(dentry);
+		for (bindex = bstart; bindex <= bend; bindex++) {
+			dput(dtohd_index(dentry, bindex));
+			mntput(dtohm_index(dentry, bindex));
+		}
+	}
+	kfree(dtohd_ptr(dentry));
+	kfree(dtohm_ptr(dentry));
+	dtohd_ptr(dentry) = NULL;
+	dtohm_ptr(dentry) = NULL;
+	set_dbstart(dentry, -1);
+	set_dbend(dentry, -1);
+
+out:
+	if (!err && dtopd(dentry)) {
+		BUG_ON(dbend(dentry) > dtopd(dentry)->udi_bcount);
+		BUG_ON(dbend(dentry) > sbmax(dentry->d_sb));
+		BUG_ON(dbstart(dentry) < 0);
+	}
+	kfree(whname);
+	if (locked_parent)
+		unlock_dentry(parent_dentry);
+	dput(parent_dentry);
+	if (locked_child)
+		unlock_dentry(dentry);
+	return ERR_PTR(err);
+}
+
+/* This is a utility function that fills in a unionfs dentry.*/
+int unionfs_partial_lookup(struct dentry *dentry)
+{
+	struct dentry *tmp;
+	struct nameidata nd = { .flags = 0 };
+
+	tmp = unionfs_lookup_backend(dentry, &nd, INTERPOSE_PARTIAL);
+	if (!tmp)
+		return 0;
+	if (IS_ERR(tmp))
+		return PTR_ERR(tmp);
+	/* need to change the interface */
+	BUG_ON(tmp != dentry);
+	return -ENOSYS;
+}
+
+/* The rest of these are utility functions for lookup. */
+static int is_opaque_dir(struct dentry *dentry, int bindex)
+{
+	int err = 0;
+	struct dentry *hidden_dentry;
+	struct dentry *wh_hidden_dentry;
+	struct inode *hidden_inode;
+	struct sioq_args args;
+
+	hidden_dentry = dtohd_index(dentry, bindex);
+	hidden_inode = hidden_dentry->d_inode;
+
+	BUG_ON(!S_ISDIR(hidden_inode->i_mode));
+
+	mutex_lock(&hidden_inode->i_mutex);
+
+	if (!permission(hidden_inode, MAY_EXEC, NULL))
+		wh_hidden_dentry = lookup_one_len(UNIONFS_DIR_OPAQUE, hidden_dentry,
+					sizeof(UNIONFS_DIR_OPAQUE) - 1);
+	else {
+		args.u.isopaque.dentry = hidden_dentry;
+		run_sioq(__is_opaque_dir, &args);
+		wh_hidden_dentry = args.ret;
+	}
+
+	mutex_unlock(&hidden_inode->i_mutex);
+
+	if (IS_ERR(wh_hidden_dentry)) {
+		err = PTR_ERR(wh_hidden_dentry);
+		goto out;
+	}
+
+	/* This is an opaque dir iff wh_hidden_dentry is positive */
+	err = !!wh_hidden_dentry->d_inode;
+
+	dput(wh_hidden_dentry);
+out:
+	return err;
+}
+
+static int is_validname(const char *name)
+{
+	if (!strncmp(name, UNIONFS_WHPFX, UNIONFS_WHLEN))
+		return 0;
+	if (!strncmp(name, UNIONFS_DIR_OPAQUE_NAME,
+		     sizeof(UNIONFS_DIR_OPAQUE_NAME) - 1))
+		return 0;
+	return 1;
+}
+
+/* The dentry cache is just so we have properly sized dentries. */
+static kmem_cache_t *unionfs_dentry_cachep;
+int init_dentry_cache(void)
+{
+	unionfs_dentry_cachep =
+	    kmem_cache_create("unionfs_dentry",
+			      sizeof(struct unionfs_dentry_info), 0,
+			      SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+
+	if (!unionfs_dentry_cachep)
+		return -ENOMEM;
+	return 0;
+}
+
+void destroy_dentry_cache(void)
+{
+	if (unionfs_dentry_cachep)
+		kmem_cache_destroy(unionfs_dentry_cachep);
+}
+
+void free_dentry_private_data(struct unionfs_dentry_info *udi)
+{
+	if (!udi)
+		return;
+	kmem_cache_free(unionfs_dentry_cachep, udi);
+}
+
+int new_dentry_private_data(struct dentry *dentry)
+{
+	int newsize;
+	int oldsize = 0;
+
+	spin_lock(&dentry->d_lock);
+	if (!dtopd(dentry)) {
+		dtopd_lhs(dentry) = (struct unionfs_dentry_info *)
+		    kmem_cache_alloc(unionfs_dentry_cachep, SLAB_ATOMIC);
+		if (!dtopd(dentry))
+			goto out;
+		init_MUTEX_LOCKED(&dtopd_nocheck(dentry)->udi_sem);
+
+		dtohd_ptr(dentry) = NULL;
+	} else
+		oldsize = sizeof(struct dentry *) * dtopd(dentry)->udi_bcount;
+
+	dtopd(dentry)->udi_bstart = -1;
+	dtopd(dentry)->udi_bend = -1;
+	dtopd(dentry)->udi_bopaque = -1;
+	dtopd(dentry)->udi_bcount = sbmax(dentry->d_sb);
+	atomic_set(&dtopd(dentry)->udi_generation,
+		   atomic_read(&stopd(dentry->d_sb)->usi_generation));
+	newsize = sizeof(void *) * sbmax(dentry->d_sb);
+
+	/* Don't reallocate when we already have enough space. */
+	/* It would be ideal if we could actually use the slab macros to
+	 * determine what our object sizes is, but those are not exported.
+	 */
+	if (oldsize) {
+		int minsize = malloc_sizes[0].cs_size;
+
+		if (!newsize || ((oldsize < newsize) && (newsize > minsize))) {
+			kfree(dtohd_ptr(dentry));
+			kfree(dtohm_ptr(dentry));
+			dtohd_ptr(dentry) = NULL;
+			dtohm_ptr(dentry) = NULL;
+		}
+	}
+
+	if (!dtohd_ptr(dentry) && newsize) {
+		dtohd_ptr(dentry) = kmalloc(newsize, GFP_ATOMIC);
+		dtohm_ptr(dentry) = kmalloc(newsize, GFP_ATOMIC);
+		if (!dtohd_ptr(dentry) || !dtohm_ptr(dentry))
+			goto out_free;
+	}
+
+	memset(dtohd_ptr(dentry), 0, (oldsize > newsize ? oldsize : newsize));
+	memset(dtohm_ptr(dentry), 0, (oldsize > newsize ? oldsize : newsize));
+
+	spin_unlock(&dentry->d_lock);
+	return 0;
+
+out_free:
+	kfree(dtohd_ptr(dentry));
+	kfree(dtohm_ptr(dentry));
+
+out:
+	free_dentry_private_data(dtopd(dentry));
+	dtopd_lhs(dentry) = NULL;
+	spin_unlock(&dentry->d_lock);
+	return -ENOMEM;
+}
+
+void update_bstart(struct dentry *dentry)
+{
+	int bindex;
+	int bstart = dbstart(dentry);
+	int bend = dbend(dentry);
+	struct dentry *hidden_dentry;
+
+	for (bindex = bstart; bindex <= bend; bindex++) {
+		hidden_dentry = dtohd_index(dentry, bindex);
+		if (!hidden_dentry)
+			continue;
+		if (hidden_dentry->d_inode) {
+			set_dbstart(dentry, bindex);
+			break;
+		}
+		dput(hidden_dentry);
+		set_dtohd_index(dentry, bindex, NULL);
+	}
+}
+
@


1.1.2.2
log
@Git generates slightly different diffs - same information, just little
different
@
text
@d11 3
a13 5
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
new file mode 100644
index 0000000..288f42a
--- /dev/null
+++ b/fs/unionfs/lookup.c
@


1.1.2.3
log
@Sync...
@
text
@d14 2
a15 4

diff -r 2414276470bb fs/unionfs/lookup.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fs/unionfs/lookup.c	Tue Nov 28 02:56:08 2006 -0500
d383 1
a383 1
+		args.isopaque.dentry = hidden_dentry;
@


1.1.2.4
log
@Collapse unionfs-struct_kmem_cache
@
text
@d15 1
a15 1
diff -r 679ff572c9dd fs/unionfs/lookup.c
d17 1
a17 1
+++ b/fs/unionfs/lookup.c	Tue Nov 28 03:10:01 2006 -0500
d416 1
a416 1
+static struct kmem_cache *unionfs_dentry_cachep;
@


1.1.2.5
log
@Collapsed: struct_path-unionfs unionfs-fix-comments unionfs-kill-wrappers
@
text
@d15 1
a15 1
diff -r 4d8de8db8e87 fs/unionfs/lookup.c
d17 2
a18 2
+++ b/fs/unionfs/lookup.c	Tue Nov 28 03:22:10 2006 -0500
@@@@ -0,0 +1,500 @@@@
d327 4
a330 2
+	kfree(dtohp_ptr(dentry));
+	dtohp_ptr(dentry) = NULL;
d455 1
a455 1
+		dtohp_ptr(dentry) = NULL;
d457 1
a457 1
+		oldsize = sizeof(struct path) * dtopd(dentry)->udi_bcount;
d465 1
a465 1
+	newsize = sizeof(struct path) * sbmax(dentry->d_sb);
d475 4
a478 2
+			kfree(dtohp_ptr(dentry));
+			dtohp_ptr(dentry) = NULL;
d482 4
a485 3
+	if (!dtohp_ptr(dentry) && newsize) {
+		dtohp_ptr(dentry) = kmalloc(newsize, GFP_ATOMIC);
+		if (!dtohp_ptr(dentry))
d489 2
a490 1
+	memset(dtohp_ptr(dentry), 0, (oldsize > newsize ? oldsize : newsize));
d496 2
a497 1
+	kfree(dtohp_ptr(dentry));
@


1.1.2.6
log
@Sync
@
text
@d15 1
a15 1
diff -r e229edfff3f1 fs/unionfs/lookup.c
d17 1
a17 1
+++ b/fs/unionfs/lookup.c	Thu Nov 30 20:55:37 2006 -0500
d210 1
a210 1
+		fsstack_copy_attr_atime(parent_dentry->d_inode,
@


1.1.2.7
log
@Remove git crud & nicer makefile
@
text
@d11 4
@


1.1.2.8
log
@Collapsed macro patch into unionfs proper
@
text
@d11 1
a11 1
diff -r 3deaa8aef460 fs/unionfs/lookup.c
d13 2
a14 2
+++ b/fs/unionfs/lookup.c	Sun Dec 03 16:38:17 2006 -0500
@@@@ -0,0 +1,506 @@@@
d38 1
a38 2
+struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd,
+				      int lookupmode)
d61 2
a62 2
+	if (lookupmode == INTERPOSE_PARTIAL || lookupmode == INTERPOSE_REVAL ||
+	    lookupmode == INTERPOSE_REVAL_NEG)
d65 1
a65 1
+		BUG_ON(UNIONFS_D(dentry) != NULL);
d110 1
a110 1
+		hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
d115 1
a115 1
+		hidden_dir_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
d165 1
a165 1
+		nd->dentry = unionfs_lower_dentry_idx(dentry, bindex);
d167 1
a167 1
+		nd->mnt = unionfs_lower_mnt_idx(parent_dentry, bindex);
d185 1
a185 1
+				first_hidden_mnt = mntget(unionfs_lower_mnt_idx(parent_dentry, bindex));
d199 1
a199 1
+		unionfs_set_lower_dentry_idx(dentry, bindex, hidden_dentry);
d202 1
a202 2
+		unionfs_set_lower_mnt_idx(dentry, bindex,
+			mntget(unionfs_lower_mnt_idx(parent_dentry, bindex)));
d216 1
a216 1
+			BUG_ON(!S_ISDIR(unionfs_lower_dentry(dentry)->d_inode->i_mode));
d226 2
a227 1
+		} else if (opaque) {
d246 1
a246 1
+			UNIONFS_I(dentry->d_inode)->stale = 1;
d254 1
a254 1
+		nd->mnt = unionfs_lower_mnt_idx(parent_dentry, bindex);
d266 1
a266 1
+		first_hidden_mnt = mntget(unionfs_lower_mnt_idx(dentry, bindex));
d268 2
a269 2
+	unionfs_set_lower_dentry_idx(dentry, first_dentry_offset, first_hidden_dentry);
+	unionfs_set_lower_mnt_idx(dentry, first_dentry_offset, first_hidden_mnt);
d319 2
a320 2
+			dput(unionfs_lower_dentry_idx(dentry, bindex));
+			mntput(unionfs_lower_mnt_idx(dentry, bindex));
d323 2
a324 2
+	kfree(UNIONFS_D(dentry)->lower_paths);
+	UNIONFS_D(dentry)->lower_paths = NULL;
d329 2
a330 2
+	if (!err && UNIONFS_D(dentry)) {
+		BUG_ON(dbend(dentry) > UNIONFS_D(dentry)->bcount);
d368 1
a368 1
+	hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
a398 1
+/* is the filename valid == !(whiteout for a file or opaque dir marker) */
d413 4
a416 3
+	unionfs_dentry_cachep = kmem_cache_create("unionfs_dentry",
+					sizeof(struct unionfs_dentry_info), 0,
+					SLAB_RECLAIM_ACCOUNT, NULL, NULL);
d418 3
a420 1
+	return (unionfs_dentry_cachep ? 0 : -ENOMEM);
a435 1
+/* allocate new dentry private data, free old one if necessary */
a439 1
+	struct unionfs_dentry_info *info = UNIONFS_D(dentry);
d442 4
a445 6
+	if (!info) {
+		dentry->d_fsdata = kmem_cache_alloc(unionfs_dentry_cachep,
+						SLAB_ATOMIC);
+		info = UNIONFS_D(dentry);
+
+		if (!info)
d447 1
a447 1
+		init_MUTEX_LOCKED(&info->sem);
d449 1
a449 1
+		info->lower_paths = NULL;
d451 1
a451 1
+		oldsize = sizeof(struct path) * info->bcount;
d453 6
a458 6
+	info->bstart = -1;
+	info->bend = -1;
+	info->bopaque = -1;
+	info->bcount = sbmax(dentry->d_sb);
+	atomic_set(&info->generation,
+		   atomic_read(&UNIONFS_SB(dentry->d_sb)->generation));
d469 2
a470 2
+			kfree(info->lower_paths);
+			info->lower_paths = NULL;
d474 3
a476 3
+	if (!info->lower_paths && newsize) {
+		info->lower_paths = kmalloc(newsize, GFP_ATOMIC);
+		if (!info->lower_paths)
d480 1
a480 1
+	memset(info->lower_paths, 0, (oldsize > newsize ? oldsize : newsize));
a483 1
+	/* */
d486 1
a486 1
+	kfree(info->lower_paths);
d489 2
a490 2
+	free_dentry_private_data(info);
+	dentry->d_fsdata = NULL;
a494 2
+/* scan through the lower dentry objects, and set bstart to reflect the
+ * starting branch */
d503 1
a503 1
+		hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
d511 1
a511 1
+		unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
@


1.1.2.9
log
@Folded unionfs-lkml-comments-jan
@
text
@d11 1
a11 1
diff -r 2b27189d982b fs/unionfs/lookup.c
d13 2
a14 2
+++ b/fs/unionfs/lookup.c	Mon Dec 11 09:04:53 2006 -0500
@@@@ -0,0 +1,516 @@@@
d61 1
a61 2
+	 * new_dentry_private_data already locked.
+	 */
d103 1
a103 2
+	 * performance quite a bit, and maybe simplify the rest of the code.
+	 */
d180 1
a180 2
+		 * are all negative we need this for future creates.
+		 */
d185 2
a186 5
+				 * to allow mountpoint crossing
+				 */
+				first_hidden_mnt = mntget(
+					unionfs_lower_mnt_idx(parent_dentry,
+								bindex));
d202 1
a202 2
+		 * mountpoint crossing
+		 */
d266 1
a266 2
+		 * mountpoint crossing
+		 */
d285 1
a285 2
+	 * vfsmount - throw it out.
+	 */
d297 1
a297 2
+		 * negative revalidation.
+		 */
d380 1
a380 1
+		args.is_opaque.dentry = hidden_dentry;
d413 1
a413 1
+int unionfs_init_dentry_cache(void)
d422 1
a422 1
+void unionfs_destroy_dentry_cache(void)
d487 1
d500 1
a500 2
+ * starting branch
+ */
@


1.1.2.10
log
@2.6.20-rc compile fixes
@
text
@d11 3
a13 5
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
new file mode 100644
index 0000000..576e224
--- /dev/null
+++ b/fs/unionfs/lookup.c
d455 1
a455 1
+						GFP_ATOMIC);
@


1.1.2.11
log
@A. Bunk's patch, more akpm comments, new copyright
@
text
@d13 1
a13 1
index 0000000..63b5719
d18 1
a18 1
+ * Copyright (c) 2003-2007 Erez Zadok
d20 1
a20 1
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
d27 2
a28 2
+ * Copyright (c) 2003-2007 Stony Brook University
+ * Copyright (c) 2003-2007 The Research Foundation of State University of New York
@


