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


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

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

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

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

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

1.1.2.5
date	2006.10.07.04.43.42;	author jsipek;	state dead;
branches;
next	;


desc
@@


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


1.1.2.1
log
@Few things here and there to make mount point crossing possible
@
text
@a0 107
diff -r c481a6bbd16b fs/unionfs/fanout.h
--- a/fs/unionfs/fanout.h	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/fanout.h	Wed Sep 27 02:05:16 2006 -0400
@@@@ -174,10 +174,28 @@@@ static inline struct dentry *dtohd(const
 	return dtopd(dent)->udi_dentry[dbstart(dent)];
 }
 
+static inline void set_dtohm_index(struct dentry *dent, int index,
+				   struct vfsmount *mnt)
+{
+	dtopd(dent)->udi_mnt[index] = mnt;
+}
+
+static inline struct vfsmount *dtohm_index(const struct dentry *dent, int index)
+{
+	return dtopd(dent)->udi_mnt[index];
+}
+
+static inline struct vfsmount *dtohm(const struct dentry *dent)
+{
+	return dtopd(dent)->udi_mnt[dbstart(dent)];
+}
+
 #define set_dtohd_index_nocheck(dent, index, val) set_dtohd_index(dent, index, val)
 #define dtohd_index_nocheck(dent, index) dtohd_index(dent, index)
 
-#define dtohd_ptr(dent) (dtopd_nocheck(dent)->udi_dentry)
+#define dtohd_ptr(dent) (dtopd(dent)->udi_dentry)
+
+#define dtohm_ptr(dent) (dtopd(dent)->udi_mnt)
 
 /* Macros for locking a dentry. */
 #define lock_dentry(d) down(&dtopd(d)->udi_sem)
diff -r c481a6bbd16b fs/unionfs/lookup.c
--- a/fs/unionfs/lookup.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/lookup.c	Wed Sep 27 02:03:00 2006 -0400
@@@@ -400,10 +400,10 @@@@ int new_dentry_private_data(struct dentr
 	int oldsize = 0;
 
 	spin_lock(&dentry->d_lock);
-	if (!dtopd_nocheck(dentry)) {
+	if (!dtopd(dentry)) {
 		dtopd_lhs(dentry) = (struct unionfs_dentry_info *)
 		    kmem_cache_alloc(unionfs_dentry_cachep, SLAB_ATOMIC);
-		if (!dtopd_nocheck(dentry))
+		if (!dtopd(dentry))
 			goto out;
 		init_MUTEX_LOCKED(&dtopd_nocheck(dentry)->udi_sem);
 
@@@@ -411,13 +411,13 @@@@ int new_dentry_private_data(struct dentr
 	} else
 		oldsize = sizeof(struct dentry *) * dtopd(dentry)->udi_bcount;
 
-	dtopd_nocheck(dentry)->udi_bstart = -1;
-	dtopd_nocheck(dentry)->udi_bend = -1;
-	dtopd_nocheck(dentry)->udi_bopaque = -1;
-	dtopd_nocheck(dentry)->udi_bcount = sbmax(dentry->d_sb);
-	atomic_set(&dtopd_nocheck(dentry)->udi_generation,
+	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(struct dentry *) * sbmax(dentry->d_sb);
+	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
@@@@ -434,17 +434,23 @@@@ int new_dentry_private_data(struct dentr
 
 	if (!dtohd_ptr(dentry) && newsize) {
 		dtohd_ptr(dentry) = kmalloc(newsize, GFP_ATOMIC);
-		if (!dtohd_ptr(dentry))
-			goto out;
+		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_nocheck(dentry));
+	free_dentry_private_data(dtopd(dentry));
 	dtopd_lhs(dentry) = NULL;
 	spin_unlock(&dentry->d_lock);
 	return -ENOMEM;
diff -r c481a6bbd16b fs/unionfs/union.h
--- a/fs/unionfs/union.h	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/union.h	Sun Sep 24 19:37:59 2006 -0400
@@@@ -116,6 +116,7 @@@@ struct unionfs_dentry_info {
 	int udi_bcount;
 	atomic_t udi_generation;
 	struct dentry **udi_dentry;
+	struct vfsmount **udi_mnt;
 };
 
 /* These are the pointers to our various objects. */
@


1.1.2.2
log
@More mountpoint crossing related fixes
@
text
@a0 54
diff -r c481a6bbd16b fs/unionfs/commonfops.c
--- a/fs/unionfs/commonfops.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/commonfops.c	Wed Sep 27 03:10:11 2006 -0400
@@@@ -110,11 +110,11 @@@@ static int open_all_files(struct file *f
 			continue;
 
 		dget(hidden_dentry);
-		mntget(stohiddenmnt_index(sb, bindex));
+		mntget(dtohm_index(dentry, bindex));
 		branchget(sb, bindex);
 
 		hidden_file = dentry_open(hidden_dentry,
-				stohiddenmnt_index(sb, bindex), file->f_flags);
+				dtohm_index(dentry, bindex), file->f_flags);
 		if (IS_ERR(hidden_file)) {
 			err = PTR_ERR(hidden_file);
 			goto out;
@@@@ -154,10 +154,10 @@@@ static int open_highest_file(struct file
 	}
 
 	dget(hidden_dentry);
-	mntget(stohiddenmnt_index(sb, bstart));
+	mntget(dtohm_index(dentry, bstart));
 	branchget(sb, bstart);
 	hidden_file = dentry_open(hidden_dentry,
-			stohiddenmnt_index(sb, bstart), file->f_flags);
+			dtohm_index(dentry, bstart), file->f_flags);
 	if (IS_ERR(hidden_file)) {
 		err = PTR_ERR(hidden_file);
 		goto out;
@@@@ -298,9 +298,9 @@@@ static inline int __open_dir(struct inod
 			continue;
 
 		dget(hidden_dentry);
-		mntget(stohiddenmnt_index(inode->i_sb, bindex));
+		mntget(dtohm_index(file->f_dentry, bindex));
 		hidden_file = dentry_open(hidden_dentry,
-					stohiddenmnt_index(inode->i_sb, bindex),
+					dtohm_index(file->f_dentry, bindex),
 					file->f_flags);
 		if (IS_ERR(hidden_file))
 			return PTR_ERR(hidden_file);
@@@@ -355,9 +355,9 @@@@ static inline int __open_file(struct ino
 	/* dentry_open will decrement mnt refcnt if err.
 	 * otherwise fput() will do an mntput() for us upon file close.
 	 */
-	mntget(stohiddenmnt_index(inode->i_sb, bstart));
+	mntget(dtohm_index(file->f_dentry, bstart));
 	hidden_file = dentry_open(hidden_dentry,
-				  stohiddenmnt_index(inode->i_sb, bstart),
+				  dtohm_index(file->f_dentry, bstart),
 				  hidden_flags);
 	if (IS_ERR(hidden_file))
 		return PTR_ERR(hidden_file);
d3 2
a4 22
+++ b/fs/unionfs/fanout.h	Wed Sep 27 02:15:03 2006 -0400
@@@@ -109,19 +109,6 @@@@ static inline void set_stohs(struct supe
 	stopd(o)->usi_data[sbstart(o)].sb = val;
 }
 
-/* Super to hidden mount. */
-static inline struct vfsmount *stohiddenmnt_index(struct super_block *o,
-						  int index)
-{
-	return stopd(o)->usi_data[index].hidden_mnt;
-}
-
-static inline void set_stohiddenmnt_index(struct super_block *o, int index,
-					  struct vfsmount *val)
-{
-	stopd(o)->usi_data[index].hidden_mnt = val;
-}
-
 /* Branch count macros. */
 static inline int branch_count(struct super_block *o, int index)
 {
@@@@ -174,10 +161,28 @@@@ static inline struct dentry *dtohd(const
@


1.1.2.3
log
@Finished converting all the users of stohiddenmnt to dtohm
@
text
@a54 71
diff -r c481a6bbd16b fs/unionfs/copyup.c
--- a/fs/unionfs/copyup.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/copyup.c	Wed Sep 27 10:54:45 2006 -0400
@@@@ -112,7 +112,7 @@@@ static inline int __copyup_ndentry(struc
 	return err;
 }
 
-static inline int __copyup_reg_data(struct super_block *sb,
+static inline int __copyup_reg_data(struct dentry *dentry,
 				    struct dentry *new_hidden_dentry,
 				    int new_bindex,
 				    struct dentry *old_hidden_dentry,
@@@@ -120,6 +120,7 @@@@ static inline int __copyup_reg_data(stru
 				    struct file **copyup_file,
 				    loff_t len)
 {
+	struct super_block *sb = dentry->d_sb;
 	struct file *input_file;
 	struct file *output_file;
 	mm_segment_t old_fs;
@@@@ -129,10 +130,10 @@@@ static inline int __copyup_reg_data(stru
 	int err = 0;
 
 	/* open old file */
-	mntget(stohiddenmnt_index(sb, old_bindex));
+	mntget(dtohm_index(dentry, old_bindex));
 	branchget(sb, old_bindex);
 	input_file = dentry_open(old_hidden_dentry,
-			stohiddenmnt_index(sb, old_bindex), O_RDONLY);
+			dtohm_index(dentry, old_bindex), O_RDONLY);
 	if (IS_ERR(input_file)) {
 		dput(old_hidden_dentry);
 		err = PTR_ERR(input_file);
@@@@ -145,10 +146,10 @@@@ static inline int __copyup_reg_data(stru
 
 	/* open new file */
 	dget(new_hidden_dentry);
-	mntget(stohiddenmnt_index(sb, new_bindex));
+	mntget(dtohm_index(dentry, new_bindex));
 	branchget(sb, new_bindex);
 	output_file = dentry_open(new_hidden_dentry,
-			stohiddenmnt_index(sb, new_bindex), O_WRONLY);
+			dtohm_index(dentry, new_bindex), O_WRONLY);
 	if (IS_ERR(output_file)) {
 		err = PTR_ERR(output_file);
 		goto out_close_in2;
@@@@ -330,7 +331,7 @@@@ int copyup_named_dentry(struct inode *di
 
 	/* We actually copyup the file here. */
 	if (S_ISREG(old_hidden_dentry->d_inode->i_mode))
-		err = __copyup_reg_data(sb, new_hidden_dentry, new_bindex,
+		err = __copyup_reg_data(dentry, new_hidden_dentry, new_bindex,
 				old_hidden_dentry, old_bindex, copyup_file, len);
 	if (err)
 		goto out_unlink;
diff -r c481a6bbd16b fs/unionfs/dirhelper.c
--- a/fs/unionfs/dirhelper.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/dirhelper.c	Wed Sep 27 10:46:27 2006 -0400
@@@@ -221,10 +221,10 @@@@ int check_empty(struct dentry *dentry, s
 			continue;
 
 		dget(hidden_dentry);
-		mntget(stohiddenmnt_index(sb, bindex));
+		mntget(dtohm_index(dentry, bindex));
 		branchget(sb, bindex);
 		hidden_file =
-		    dentry_open(hidden_dentry, stohiddenmnt_index(sb, bindex),
+		    dentry_open(hidden_dentry, dtohm_index(dentry, bindex),
 				O_RDONLY);
 		if (IS_ERR(hidden_file)) {
 			err = PTR_ERR(hidden_file);
a170 84
diff -r c481a6bbd16b fs/unionfs/main.c
--- a/fs/unionfs/main.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/main.c	Wed Sep 27 10:38:15 2006 -0400
@@@@ -302,8 +302,8 @@@@ static int parse_dirs_option(struct supe
 		}
 
 		hidden_root_info->udi_dentry[bindex] = nd.dentry;
-
-		set_stohiddenmnt_index(sb, bindex, nd.mnt);
+		hidden_root_info->udi_mnt[bindex] = nd.mnt;
+
 		set_branchperms(sb, bindex, perms);
 		set_branch_count(sb, bindex, 0);
 
@@@@ -441,10 +441,15 @@@@ out_error:
 		     bindex >= 0 && bindex <= hidden_root_info->udi_bend;
 		     bindex++) {
 			struct dentry *d;
+			struct vfsmount *m;
+
 			d = hidden_root_info->udi_dentry[bindex];
+			m = hidden_root_info->udi_mnt[bindex];
+
 			dput(d);
-			if (stohiddenmnt_index(sb, bindex))
-				mntput(stohiddenmnt_index(sb, bindex));
+
+			if (m)
+				mntput(m);
 		}
 	}
 
@@@@ -583,14 +588,16 @@@@ out_dput:
 		for (bindex = hidden_root_info->udi_bstart;
 		     bindex <= hidden_root_info->udi_bend; bindex++) {
 			struct dentry *d;
+			struct vfsmount *m;
 
 			d = hidden_root_info->udi_dentry[bindex];
+			m = hidden_root_info->udi_mnt[bindex];
 
 			if (d)
 				dput(d);
 
-			if (stopd(sb) && stohiddenmnt_index(sb, bindex))
-				mntput(stohiddenmnt_index(sb, bindex));
+			if (m)
+				mntput(m);
 		}
 		kfree(hidden_root_info->udi_dentry);
 		kfree(hidden_root_info);
diff -r c481a6bbd16b fs/unionfs/super.c
--- a/fs/unionfs/super.c	Sun Sep 24 18:59:20 2006 -0400
+++ b/fs/unionfs/super.c	Wed Sep 27 10:41:29 2006 -0400
@@@@ -102,8 +102,11 @@@@ static void unionfs_put_super(struct sup
 		
 	bstart = sbstart(sb);
 	bend = sbend(sb);
+#if 0
+	/* this shouldn't be needed */
 	for (bindex = bstart; bindex <= bend; bindex++)
 		mntput(stohiddenmnt_index(sb, bindex));
+#endif
 
 	/* Make sure we have no leaks of branchget/branchput. */
 	for (bindex = bstart; bindex <= bend; bindex++)
@@@@ -282,7 +285,7 @@@@ static void unionfs_umount_begin(struct 
 	bstart = sbstart(sb);
 	bend = sbend(sb);
 	for (bindex = bstart; bindex <= bend; bindex++) {
-		hidden_mnt = stohiddenmnt_index(sb, bindex);
+		hidden_mnt = dtohm_index(sb->s_root, bindex);
 		hidden_sb = stohs_index(sb, bindex);
 
 		if (hidden_mnt && hidden_sb && hidden_sb->s_op &&
@@@@ -314,7 +317,7 @@@@ static int unionfs_show_options(struct s
 	seq_printf(m, ",dirs=");
 	for (bindex = bstart; bindex <= bend; bindex++) {
 		path = d_path(dtohd_index(sb->s_root, bindex),
-			   stohiddenmnt_index(sb, bindex), tmp_page,
+			   dtohm_index(sb->s_root, bindex), tmp_page,
 			   PAGE_SIZE);
 		perms = branchperms(sb, bindex);
 
@


1.1.2.4
log
@Nice, hopefully working lookup_one_len replacement that allows crossing
mountpoints
@
text
@d1 3
a3 3
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
d55 3
a57 3
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
d110 3
a112 3
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
d126 3
a128 3
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
d179 3
a181 3
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
d242 3
a244 3
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
d293 3
a295 3
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
d326 3
a328 3
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@


1.1.2.5
log
@Collapse 3 feature patches
@
text
@@


