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


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

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

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

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

1.1.2.4
date	2007.01.28.19.24.33;	author jsipek;	state dead;
branches;
next	;


desc
@@


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


1.1.2.1
log
@Most of akpm's comments & work-in-progress mmap implementation
@
text
@a0 596
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 6685bf7..7aecd1b 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@@@ -33,7 +33,7 @@@@ static int copyup_deleted_file(struct file *file, struct dentry *dentry,
 
 	int err;
 	struct dentry *tmp_dentry = NULL;
-	struct dentry *hidden_dentry = NULL;
+	struct dentry *hidden_dentry;
 	struct dentry *hidden_dir_dentry = NULL;
 
 	hidden_dentry = unionfs_lower_dentry_idx(dentry, bstart);
@@@@ -529,23 +529,23 @@@@ long unionfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	/* check if asked for local commands */
 	switch (cmd) {
-		case UNIONFS_IOCTL_INCGEN:
-			/* Increment the superblock generation count */
-			err = -EACCES;
-			if (!capable(CAP_SYS_ADMIN))
-				goto out;
-			err = unionfs_ioctl_incgen(file, cmd, arg);
-			break;
-
-		case UNIONFS_IOCTL_QUERYFILE:
-			/* Return list of branches containing the given file */
-			err = unionfs_ioctl_queryfile(file, cmd, arg);
-			break;
-
-		default:
-			/* pass the ioctl down */
-			err = do_ioctl(file, cmd, arg);
-			break;
+	case UNIONFS_IOCTL_INCGEN:
+		/* Increment the superblock generation count */
+		err = -EACCES;
+		if (!capable(CAP_SYS_ADMIN))
+			goto out;
+		err = unionfs_ioctl_incgen(file, cmd, arg);
+		break;
+
+	case UNIONFS_IOCTL_QUERYFILE:
+		/* Return list of branches containing the given file */
+		err = unionfs_ioctl_queryfile(file, cmd, arg);
+		break;
+
+	default:
+		/* pass the ioctl down */
+		err = do_ioctl(file, cmd, arg);
+		break;
 	}
 
 out:
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 1d59ff3..76e7b0e 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@@@ -18,6 +18,10 @@@@
 
 #include "union.h"
 
+/* For detailed explanation of copyup see:
+ * Documentation/filesystems/unionfs/concepts.txt
+ */
+
 #ifdef CONFIG_UNION_FS_XATTR
 /* copyup all extended attrs for a given dentry */
 static int copyup_xattrs(struct dentry *old_hidden_dentry,
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 740c000..44b4122 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@@@ -18,12 +18,6 @@@@
 
 #include "union.h"
 
-/* declarations added for "sparse" */
-extern int unionfs_d_revalidate_wrap(struct dentry *dentry,
-				     struct nameidata *nd);
-extern void unionfs_d_release(struct dentry *dentry);
-extern void unionfs_d_iput(struct dentry *dentry, struct inode *inode);
-
 /*
  * returns 1 if valid, 0 otherwise.
  */
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index ab3bf2c..710c07e 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@@@ -130,12 +130,35 @@@@ static inline struct unionfs_dentry_info *UNIONFS_D(const struct dentry *dent)
 	return dent->d_fsdata;
 }
 
-#define dbstart(dent) (UNIONFS_D(dent)->bstart)
-#define set_dbstart(dent, val) do { UNIONFS_D(dent)->bstart = val; } while(0)
-#define dbend(dent) (UNIONFS_D(dent)->bend)
-#define set_dbend(dent, val) do { UNIONFS_D(dent)->bend = val; } while(0)
-#define dbopaque(dent) (UNIONFS_D(dent)->bopaque)
-#define set_dbopaque(dent, val) do { UNIONFS_D(dent)->bopaque = val; } while (0)
+static inline int dbstart(const struct dentry *dent)
+{
+	return UNIONFS_D(dent)->bstart;
+}
+
+static inline void set_dbstart(struct dentry *dent, int val)
+{
+	UNIONFS_D(dent)->bstart = val;
+}
+
+static inline int dbend(const struct dentry *dent)
+{
+	return UNIONFS_D(dent)->bend;
+}
+
+static inline void set_dbend(struct dentry *dent, int val)
+{
+	UNIONFS_D(dent)->bend = val;
+}
+
+static inline int dbopaque(const struct dentry *dent)
+{
+	return UNIONFS_D(dent)->bopaque;
+}
+
+static inline void set_dbopaque(struct dentry *dent, int val)
+{
+	UNIONFS_D(dent)->bopaque = val;
+}
 
 static inline void unionfs_set_lower_dentry_idx(struct dentry *dent, int index,
 				   struct dentry *val)
@@@@ -170,8 +193,18 @@@@ static inline struct vfsmount *unionfs_lower_mnt(const struct dentry *dent)
 }
 
 /* Macros for locking a dentry. */
-#define lock_dentry(d)		down(&UNIONFS_D(d)->sem)
-#define unlock_dentry(d)	up(&UNIONFS_D(d)->sem)
-#define verify_locked(d)
+static inline void lock_dentry(struct dentry *d)
+{
+	down(&UNIONFS_D(d)->sem);
+}
+
+static inline void unlock_dentry(struct dentry *d)
+{
+	up(&UNIONFS_D(d)->sem);
+}
+
+static inline void verify_locked(struct dentry *d)
+{
+}
 
 #endif	/* _FANOUT_H */
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 9d05806..428d0ab 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@@@ -19,9 +19,9 @@@@
 #include "union.h"
 
 /* declarations for sparse */
-extern ssize_t unionfs_read(struct file *, char __user *, size_t, loff_t *);
+/*extern ssize_t unionfs_read(struct file *, char __user *, size_t, loff_t *);
 extern ssize_t unionfs_write(struct file *, const char __user *, size_t,
-			     loff_t *);
+			     loff_t *);*/
 
 /*******************
  * File Operations *
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 36f2660..4fbfde6 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@@@ -18,14 +18,6 @@@@
 
 #include "union.h"
 
-/* declarations added for "sparse" */
-extern struct dentry *unionfs_lookup(struct inode *, struct dentry *,
-				     struct nameidata *);
-extern int unionfs_readlink(struct dentry *dentry, char __user * buf,
-			    int bufsiz);
-extern void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
-			     void *cookie);
-
 static int unionfs_create(struct inode *parent, struct dentry *dentry,
 			  int mode, struct nameidata *nd)
 {
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 576e224..fb7a993 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@@@ -18,8 +18,56 @@@@
 
 #include "union.h"
 
-static int is_opaque_dir(struct dentry *dentry, int bindex);
-static int is_validname(const char *name);
+/* is the filename valid == !(whiteout for a file or opaque dir marker) */
+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 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 = unionfs_lower_dentry_idx(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.is_opaque.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;
+}
 
 struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd,
 				      int lookupmode)
@@@@ -353,57 +401,6 @@@@ int unionfs_partial_lookup(struct dentry *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 = unionfs_lower_dentry_idx(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.is_opaque.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;
-}
-
-/* is the filename valid == !(whiteout for a file or opaque dir marker) */
-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 struct kmem_cache *unionfs_dentry_cachep;
 int unionfs_init_dentry_cache(void)
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 9cab716..094e921 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@@@ -132,19 +132,19 @@@@ int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
 skip:
 	/* only (our) lookup wants to do a d_add */
 	switch (flag) {
-		case INTERPOSE_DEFAULT:
-		case INTERPOSE_REVAL_NEG:
-			d_instantiate(dentry, inode);
-			break;
-		case INTERPOSE_LOOKUP:
-			err = PTR_ERR(d_splice_alias(inode, dentry));
-			break;
-		case INTERPOSE_REVAL:
-			/* Do nothing. */
-			break;
-		default:
-			printk(KERN_ERR "Invalid interpose flag passed!");
-			BUG();
+	case INTERPOSE_DEFAULT:
+	case INTERPOSE_REVAL_NEG:
+		d_instantiate(dentry, inode);
+		break;
+	case INTERPOSE_LOOKUP:
+		err = PTR_ERR(d_splice_alias(inode, dentry));
+		break;
+	case INTERPOSE_REVAL:
+		/* Do nothing. */
+		break;
+	default:
+		printk(KERN_ERR "Invalid interpose flag passed!");
+		BUG();
 	}
 
 	mutex_unlock(&inode->i_mutex);
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index 444a3e5..1be5691 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@@@ -24,26 +24,26 @@@@
  * whiteouts).
  */
 
-struct workqueue_struct *sioq;
+struct workqueue_struct *superio_workqueue;
 
 int __init init_sioq(void)
 {
 	int err;
 
-	sioq = create_workqueue("unionfs_siod");
-	if (!IS_ERR(sioq))
+	superio_workqueue = create_workqueue("unionfs_siod");
+	if (!IS_ERR(superio_workqueue))
 		return 0;
 
-	err = PTR_ERR(sioq);
+	err = PTR_ERR(superio_workqueue);
 	printk(KERN_ERR "create_workqueue failed %d\n", err);
-	sioq = NULL;
+	superio_workqueue = NULL;
 	return err;
 }
 
 void __exit stop_sioq(void)
 {
-	if (sioq)
-		destroy_workqueue(sioq);
+	if (superio_workqueue)
+		destroy_workqueue(superio_workqueue);
 }
 
 void run_sioq(work_func_t func, struct sioq_args *args)
@@@@ -51,7 +51,7 @@@@ void run_sioq(work_func_t func, struct sioq_args *args)
 	INIT_WORK(&args->work, func);
 
 	init_completion(&args->comp);
-	while (!queue_work(sioq, &args->work)) {
+	while (!queue_work(superio_workqueue, &args->work)) {
 		/* TODO: do accounting if needed */
 		schedule();
 	}
@@@@ -103,7 +103,8 @@@@ void __unionfs_unlink(struct work_struct *work)
 	complete(&args->comp);
 }
 
-void __delete_whiteouts(struct work_struct *work) {
+void __delete_whiteouts(struct work_struct *work)
+{
 	struct sioq_args *args = container_of(work, struct sioq_args, work);
 	struct deletewh_args *d = &args->deletewh;
 
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 5a93414..12ce254 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@@@ -61,7 +61,7 @@@@ struct sioq_args {
 	};
 };
 
-extern struct workqueue_struct *sioq;
+extern struct workqueue_struct *superio_workqueue;
 extern int __init init_sioq(void);
 extern __exit void stop_sioq(void);
 extern void run_sioq(work_func_t func, struct sioq_args *args);
diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index 6734776..d52f9ff 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@@@ -170,3 +170,64 @@@@ out:
 	return err;
 }
 
+/* returns the sum of the n_link values of all the underlying inodes of the
+ * passed inode
+ */
+int unionfs_get_nlinks(struct inode *inode)
+{
+	int sum_nlinks = 0;
+	int dirs = 0;
+	int bindex;
+	struct inode *hidden_inode;
+
+	/* don't bother to do all the work since we're unlinked */
+	if (inode->i_nlink == 0)
+		return 0;
+
+	if (!S_ISDIR(inode->i_mode))
+		return unionfs_lower_inode(inode)->i_nlink;
+
+	for (bindex = ibstart(inode); bindex <= ibend(inode); bindex++) {
+		hidden_inode = unionfs_lower_inode_idx(inode, bindex);
+
+		/* ignore files */
+		if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode))
+			continue;
+
+		BUG_ON(hidden_inode->i_nlink < 0);
+
+		/* A deleted directory. */
+		if (hidden_inode->i_nlink == 0)
+			continue;
+		dirs++;
+
+		/*
+		 * A broken directory...
+		 *
+		 * Some filesystems don't properly set the number of links
+		 * on empty directories
+		 */
+		if (hidden_inode->i_nlink == 1)
+			sum_nlinks += 2;
+		else
+			sum_nlinks += (hidden_inode->i_nlink - 2);
+	}
+
+	return (!dirs ? 0 : sum_nlinks + 2);
+}
+
+/* construct whiteout filename */
+char *alloc_whname(const char *name, int len)
+{
+	char *buf;
+
+	buf = kmalloc(len + UNIONFS_WHLEN + 1, GFP_KERNEL);
+	if (!buf)
+		return ERR_PTR(-ENOMEM);
+
+	strcpy(buf, UNIONFS_WHPFX);
+	strlcat(buf, name, len + UNIONFS_WHLEN + 1);
+
+	return buf;
+}
+
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 25085bf..9956caf 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@@@ -321,8 +321,7 @@@@ static int unionfs_show_options(struct seq_file *m, struct vfsmount *mnt)
 	}
 
 out:
-	if (tmp_page)
-		free_page((unsigned long) tmp_page);
+	free_page((unsigned long) tmp_page);
 
 	unlock_dentry(sb->s_root);
 
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index f08eb75..8cb6633 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@@@ -276,6 +276,8 @@@@ extern int remove_whiteouts(struct dentry *dentry, struct dentry *hidden_dentry,
 extern int do_delete_whiteouts(struct dentry *dentry, int bindex,
 		     struct unionfs_dir_state *namelist);
 
+extern int unionfs_get_nlinks(struct inode *inode);
+
 /* Is this directory empty: 0 if it is empty, -ENOTEMPTY if not. */
 extern int check_empty(struct dentry *dentry,
 		       struct unionfs_dir_state **namelist);
@@@@ -348,52 +350,6 @@@@ static inline int d_deleted(struct dentry *d)
 	return d_unhashed(d) && (d != d->d_sb->s_root);
 }
 
-/* returns the sum of the n_link values of all the underlying inodes of the
- * passed inode
- */
-static inline int unionfs_get_nlinks(struct inode *inode)
-{
-	int sum_nlinks = 0;
-	int dirs = 0;
-	int bindex;
-	struct inode *hidden_inode;
-
-	/* don't bother to do all the work since we're unlinked */
-	if (inode->i_nlink == 0)
-		return 0;
-
-	if (!S_ISDIR(inode->i_mode))
-		return unionfs_lower_inode(inode)->i_nlink;
-
-	for (bindex = ibstart(inode); bindex <= ibend(inode); bindex++) {
-		hidden_inode = unionfs_lower_inode_idx(inode, bindex);
-
-		/* ignore files */
-		if (!hidden_inode || !S_ISDIR(hidden_inode->i_mode))
-			continue;
-
-		BUG_ON(hidden_inode->i_nlink < 0);
-
-		/* A deleted directory. */
-		if (hidden_inode->i_nlink == 0)
-			continue;
-		dirs++;
-
-		/*
-		 * A broken directory...
-		 *
-		 * Some filesystems don't properly set the number of links
-		 * on empty directories
-		 */
-		if (hidden_inode->i_nlink == 1)
-			sum_nlinks += 2;
-		else
-			sum_nlinks += (hidden_inode->i_nlink - 2);
-	}
-
-	return (!dirs ? 0 : sum_nlinks + 2);
-}
-
 struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd, int lookupmode);
 int is_stale_inode(struct inode *inode);
 void make_stale_inode(struct inode *inode);
@@@@ -462,21 +418,6 @@@@ static inline int is_robranch(const struct dentry *dentry)
 #define UNIONFS_DIR_OPAQUE_NAME "__dir_opaque"
 #define UNIONFS_DIR_OPAQUE UNIONFS_WHPFX UNIONFS_DIR_OPAQUE_NAME
 
-/* construct whiteout filename */
-static inline char *alloc_whname(const char *name, int len)
-{
-	char *buf;
-
-	buf = kmalloc(len + UNIONFS_WHLEN + 1, GFP_KERNEL);
-	if (!buf)
-		return ERR_PTR(-ENOMEM);
-
-	strcpy(buf, UNIONFS_WHPFX);
-	strlcat(buf, name, len + UNIONFS_WHLEN + 1);
-
-	return buf;
-}
-
 #define VALID_MOUNT_FLAGS (0)
 
 #ifndef DEFAULT_POLLMASK
@@@@ -486,6 +427,7 @@@@ static inline char *alloc_whname(const char *name, int len)
 /*
  * EXTERNALS:
  */
+extern char *alloc_whname(const char *name, int len);
 
 /* These two functions are here because it is kind of daft to copy and paste the
  * contents of the two functions to 32+ places in unionfs
@


1.1.2.2
log
@Replaced semaphores with mutexes (as per akpm's suggestion)
@
text
@a0 22
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
index 168c5d5..90a6bf7 100644
--- a/fs/unionfs/branchman.c
+++ b/fs/unionfs/branchman.c
@@@@ -54,7 +54,7 @@@@ int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
 	struct dentry *dentry, *hidden_dentry;
 
 	dentry = file->f_dentry;
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	if ((err = unionfs_partial_lookup(dentry)))
 		goto out;
 	bstart = dbstart(dentry);
@@@@ -75,7 +75,7 @@@@ int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
 		err = -EFAULT;
 
 out:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err < 0 ? err : bend;
 }
 
d2 1
a2 1
index 6685bf7..43063b4 100644
a13 36
@@@@ -225,7 +225,7 @@@@ int unionfs_file_revalidate(struct file *file, int willwrite)
 	int err = 0;
 
 	dentry = file->f_dentry;
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	sb = dentry->d_sb;
 	unionfs_read_lock(sb);
 	if (!unionfs_d_revalidate(dentry, NULL) && !d_deleted(dentry)) {
@@@@ -286,7 +286,7 @@@@ int unionfs_file_revalidate(struct file *file, int willwrite)
 	}
 
 out:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	unionfs_read_unlock(dentry->d_sb);
 	return err;
 }
@@@@ -406,7 +406,7 @@@@ int unionfs_open(struct inode *inode, struct file *file)
 	}
 
 	dentry = file->f_dentry;
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	unionfs_read_lock(inode->i_sb);
 
 	bstart = fbstart(file) = dbstart(dentry);
@@@@ -436,7 +436,7 @@@@ int unionfs_open(struct inode *inode, struct file *file)
 		}
 	}
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	unionfs_read_unlock(inode->i_sb);
 
 out:
a54 18
@@@@ -564,7 +564,7 @@@@ int unionfs_flush(struct file *file, fl_owner_t id)
 	if (!atomic_dec_and_test(&UNIONFS_I(dentry->d_inode)->totalopens))
 		goto out;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	bstart = fbstart(file);
 	bend = fbend(file);
@@@@ -586,7 +586,7 @@@@ int unionfs_flush(struct file *file, fl_owner_t id)
 	}
 
 out_lock:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 out:
 	return err;
 }
d56 1
a56 1
index 1d59ff3..e88f903 100644
a69 18
@@@@ -641,7 +645,7 @@@@ struct dentry *create_parents_named(struct inode *dir, struct dentry *dentry,
 
 		/* find the parent directory dentry in unionfs */
 		parent_dentry = child_dentry->d_parent;
-		lock_dentry(parent_dentry);
+		unionfs_lock_dentry(parent_dentry);
 
 		/* find out the hidden_parent_dentry in the given branch */
 		hidden_parent_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
@@@@ -677,7 +681,7 @@@@ struct dentry *create_parents_named(struct inode *dir, struct dentry *dentry,
 	while (1) {
 		/* get hidden parent dir in the current branch */
 		hidden_parent_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
-		unlock_dentry(parent_dentry);
+		unionfs_unlock_dentry(parent_dentry);
 
 		/* init the values to lookup */
 		childname = child_dentry->d_name.name;
d71 1
a71 1
index 740c000..3c8abb3 100644
a86 21
@@@@ -184,9 +178,9 @@@@ int unionfs_d_revalidate_wrap(struct dentry *dentry, struct nameidata *nd)
 {
 	int err;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	err = unionfs_d_revalidate(dentry, nd);
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 
 	return err;
 }
@@@@ -199,7 +193,7 @@@@ void unionfs_d_release(struct dentry *dentry)
 	 * reference, but the printing functions verify that we have a lock
 	 * on the dentry before calling dbstart, etc.
 	 */
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	/* this could be a negative dentry, so check first */
 	if (!UNIONFS_D(dentry)) {
d88 1
a88 1
index ab3bf2c..6576120 100644
d140 1
a140 1
+static inline void unionfs_lock_dentry(struct dentry *d)
d142 1
a142 1
+	mutex_lock(&UNIONFS_D(d)->lock);
d145 1
a145 1
+static inline void unionfs_unlock_dentry(struct dentry *d)
d147 1
a147 1
+	mutex_unlock(&UNIONFS_D(d)->lock);
d172 1
a172 1
index 36f2660..fb897e4 100644
a189 119
@@@@ -37,7 +29,7 @@@@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
 	int bindex = 0, bstart;
 	char *name = NULL;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	/* We start out in the leftmost branch. */
 	bstart = dbstart(dentry);
@@@@ -191,7 +183,7 @@@@ out:
 	dput(wh_dentry);
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -326,8 +318,8 @@@@ out:
 
 	kfree(name);
 
-	unlock_dentry(new_dentry);
-	unlock_dentry(old_dentry);
+	unionfs_unlock_dentry(new_dentry);
+	unionfs_unlock_dentry(old_dentry);
 
 	return err;
 }
@@@@ -343,7 +335,7 @@@@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
 	int bindex = 0, bstart;
 	char *name = NULL;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	/* We start out in the leftmost branch. */
 	bstart = dbstart(dentry);
@@@@ -451,7 +443,7 @@@@ out:
 		d_drop(dentry);
 
 	kfree(name);
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -465,7 +457,7 @@@@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
 	int whiteout_unlinked = 0;
 	struct sioq_args args;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	bstart = dbstart(dentry);
 
 	hidden_dentry = unionfs_lower_dentry(dentry);
@@@@ -578,7 +570,7 @@@@ out:
 
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -592,7 +584,7 @@@@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
 	char *name = NULL;
 	int whiteout_unlinked = 0;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	bstart = dbstart(dentry);
 
 	hidden_dentry = unionfs_lower_dentry(dentry);
@@@@ -684,7 +676,7 @@@@ out:
 
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -693,7 +685,7 @@@@ int unionfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
 	int err;
 	struct dentry *hidden_dentry;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	hidden_dentry = unionfs_lower_dentry(dentry);
 
 	if (!hidden_dentry->d_inode->i_op ||
@@@@ -707,7 +699,7 @@@@ int unionfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
 		fsstack_copy_attr_atime(dentry->d_inode, hidden_dentry->d_inode);
 
 out:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -858,7 +850,7 @@@@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
 	int i;
 	int copyup = 0;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	bstart = dbstart(dentry);
 	bend = dbend(dentry);
 	inode = dentry->d_inode;
@@@@ -906,7 +898,7 @@@@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
 	fsstack_copy_inode_size(inode, hidden_inode);
 
 out:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
d191 1
a191 1
index 576e224..ff99a71 100644
a252 22
@@@@ -62,7 +110,7 @@@@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
 	parent_dentry = dget_parent(dentry);
 	/* We never partial lookup the root directory. */
 	if (parent_dentry != dentry) {
-		lock_dentry(parent_dentry);
+		unionfs_lock_dentry(parent_dentry);
 		locked_parent = 1;
 	} else {
 		dput(parent_dentry);
@@@@ -330,10 +378,10 @@@@ out:
 	}
 	kfree(whname);
 	if (locked_parent)
-		unlock_dentry(parent_dentry);
+		unionfs_unlock_dentry(parent_dentry);
 	dput(parent_dentry);
 	if (locked_child)
-		unlock_dentry(dentry);
+		unionfs_unlock_dentry(dentry);
 	return ERR_PTR(err);
 }
 
a310 11
@@@@ -443,7 +440,9 @@@@ int new_dentry_private_data(struct dentry *dentry)
 
 		if (!info)
 			goto out;
-		init_MUTEX_LOCKED(&info->sem);
+
+		mutex_init(&info->lock);
+		mutex_lock(&info->lock);
 
 		info->lower_paths = NULL;
 	} else
d312 1
a312 1
index 9cab716..4ebe080 100644
a347 42
@@@@ -586,7 +586,7 @@@@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
 	/* call interpose to create the upper level inode */
 	if ((err = unionfs_interpose(sb->s_root, sb, 0)))
 		goto out_freedpd;
-	unlock_dentry(sb->s_root);
+	unionfs_unlock_dentry(sb->s_root);
 	goto out;
 
 out_freedpd:
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 76ec0ce..95dd39f 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@@@ -322,7 +322,7 @@@@ static struct dentry *lookup_whiteout(struct dentry *dentry)
 		return (void *)whname;
 
 	parent = dget_parent(dentry);
-	lock_dentry(parent);
+	unionfs_lock_dentry(parent);
 	bstart = dbstart(parent);
 	bend = dbend(parent);
 	wh_dentry = ERR_PTR(-ENOENT);
@@@@ -339,7 +339,7 @@@@ static struct dentry *lookup_whiteout(struct dentry *dentry)
 		dput(wh_dentry);
 		wh_dentry = ERR_PTR(-ENOENT);
 	}
-	unlock_dentry(parent);
+	unionfs_unlock_dentry(parent);
 	dput(parent);
 	kfree(whname);
 	return wh_dentry;
@@@@ -438,8 +438,8 @@@@ out:
 		if (S_ISDIR(old_dentry->d_inode->i_mode))
 			atomic_dec(&UNIONFS_D(old_dentry)->generation);
 
-	unlock_dentry(new_dentry);
-	unlock_dentry(old_dentry);
+	unionfs_unlock_dentry(new_dentry);
+	unionfs_unlock_dentry(old_dentry);
 	return err;
 }
 
d419 1
a419 1
index 6734776..d50962c 100644
a421 12
@@@@ -109,9 +109,9 @@@@ int unionfs_refresh_hidden_dentry(struct dentry *dentry, int bindex)
 
 	verify_locked(dentry);
 
-	lock_dentry(dentry->d_parent);
+	unionfs_lock_dentry(dentry->d_parent);
 	hidden_parent = unionfs_lower_dentry_idx(dentry->d_parent, bindex);
-	unlock_dentry(dentry->d_parent);
+	unionfs_unlock_dentry(dentry->d_parent);
 
 	BUG_ON(!S_ISDIR(hidden_parent->d_inode->i_mode));
 
d488 1
a488 1
index 25085bf..f6e925b 100644
d491 1
a491 10
@@@@ -295,7 +295,7 @@@@ static int unionfs_show_options(struct seq_file *m, struct vfsmount *mnt)
 	int bindex, bstart, bend;
 	int perms;
 
-	lock_dentry(sb->s_root);
+	unionfs_lock_dentry(sb->s_root);
 
 	tmp_page = (char*) __get_free_page(GFP_KERNEL);
 	if (!tmp_page) {
@@@@ -321,10 +321,9 @@@@ static int unionfs_show_options(struct seq_file *m, struct vfsmount *mnt)
d499 1
a499 2
-	unlock_dentry(sb->s_root);
+	unionfs_unlock_dentry(sb->s_root);
a500 2
 	return ret;
 }
d502 1
a502 1
index f08eb75..e721790 100644
a504 20
@@@@ -111,7 +111,7 @@@@ struct unionfs_dentry_info {
 	 * unionfs function from the VFS.  Our lock ordering is that children
 	 * go before their parents.
 	 */
-	struct semaphore sem;
+	struct mutex lock;
 	int bstart;
 	int bend;
 	int bopaque;
@@@@ -226,8 +226,8 @@@@ static inline void double_lock_dentry(struct dentry *d1, struct dentry *d2)
 		d1 = d2;
 		d2 = tmp;
 	}
-	lock_dentry(d1);
-	lock_dentry(d2);
+	unionfs_lock_dentry(d1);
+	unionfs_lock_dentry(d2);
 }
 
 extern int new_dentry_private_data(struct dentry *dentry);
a596 106
diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c
index 844835f..7c7f998 100644
--- a/fs/unionfs/unlink.c
+++ b/fs/unionfs/unlink.c
@@@@ -74,14 +74,14 @@@@ int unionfs_unlink(struct inode *dir, struct dentry *dentry)
 {
 	int err = 0;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	err = unionfs_unlink_whiteout(dir, dentry);
 	/* call d_drop so the system "forgets" about us */
 	if (!err)
 		d_drop(dentry);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -122,7 +122,7 @@@@ int unionfs_rmdir(struct inode *dir, struct dentry *dentry)
 	int err = 0;
 	struct unionfs_dir_state *namelist = NULL;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	/* check if this unionfs directory is empty or not */
 	err = check_empty(dentry, &namelist);
@@@@ -156,7 +156,7 @@@@ out:
 	if (namelist)
 		free_rdstate(namelist);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 881a05d..07598cc 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@@@ -56,13 +56,13 @@@@ ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
 	struct dentry *hidden_dentry = NULL;
 	int err = -EOPNOTSUPP;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	hidden_dentry = unionfs_lower_dentry(dentry);
 
 	err = vfs_getxattr(hidden_dentry, (char*) name, value, size);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -75,12 +75,12 @@@@ int unionfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 	struct dentry *hidden_dentry = NULL;
 	int err = -EOPNOTSUPP;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	hidden_dentry = unionfs_lower_dentry(dentry);
 
 	err = vfs_setxattr(hidden_dentry, (char*) name, (void*) value, size, flags);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -92,12 +92,12 @@@@ int unionfs_removexattr(struct dentry *dentry, const char *name)
 	struct dentry *hidden_dentry = NULL;
 	int err = -EOPNOTSUPP;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	hidden_dentry = unionfs_lower_dentry(dentry);
 
 	err = vfs_removexattr(hidden_dentry, (char*) name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@@@ -110,14 +110,14 @@@@ ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
 	int err = -EOPNOTSUPP;
 	char *encoded_list = NULL;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 
 	hidden_dentry = unionfs_lower_dentry(dentry);
 
 	encoded_list = list;
 	err = vfs_listxattr(hidden_dentry, encoded_list, size);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@


1.1.2.3
log
@A. Bunk's patch, more akpm comments, new copyright
@
text
@a0 15
fs/unionfs/: Andrew Morton's comments

- rename {,un}lock_dentry to unionfs_{,un}lock_dentry
- few minor coding style fixes
- removed prototypes from .c files
- replaced dbstart macros etc with static inlines
- replaced UNIONFS_D(d)->sem semaphore with a mutex
- renamed sioq struct workqueue to superio_workqueue
- made unionfs_get_nlinks and alloc_whname not inlined

TODO:
- change run_sioq to not be busy-wait
- make sure Documentation/filesystems/unionfs/concepts.txt describes copyup
  well enough

d24 1
a24 1
index 76b2ed9..91ea181 100644
d132 1
a132 1
index 15296d4..032371a 100644
d135 3
a137 3
@@@@ -26,6 +26,10 @@@@ static struct dentry *create_parents_named(struct inode *dir,
 					   struct dentry *dentry,
 					   const char *name, int bindex);
d146 1
a146 1
@@@@ -646,7 +650,7 @@@@ static struct dentry *create_parents_named(struct inode *dir,
d155 1
a155 1
@@@@ -682,7 +686,7 @@@@ static struct dentry *create_parents_named(struct inode *dir,
d165 1
a165 1
index 04afcb6..3d0065e 100644
d168 14
a181 1
@@@@ -179,9 +179,9 @@@@ static int unionfs_d_revalidate_wrap(struct dentry *dentry,
d193 1
a193 1
@@@@ -194,7 +194,7 @@@@ static void unionfs_d_release(struct dentry *dentry)
d270 16
d287 1
a287 1
index 07044ac..40974e2 100644
d290 16
a305 1
@@@@ -29,7 +29,7 @@@@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
d314 1
a314 1
@@@@ -183,7 +183,7 @@@@ out:
d323 1
a323 1
@@@@ -319,8 +319,8 @@@@ out:
d334 1
a334 1
@@@@ -336,7 +336,7 @@@@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
d343 1
a343 1
@@@@ -444,7 +444,7 @@@@ out:
d352 1
a352 1
@@@@ -458,7 +458,7 @@@@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
d361 1
a361 1
@@@@ -571,7 +571,7 @@@@ out:
d370 1
a370 1
@@@@ -585,7 +585,7 @@@@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
d379 1
a379 1
@@@@ -677,7 +677,7 @@@@ out:
d388 1
a388 1
@@@@ -687,7 +687,7 @@@@ static int unionfs_readlink(struct dentry *dentry, char __user * buf,
d397 1
a397 1
@@@@ -701,7 +701,7 @@@@ static int unionfs_readlink(struct dentry *dentry, char __user * buf,
d406 1
a406 1
@@@@ -853,7 +853,7 @@@@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
d415 1
a415 1
@@@@ -901,7 +901,7 @@@@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
d579 1
a579 1
index 3783f07..28d79ef 100644
d658 1
a658 1
index 1c71185..c3142c9 100644
d665 2
a666 2
-static struct workqueue_struct *sioq;
+static struct workqueue_struct *superio_workqueue;
d714 13
d835 1
a835 1
index d524f10..abfa34d 100644
d858 1
a858 1
@@@@ -267,6 +267,8 @@@@ extern int remove_whiteouts(struct dentry *dentry, struct dentry *hidden_dentry,
d867 1
a867 1
@@@@ -336,52 +338,6 @@@@ static inline int d_deleted(struct dentry *d)
d918 1
d920 1
a920 2
 
@@@@ -449,21 +405,6 @@@@ static inline int is_robranch(const struct dentry *dentry)
d942 1
a942 1
@@@@ -473,6 +414,7 @@@@ static inline char *alloc_whname(const char *name, int len)
@


1.1.2.4
log
@Moved akpm & bunk-fixes patches into unionfs dir & changed lookup to be
gentler to the stack by not allocating a new nameidata on the stack
@
text
@@


