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


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

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

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

1.1.2.3
date	2006.10.29.06.07.55;	author jsipek;	state dead;
branches;
next	;


desc
@@


1.1
log
@file fsstack-containers-unionfs was initially added on branch LKML-branch.
@
text
@@


1.1.2.1
log
@Container stuff
@
text
@a0 72
diff -r 075d03e17c14 fs/unionfs/union.h
--- a/fs/unionfs/union.h	Wed Oct 25 21:36:44 2006 -0400
+++ b/fs/unionfs/union.h	Wed Oct 25 21:41:34 2006 -0400
@@@@ -76,16 +76,21 @@@@ extern struct dentry_operations unionfs_
 
 /* file private data. */
 struct unionfs_file_info {
+	/* handled by fsstack - must be the first member */
+	struct fsstack_file_info info;
+
 	int b_start;
 	int b_end;
 	atomic_t ufi_generation;
 
 	struct unionfs_dir_state *rdstate;
-	struct file **ufi_file;
 };
 
 /* unionfs inode data in memory */
 struct unionfs_inode_info {
+	/* handled by fsstack - must be the first member */
+	struct fsstack_inode_info info;
+
 	int b_start;
 	int b_end;
 	atomic_t uii_generation;
@@@@ -96,18 +101,20 @@@@ struct unionfs_inode_info {
 	int uii_rdcount;
 	int uii_hashsize;
 	int uii_cookie; /* The hidden inodes */
-	struct inode **uii_inode;
 	/* to keep track of reads/writes for unlinks before closes */
 	atomic_t uii_totalopens;
 };
 
 struct unionfs_inode_container {
+	struct inode vfs_inode;
 	struct unionfs_inode_info info;
-	struct inode vfs_inode;
 };
 
 /* unionfs dentry data in memory */
 struct unionfs_dentry_info {
+	/* handled by fsstack - must be the first member */
+	struct fsstack_dentry_info info;
+
 	/* The semaphore is used to lock the dentry as soon as we get into a
 	 * unionfs function from the VFS.  Our lock ordering is that children
 	 * go before their parents. */
@@@@ -117,19 +124,19 @@@@ struct unionfs_dentry_info {
 	int udi_bopaque;
 	int udi_bcount;
 	atomic_t udi_generation;
-	struct path *udi_path;
 };
 
 /* These are the pointers to our various objects. */
 struct unionfs_usi_data {
-	struct super_block *sb;
-	struct vfsmount *hidden_mnt;
 	atomic_t sbcount;
 	int branchperms;
 };
 
 /* unionfs super-block data in memory */
 struct unionfs_sb_info {
+	/* handled by fsstack - must be the first member */
+	struct fsstack_dentry_info info;
+
 	int b_end;
 
 	atomic_t usi_generation;
@


1.1.2.2
log
@More container magic - generic & unionfs
@
text
@d1 3
a3 3
diff -r 1aa58aad7c86 fs/unionfs/union.h
--- a/fs/unionfs/union.h	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/union.h	Fri Oct 27 06:09:05 2006 -0400
a72 335
diff -r 1aa58aad7c86 fs/unionfs/commonfops.c
--- a/fs/unionfs/commonfops.c	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/commonfops.c	Sat Oct 28 11:01:58 2006 -0400
@@@@ -88,9 +88,9 @@@@ static void cleanup_file(struct file *fi
 		}
 	}
 
-	if (ftohf_ptr(file)) {
-		kfree(ftohf_ptr(file));
-		ftohf_ptr(file) = NULL;
+	if (__fsstack_lower_files(file)) {
+		kfree(__fsstack_lower_files(file));
+		__fsstack_set_lower_files(file, NULL);
 	}
 }
 
@@@@ -246,8 +246,8 @@@@ int unionfs_file_revalidate(struct file 
 		bend = fbend(file) = dbend(dentry);
 
 		size = sizeof(struct file *) * sbmax(sb);
-		ftohf_ptr(file) = kzalloc(size, GFP_KERNEL);
-		if (!ftohf_ptr(file)) {
+		__fsstack_set_lower_files(file, kzalloc(size, GFP_KERNEL));
+		if (!__fsstack_lower_files(file)) {
 			err = -ENOMEM;
 			goto out;
 		}
@@@@ -387,8 +387,8 @@@@ int unionfs_open(struct inode *inode, st
 		   atomic_read(&itopd(inode)->uii_generation));
 
 	size = sizeof(struct file *) * sbmax(inode->i_sb);
-	ftohf_ptr(file) = kzalloc(size, GFP_KERNEL);
-	if (!ftohf_ptr(file)) {
+	__fsstack_set_lower_files(file, kzalloc(size, GFP_KERNEL));
+	if (!__fsstack_lower_files(file)) {
 		err = -ENOMEM;
 		goto out;
 	}
@@@@ -427,7 +427,7 @@@@ int unionfs_open(struct inode *inode, st
 
 out:
 	if (err) {
-		kfree(ftohf_ptr(file));
+		kfree(__fsstack_lower_files(file));
 		kfree(ftopd(file));
 	}
 
@@@@ -455,7 +455,7 @@@@ int unionfs_file_release(struct inode *i
 			unionfs_read_unlock(inode->i_sb);
 		}
 	}
-	kfree(ftohf_ptr(file));
+	kfree(__fsstack_lower_files(file));
 
 	if (ftopd(file)->rdstate) {
 		ftopd(file)->rdstate->uds_access = jiffies;
diff -r 1aa58aad7c86 fs/unionfs/dentry.c
--- a/fs/unionfs/dentry.c	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/dentry.c	Sat Oct 28 10:35:53 2006 -0400
@@@@ -124,8 +124,8 @@@@ restart:
 					iput(hidden_inode);
 				}
 			}
-			kfree(itohi_ptr(dentry->d_inode));
-			itohi_ptr(dentry->d_inode) = NULL;
+			kfree(__fsstack_lower_inodes(dentry->d_inode));
+			__fsstack_set_lower_inodes(dentry->d_inode, NULL);
 			ibstart(dentry->d_inode) = -1;
 			ibend(dentry->d_inode) = -1;
 			mutex_unlock(&dentry->d_inode->i_mutex);
@@@@ -223,8 +223,8 @@@@ void unionfs_d_release(struct dentry *de
 		__fsstack_set_lower_mnt(dentry, bindex, NULL);
 	}
 	/* free private data (unionfs_dentry_info) here */
-	kfree(dtohp_ptr(dentry));
-	dtohp_ptr(dentry) = NULL;
+	kfree(__fsstack_lower_paths(dentry));
+	__fsstack_set_lower_paths(dentry, NULL);
 
 out_free:
 	/* No need to unlock it, because it is disappeared. */
diff -r 1aa58aad7c86 fs/unionfs/fanout.h
--- a/fs/unionfs/fanout.h	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/fanout.h	Sat Oct 28 10:30:01 2006 -0400
@@@@ -26,7 +26,6 @@@@ static inline struct unionfs_inode_info 
 	      info);
 }
 
-#define itohi_ptr(ino) (itopd(ino)->uii_inode)
 #define ibstart(ino) (itopd(ino)->b_start)
 #define ibend(ino) (itopd(ino)->b_end)
 
diff -r 1aa58aad7c86 fs/unionfs/lookup.c
--- a/fs/unionfs/lookup.c	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/lookup.c	Sat Oct 28 10:59:51 2006 -0400
@@@@ -306,8 +306,8 @@@@ out_free:
 			mntput(__fsstack_lower_mnt(dentry, bindex));
 		}
 	}
-	kfree(dtohp_ptr(dentry));
-	dtohp_ptr(dentry) = NULL;
+	kfree(__fsstack_lower_paths(dentry));
+	__fsstack_set_lower_paths(dentry, NULL);
 	set_dbstart(dentry, -1);
 	set_dbend(dentry, -1);
 
@@@@ -432,7 +432,7 @@@@ int new_dentry_private_data(struct dentr
 			goto out;
 		init_MUTEX_LOCKED(&dtopd_nocheck(dentry)->udi_sem);
 
-		dtohp_ptr(dentry) = NULL;
+		__fsstack_set_lower_paths(dentry, NULL);
 	} else
 		oldsize = sizeof(struct path) * dtopd(dentry)->udi_bcount;
 
@@@@ -452,24 +452,24 @@@@ int new_dentry_private_data(struct dentr
 		int minsize = malloc_sizes[0].cs_size;
 
 		if (!newsize || ((oldsize < newsize) && (newsize > minsize))) {
-			kfree(dtohp_ptr(dentry));
-			dtohp_ptr(dentry) = NULL;
-		}
-	}
-
-	if (!dtohp_ptr(dentry) && newsize) {
-		dtohp_ptr(dentry) = kmalloc(newsize, GFP_ATOMIC);
-		if (!dtohp_ptr(dentry))
+			kfree(__fsstack_lower_paths(dentry));
+			__fsstack_set_lower_paths(dentry, NULL);
+		}
+	}
+
+	if (!__fsstack_lower_paths(dentry) && newsize) {
+		__fsstack_set_lower_paths(dentry, kmalloc(newsize, GFP_ATOMIC));
+		if (!__fsstack_lower_paths(dentry))
 			goto out_free;
 	}
 
-	memset(dtohp_ptr(dentry), 0, (oldsize > newsize ? oldsize : newsize));
+	memset(__fsstack_lower_paths(dentry), 0, (oldsize > newsize ? oldsize : newsize));
 
 	spin_unlock(&dentry->d_lock);
 	return 0;
 
 out_free:
-	kfree(dtohp_ptr(dentry));
+	kfree(__fsstack_lower_paths(dentry));
 
 out:
 	free_dentry_private_data(dtopd(dentry));
diff -r 1aa58aad7c86 fs/unionfs/main.c
--- a/fs/unionfs/main.c	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/main.c	Sat Oct 28 10:53:35 2006 -0400
@@@@ -61,9 +61,9 @@@@ int unionfs_interpose(struct dentry *den
 		atomic_set(&itopd(inode)->uii_generation,
 			   atomic_read(&stopd(sb)->usi_generation));
 
-		itohi_ptr(inode) =
-		    kcalloc(sbmax(sb), sizeof(struct inode *), GFP_KERNEL);
-		if (!itohi_ptr(inode)) {
+		__fsstack_set_lower_inodes(inode,
+			kcalloc(sbmax(sb), sizeof(struct inode *), GFP_KERNEL));
+		if (!__fsstack_lower_inodes(inode)) {
 			err = -ENOMEM;
 			goto out;
 		}
@@@@ -260,9 +260,9 @@@@ static int parse_dirs_option(struct supe
 		goto out;
 	}
 
-	hidden_root_info->udi_path = kcalloc(branches,
+	hidden_root_info->info.paths = kcalloc(branches,
 			sizeof(struct path), GFP_KERNEL);
-	if (!hidden_root_info->udi_path) {
+	if (!hidden_root_info->info.paths) {
 		err = -ENOMEM;
 		goto out;
 	}
@@@@ -298,8 +298,8 @@@@ static int parse_dirs_option(struct supe
 			goto out;
 		}
 
-		hidden_root_info->udi_path[bindex].dentry = nd.dentry;
-		hidden_root_info->udi_path[bindex].mnt = nd.mnt;
+		hidden_root_info->info.paths[bindex].dentry = nd.dentry;
+		hidden_root_info->info.paths[bindex].mnt = nd.mnt;
 
 		set_branchperms(sb, bindex, perms);
 		set_branch_count(sb, bindex, 0);
@@@@ -321,8 +321,8 @@@@ static int parse_dirs_option(struct supe
 	/* ensure that no overlaps exist in the branches */
 	for (i = 0; i < branches; i++) {
 		for (j = i + 1; j < branches; j++) {
-			dent1 = hidden_root_info->udi_path[i].dentry;
-			dent2 = hidden_root_info->udi_path[j].dentry;
+			dent1 = hidden_root_info->info.paths[i].dentry;
+			dent2 = hidden_root_info->info.paths[j].dentry;
 
 			if (is_branch_overlap(dent1, dent2)) {
 				printk(KERN_WARNING "unionfs: branches %d and %d overlap\n", i, j);
@@@@ -335,18 +335,18 @@@@ out:
 out:
 	if (err) {
 		for (i = 0; i < branches; i++)
-			if (hidden_root_info->udi_path[i].dentry) {
-				dput(hidden_root_info->udi_path[i].dentry);
-				mntput(hidden_root_info->udi_path[i].mnt);
+			if (hidden_root_info->info.paths[i].dentry) {
+				dput(hidden_root_info->info.paths[i].dentry);
+				mntput(hidden_root_info->info.paths[i].mnt);
 			}
 
-		kfree(hidden_root_info->udi_path);
+		kfree(hidden_root_info->info.paths);
 		kfree(stopd(sb)->usi_data);
 
 		/* MUST clear the pointers to prevent potential double free if
 		 * the caller dies later on
 		 */
-		hidden_root_info->udi_path = NULL;
+		hidden_root_info->info.paths = NULL;
 		stopd(sb)->usi_data = NULL;
 	}
 	return err;
@@@@ -435,15 +435,15 @@@@ static struct unionfs_dentry_info *union
 	goto out;
 
 out_error:
-	if (hidden_root_info && hidden_root_info->udi_path) {
+	if (hidden_root_info && hidden_root_info->info.paths) {
 		for (bindex = hidden_root_info->udi_bstart;
 		     bindex >= 0 && bindex <= hidden_root_info->udi_bend;
 		     bindex++) {
 			struct dentry *d;
 			struct vfsmount *m;
 
-			d = hidden_root_info->udi_path[bindex].dentry;
-			m = hidden_root_info->udi_path[bindex].mnt;
+			d = hidden_root_info->info.paths[bindex].dentry;
+			m = hidden_root_info->info.paths[bindex].mnt;
 
 			dput(d);
 
@@@@ -452,7 +452,7 @@@@ out_error:
 		}
 	}
 
-	kfree(hidden_root_info->udi_path);
+	kfree(hidden_root_info->info.paths);
 	kfree(hidden_root_info);
 
 	kfree(stopd(sb)->usi_data);
@@@@ -529,7 +529,7 @@@@ static int unionfs_read_super(struct sup
 	for (bindex = bstart; bindex <= bend; bindex++) {
 		struct dentry *d;
 
-		d = hidden_root_info->udi_path[bindex].dentry;
+		d = hidden_root_info->info.paths[bindex].dentry;
 
 		__fsstack_set_lower_sb(sb, bindex, d->d_sb);
 	}
@@@@ -560,8 +560,8 @@@@ static int unionfs_read_super(struct sup
 		struct dentry *d;
 		struct vfsmount *m;
 
-		d = hidden_root_info->udi_path[bindex].dentry;
-		m = hidden_root_info->udi_path[bindex].mnt;
+		d = hidden_root_info->info.paths[bindex].dentry;
+		m = hidden_root_info->info.paths[bindex].mnt;
 
 		__fsstack_set_lower_dentry(sb->s_root, bindex, d);
 		__fsstack_set_lower_mnt(sb->s_root, bindex, m);
@@@@ -580,7 +580,7 @@@@ static int unionfs_read_super(struct sup
 
 out_freedpd:
 	if (dtopd(sb->s_root)) {
-		kfree(dtohp_ptr(sb->s_root));
+		kfree(__fsstack_lower_paths(sb->s_root));
 		free_dentry_private_data(dtopd(sb->s_root));
 	}
 	dput(sb->s_root);
@@@@ -592,8 +592,8 @@@@ out_dput:
 			struct dentry *d;
 			struct vfsmount *m;
 
-			d = hidden_root_info->udi_path[bindex].dentry;
-			m = hidden_root_info->udi_path[bindex].mnt;
+			d = hidden_root_info->info.paths[bindex].dentry;
+			m = hidden_root_info->info.paths[bindex].mnt;
 
 			if (d)
 				dput(d);
@@@@ -601,7 +601,7 @@@@ out_dput:
 			if (m)
 				mntput(m);
 		}
-		kfree(hidden_root_info->udi_path);
+		kfree(hidden_root_info->info.paths);
 		kfree(hidden_root_info);
 		hidden_root_info = NULL;
 	}
@@@@ -613,7 +613,7 @@@@ out_free:
 
 out:
 	if (hidden_root_info && !IS_ERR(hidden_root_info)) {
-		kfree(hidden_root_info->udi_path);
+		kfree(hidden_root_info->info.paths);
 		kfree(hidden_root_info);
 	}
 	return err;
diff -r 1aa58aad7c86 fs/unionfs/super.c
--- a/fs/unionfs/super.c	Fri Oct 27 06:09:05 2006 -0400
+++ b/fs/unionfs/super.c	Sat Oct 28 10:56:45 2006 -0400
@@@@ -44,8 +44,8 @@@@ static void unionfs_read_inode(struct in
 	INIT_LIST_HEAD(&itopd(inode)->uii_readdircache);
 
 	size = sbmax(inode->i_sb) * sizeof(struct inode *);
-	itohi_ptr(inode) = kzalloc(size, GFP_KERNEL);
-	if (!itohi_ptr(inode)) {
+	__fsstack_set_lower_inodes(inode, kzalloc(size, GFP_KERNEL));
+	if (!__fsstack_lower_inodes(inode)) {
 		printk(KERN_ERR "No kernel memory when allocating lower-"
 				"pointer array!\n");
 		BUG();
@@@@ -180,8 +180,8 @@@@ static void unionfs_clear_inode(struct i
 		}
 	}
 
-	kfree(itohi_ptr(inode));
-	itohi_ptr(inode) = NULL;
+	kfree(__fsstack_lower_inodes(inode));
+	__fsstack_set_lower_inodes(inode, NULL);
 }
 
 static struct inode *unionfs_alloc_inode(struct super_block *sb)
@


1.1.2.3
log
@Collapse several unionfs patches into one
@
text
@@


