Skip to contentSkip to conversation

Unionfs updates/cleanups

GIT PULL In review Josef 'Jeff' Sipek 3 participants 9 messages Jan 29, 2007 – Jan 30, 2007 VFS

lore
Share & tools
lore
#0 lore raw

The following patches (also available though the git tree) address a number of code cleanliness issues with Unionfs.

You can pull from 'master' branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jsipek/unionfs.git

to receive the following:

Adrian Bunk (1):
fs/unionfs/: possible cleanups

Josef 'Jeff' Sipek (3):
fs/unionfs/: Remove stale_inode.c fs/unionfs/: Andrew Morton's comments fs/unionfs/: Don't duplicate the struct nameidata

 fs/unionfs/branchman.c   |    4 +-
 fs/unionfs/commonfops.c  |   54 +++++++++++-----------
 fs/unionfs/copyup.c      |   67 +++++++++++++++------------
 fs/unionfs/dentry.c      |   19 +++-----
 fs/unionfs/fanout.h      |   51 +++++++++++++++++----
 fs/unionfs/file.c        |   17 +++-----
 fs/unionfs/inode.c       |   69 +++++++++++++++-------------
 fs/unionfs/lookup.c      |  113 +++++++++++++++++++++++-----------------------
 fs/unionfs/main.c        |   32 +++++++-------
 fs/unionfs/rdstate.c     |    2 +-
 fs/unionfs/rename.c      |    8 ++--
 fs/unionfs/sioq.c        |   19 ++++----
 fs/unionfs/sioq.h        |    1 -
 fs/unionfs/stale_inode.c |  112 ---------------------------------------------
 fs/unionfs/subr.c        |   65 +++++++++++++++++++++++++-
 fs/unionfs/super.c       |    7 +--
 fs/unionfs/union.h       |   84 +++-------------------------------
 fs/unionfs/unlink.c      |    8 ++--
 fs/unionfs/xattr.c       |   16 +++---
 19 files changed, 330 insertions(+), 418 deletions(-)

Josef 'Jeff' Sipek.

[email protected]

#1 lore raw

PATCH 1/4 fs/unionfs/: Remove stale_inode.c

The stale inode operations were heavily based on bad inode operations. This patch removes stale_inode.c and converts all users of stale_inode_ops to bad_inode_ops as there seems to be no reason to return ESTALE instead of EIO.

This is the more appropriate than porting the bad_inode.c fix (commit be6aab0e9fa6d3c6d75aa1e38ac972d8b4ee82b8) to stale_inode.c.

---
 fs/unionfs/dentry.c      |    2 +-
 fs/unionfs/stale_inode.c |  112 ----------------------------------------------
 fs/unionfs/union.h       |    1 -
 3 files changed, 1 insertions(+), 114 deletions(-)
 delete mode 100644 fs/unionfs/stale_inode.c
fs/unionfs/dentry.c +1 -1
index 78de9c9..0b002d1 100644
@@ -141,7 +141,7 @@ restart:
 		}
 
 		if (positive && UNIONFS_I(dentry->d_inode)->stale) {
-			make_stale_inode(dentry->d_inode);
+			make_bad_inode(dentry->d_inode);
 			d_drop(dentry);
 			valid = 0;
 			goto out;
fs/unionfs/stale_inode.c deleted +0 -112

112 lines not on this page · raw message

fs/unionfs/union.h +0 -1
index b6e03ff..637f9f0 100644
@@ -396,7 +396,6 @@ static inline int unionfs_get_nlinks(struct inode *inode)
 
 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);
 
 #define IS_SET(sb, check_flag) ((check_flag) & MOUNT_FLAG(sb))
 
Signature · 1 line
1.5.0.rc1.g5355
#2 lore raw

PATCH 2/4 fs/unionfs/: possible cleanups

In reply to Josef 'Jeff' Sipek

From: Adrian Bunk <[email protected]> - unquoted

This patch contains the following possible cleanups:
- every function should #include the headers containing the prototypes of it's global functions
- static functions in C files shouldn't be marked "inline", gcc should know best when to inline them
- make needlessly global code static
- #if 0 the following unused global function:
- stale_inode.c: is_stale_inode()

[removed stale inode related fixes as stale_inode.c is gone]
---
 fs/unionfs/commonfops.c |    6 ++--
 fs/unionfs/copyup.c     |   59 +++++++++++++++++++++++++---------------------
 fs/unionfs/dentry.c     |   11 ++------
 fs/unionfs/file.c       |   17 ++++--------
 fs/unionfs/inode.c      |   19 +++++---------
 fs/unionfs/main.c       |    4 +-
 fs/unionfs/rdstate.c    |    2 +-
 fs/unionfs/sioq.c       |    2 +-
 fs/unionfs/sioq.h       |    1 -
 fs/unionfs/union.h      |   13 ----------
 10 files changed, 55 insertions(+), 79 deletions(-)
fs/unionfs/commonfops.c +3 -3
index 6226a34..1806acf 100644
@@ -292,7 +292,7 @@ out:
 }
 
 /* unionfs_open helper function: open a directory */
-static inline int __open_dir(struct inode *inode, struct file *file)
+static int __open_dir(struct inode *inode, struct file *file)
 {
 	struct dentry *hidden_dentry;
 	struct file *hidden_file;
@@ -326,7 +326,7 @@ static inline int __open_dir(struct inode *inode, struct file *file)
 }
 
 /* unionfs_open helper function: open a file */
-static inline int __open_file(struct inode *inode, struct file *file)
+static int __open_file(struct inode *inode, struct file *file)
 {
 	struct dentry *hidden_dentry;
 	struct file *hidden_file;
@@ -493,7 +493,7 @@ int unionfs_file_release(struct inode *inode, struct file *file)
 }
 
 /* pass the ioctl to the lower fs */
-static inline long do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+static long do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct file *hidden_file;
 	int err;
fs/unionfs/copyup.c +32 -27

113 lines not on this page · raw message

fs/unionfs/dentry.c +3 -8
index 0b002d1..d7193cc 100644
@@ -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.
  */
@@ -180,7 +174,8 @@ out:
 	return valid;
 }
 
-int unionfs_d_revalidate_wrap(struct dentry *dentry, struct nameidata *nd)
+static int unionfs_d_revalidate_wrap(struct dentry *dentry,
+				     struct nameidata *nd)
 {
 	int err;
 
@@ -191,7 +186,7 @@ int unionfs_d_revalidate_wrap(struct dentry *dentry, struct nameidata *nd)
 	return err;
 }
 
-void unionfs_d_release(struct dentry *dentry)
+static void unionfs_d_release(struct dentry *dentry)
 {
 	int bindex, bstart, bend;
 
fs/unionfs/file.c +6 -11
index d056e4f..9ce092d 100644
@@ -18,11 +18,6 @@
 
 #include "union.h"
 
-/* declarations for sparse */
-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 *);
-
 /*******************
  * File Operations *
  *******************/
@@ -56,8 +51,8 @@ out:
 	return err;
 }
 
-ssize_t unionfs_read(struct file * file, char __user * buf, size_t count,
-		     loff_t * ppos)
+static ssize_t unionfs_read(struct file * file, char __user * buf,
+			    size_t count, loff_t * ppos)
 {
 	struct file *hidden_file;
 	loff_t pos = *ppos;
@@ -78,8 +73,8 @@ out:
 	return err;
 }
 
-ssize_t __unionfs_write(struct file * file, const char __user * buf,
-			size_t count, loff_t * ppos)
+static ssize_t __unionfs_write(struct file * file, const char __user * buf,
+			       size_t count, loff_t * ppos)
 {
 	int err = -EINVAL;
 	struct file *hidden_file = NULL;
@@ -123,8 +118,8 @@ out:
 	return err;
 }
 
-ssize_t unionfs_write(struct file * file, const char __user * buf, size_t count,
-		      loff_t * ppos)
+static ssize_t unionfs_write(struct file * file, const char __user * buf,
+			     size_t count, loff_t * ppos)
 {
 	int err = 0;
 
fs/unionfs/inode.c +7 -12
index 8246d15..1adb83c 100644
@@ -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)
 {
@@ -195,8 +187,9 @@ out:
 	return err;
 }
 
-struct dentry *unionfs_lookup(struct inode *parent, struct dentry *dentry,
-			      struct nameidata *nd)
+static struct dentry *unionfs_lookup(struct inode *parent,
+				     struct dentry *dentry,
+				     struct nameidata *nd)
 {
 	struct nameidata lowernd; /* TODO: be gentler to the stack */
 
@@ -688,7 +681,8 @@ out:
 	return err;
 }
 
-int unionfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
+static int unionfs_readlink(struct dentry *dentry, char __user * buf,
+			    int bufsiz)
 {
 	int err;
 	struct dentry *hidden_dentry;
@@ -743,7 +737,8 @@ out:
 	return ERR_PTR(err);
 }
 
-void unionfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
+static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
+			     void *cookie)
 {
 	kfree(nd_get_link(nd));
 }
fs/unionfs/main.c +2 -2
index ae0a148..033eb7c 100644
@@ -188,7 +188,7 @@ void unionfs_reinterpose(struct dentry *dentry)
  * 2) it exists
  * 3) is a directory
  */
-int check_branch(struct nameidata *nd)
+static int check_branch(struct nameidata *nd)
 {
 	if (!strcmp(nd->dentry->d_sb->s_type->name, "unionfs"))
 		return -EINVAL;
@@ -200,7 +200,7 @@ int check_branch(struct nameidata *nd)
 }
 
 /* checks if two hidden_dentries have overlapping branches */
-int is_branch_overlap(struct dentry *dent1, struct dentry *dent2)
+static int is_branch_overlap(struct dentry *dent1, struct dentry *dent2)
 {
 	struct dentry *dent = NULL;
 
fs/unionfs/rdstate.c +1 -1
index 7f11ae2..16ce1bf 100644
@@ -232,7 +232,7 @@ struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
 	return cursor;
 }
 
-inline struct filldir_node *alloc_filldir_node(const char *name, int namelen,
+static struct filldir_node *alloc_filldir_node(const char *name, int namelen,
 					       unsigned int hash, int bindex)
 {
 	return kmem_cache_alloc(unionfs_filldir_cachep, GFP_KERNEL);
fs/unionfs/sioq.c +1 -1
index a8bc493..3225f5b 100644
@@ -24,7 +24,7 @@
  * whiteouts).
  */
 
-struct workqueue_struct *sioq;
+static struct workqueue_struct *sioq;
 
 int __init init_sioq(void)
 {
fs/unionfs/sioq.h +0 -1
index 5a93414..20e3b0c 100644
@@ -61,7 +61,6 @@ struct sioq_args {
 	};
 };
 
-extern struct workqueue_struct *sioq;
 extern int __init init_sioq(void);
 extern __exit void stop_sioq(void);
 extern void run_sioq(work_func_t func, struct sioq_args *args);
fs/unionfs/union.h +0 -13
index 637f9f0..0c61f80 100644
@@ -241,11 +241,6 @@ void update_bstart(struct dentry *dentry);
 /* replicates the directory structure upto given dentry in given branch */
 extern struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
 				     int bindex);
-struct dentry *create_parents_named(struct inode *dir, struct dentry *dentry,
-				    const char *name, int bindex);
-
-/* check if two branches overlap */
-extern int is_branch_overlap(struct dentry *dent1, struct dentry *dent2);
 
 /* partial lookup */
 extern int unionfs_partial_lookup(struct dentry *dentry);
@@ -265,10 +260,6 @@ extern int copyup_named_file(struct inode *dir, struct file *file,
 /* copies a dentry from dbstart to newbindex branch */
 extern int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 			 int new_bindex, struct file **copyup_file, loff_t len);
-extern int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
-			       int bstart, int new_bindex, const char *name,
-			       int namelen, struct file **copyup_file,
-			       loff_t len);
 
 extern int remove_whiteouts(struct dentry *dentry, struct dentry *hidden_dentry,
 			    int bindex);
@@ -325,9 +316,6 @@ int unionfs_ioctl_incgen(struct file *file, unsigned int cmd,
 int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
 			    unsigned long arg);
 
-/* Verify that a branch is valid. */
-int check_branch(struct nameidata *nd);
-
 #ifdef CONFIG_UNION_FS_XATTR
 /* Extended attribute functions. */
 extern void *unionfs_xattr_alloc(size_t size, size_t limit);
@@ -395,7 +383,6 @@ static inline int unionfs_get_nlinks(struct inode *inode)
 }
 
 struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd, int lookupmode);
-int is_stale_inode(struct inode *inode);
 
 #define IS_SET(sb, check_flag) ((check_flag) & MOUNT_FLAG(sb))
 
Signature · 1 line
1.5.0.rc1.g5355
#3 lore raw

PATCH 3/4 fs/unionfs/: Andrew Morton's comments

In reply to Josef 'Jeff' Sipek

- 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

---
 fs/unionfs/branchman.c  |    4 +-
 fs/unionfs/commonfops.c |   48 ++++++++++----------
 fs/unionfs/copyup.c     |    8 +++-
 fs/unionfs/dentry.c     |    6 +-
 fs/unionfs/fanout.h     |   51 +++++++++++++++++----
 fs/unionfs/inode.c      |   28 ++++++------
 fs/unionfs/lookup.c     |  113 +++++++++++++++++++++++------------------------
 fs/unionfs/main.c       |   28 ++++++------
 fs/unionfs/rename.c     |    8 ++--
 fs/unionfs/sioq.c       |   19 ++++----
 fs/unionfs/subr.c       |   65 ++++++++++++++++++++++++++-
 fs/unionfs/super.c      |    7 +--
 fs/unionfs/union.h      |   70 +++--------------------------
 fs/unionfs/unlink.c     |    8 ++--
 fs/unionfs/xattr.c      |   16 +++---
 15 files changed, 259 insertions(+), 220 deletions(-)
fs/unionfs/branchman.c +2 -2
index 9180de1..83d443a 100644
@@ -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;
 }
 
fs/unionfs/commonfops.c +24 -24

96 lines not on this page · raw message

fs/unionfs/copyup.c +6 -2
index 1ef8baf..998cc69 100644
@@ -26,6 +26,10 @@ static struct dentry *create_parents_named(struct inode *dir,
 					   struct dentry *dentry,
 					   const char *name, int bindex);
 
+/* 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,
@@ -646,7 +650,7 @@ static struct dentry *create_parents_named(struct inode *dir,
 
 		/* 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);
@@ -682,7 +686,7 @@ static struct dentry *create_parents_named(struct inode *dir,
 	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;
fs/unionfs/dentry.c +3 -3
index d7193cc..3721409 100644
@@ -179,9 +179,9 @@ static int unionfs_d_revalidate_wrap(struct dentry *dentry,
 {
 	int err;
 
-	lock_dentry(dentry);
+	unionfs_lock_dentry(dentry);
 	err = unionfs_d_revalidate(dentry, nd);
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 
 	return err;
 }
@@ -194,7 +194,7 @@ static 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)) {
fs/unionfs/fanout.h +42 -9

62 lines not on this page · raw message

fs/unionfs/inode.c +14 -14
index 1adb83c..3b4a388 100644
@@ -29,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);
@@ -183,7 +183,7 @@ out:
 	dput(wh_dentry);
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@ -319,8 +319,8 @@ out:
 
 	kfree(name);
 
-	unlock_dentry(new_dentry);
-	unlock_dentry(old_dentry);
+	unionfs_unlock_dentry(new_dentry);
+	unionfs_unlock_dentry(old_dentry);
 
 	return err;
 }
@@ -336,7 +336,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);
@@ -444,7 +444,7 @@ out:
 		d_drop(dentry);
 
 	kfree(name);
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@ -458,7 +458,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);
@@ -571,7 +571,7 @@ out:
 
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@ -585,7 +585,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);
@@ -677,7 +677,7 @@ out:
 
 	kfree(name);
 
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@ -687,7 +687,7 @@ static int unionfs_readlink(struct dentry *dentry, char __user * buf,
 	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 ||
@@ -701,7 +701,7 @@ static int unionfs_readlink(struct dentry *dentry, char __user * buf,
 		fsstack_copy_attr_atime(dentry->d_inode, hidden_dentry->d_inode);
 
 out:
-	unlock_dentry(dentry);
+	unionfs_unlock_dentry(dentry);
 	return err;
 }
 
@@ -853,7 +853,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;
@@ -901,7 +901,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;
 }
 
fs/unionfs/lookup.c +56 -57

145 lines not on this page · raw message

fs/unionfs/main.c +14 -14
index 033eb7c..36d30bc 100644
@@ -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);
@@ -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:
fs/unionfs/rename.c +4 -4
index c561f3d..c9aa040 100644
@@ -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;
 }
 
fs/unionfs/sioq.c +10 -9
index 3225f5b..7830b89 100644
@@ -24,26 +24,26 @@
  * whiteouts).
  */
 
-static struct workqueue_struct *sioq;
+static 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;
 
fs/unionfs/subr.c +63 -2

75 lines not on this page · raw message

fs/unionfs/super.c +3 -4
index 823cdfc..38443c7 100644
@@ -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)
 	}
 
 out:
-	if (tmp_page)
-		free_page((unsigned long) tmp_page);
+	free_page((unsigned long) tmp_page);
 
-	unlock_dentry(sb->s_root);
+	unionfs_unlock_dentry(sb->s_root);
 
 	return ret;
 }
fs/unionfs/union.h +6 -64

106 lines not on this page · raw message

fs/unionfs/unlink.c +4 -4
index 9e690d2..f5b250a 100644
@@ -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;
 }
 
fs/unionfs/xattr.c +8 -8
index 4705f46..d57f079 100644
@@ -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;
 }
 
Signature · 1 line
1.5.0.rc1.g5355
#4 lore raw

PATCH 4/4 fs/unionfs/: Don't duplicate the struct nameidata

In reply to Josef 'Jeff' Sipek

Josef 'Jeff' Sipek (3):
fs/unionfs/: Remove stale_inode.c fs/unionfs/: Andrew Morton's comments fs/unionfs/: Don't duplicate the struct nameidata

 fs/unionfs/branchman.c   |    4 +-
 fs/unionfs/commonfops.c  |   54 +++++++++++-----------
 fs/unionfs/copyup.c      |   67 +++++++++++++++------------
 fs/unionfs/dentry.c      |   19 +++-----
 fs/unionfs/fanout.h      |   51 +++++++++++++++++----
 fs/unionfs/file.c        |   17 +++-----
 fs/unionfs/inode.c       |   69 +++++++++++++++-------------
 fs/unionfs/lookup.c      |  113 +++++++++++++++++++++++-----------------------
 fs/unionfs/main.c        |   32 +++++++-------
 fs/unionfs/rdstate.c     |    2 +-
 fs/unionfs/rename.c      |    8 ++--
 fs/unionfs/sioq.c        |   19 ++++----
 fs/unionfs/sioq.h        |    1 -
 fs/unionfs/stale_inode.c |  112 ---------------------------------------------
 fs/unionfs/subr.c        |   65 +++++++++++++++++++++++++-
 fs/unionfs/super.c       |    7 +--
 fs/unionfs/union.h       |   84 +++-------------------------------
 fs/unionfs/unlink.c      |    8 ++--
 fs/unionfs/xattr.c       |   16 +++---
 19 files changed, 330 insertions(+), 418 deletions(-)
#5 lore raw

Re: [PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata

Quoted 17 lines · Josef 'Jeff' Sipek

Josef 'Jeff' Sipek (3):
fs/unionfs/: Remove stale_inode.c fs/unionfs/: Andrew Morton's comments fs/unionfs/: Don't duplicate the struct nameidata

 fs/unionfs/branchman.c   |    4 +-
 fs/unionfs/commonfops.c  |   54 +++++++++++-----------
 fs/unionfs/copyup.c      |   67 +++++++++++++++------------
 fs/unionfs/dentry.c      |   19 +++-----
 fs/unionfs/fanout.h      |   51 +++++++++++++++++----
 fs/unionfs/file.c        |   17 +++-----
 fs/unionfs/inode.c       |   69 +++++++++++++++-------------
 fs/unionfs/lookup.c      |  113 +++++++++++++++++++++++-----------------------
 fs/unionfs/main.c        |   32 +++++++-------
 fs/unionfs/rdstate.c     |    2 +-
 fs/unionfs/rename.c      |    8 ++--
 fs/unionfs/sioq.c        |   19 ++++----
Quoted 8 lines
 fs/unionfs/sioq.h        |    1 -
 fs/unionfs/stale_inode.c |  112 ---------------------------------------------
 fs/unionfs/subr.c        |   65 +++++++++++++++++++++++++-
 fs/unionfs/super.c       |    7 +--
 fs/unionfs/union.h       |   84 +++-------------------------------
 fs/unionfs/unlink.c      |    8 ++--
 fs/unionfs/xattr.c       |   16 +++---
 19 files changed, 330 insertions(+), 418 deletions(-)

Not sure why this was sent. The other 4/4 email is the correct one.

Josef "Jeff" Sipek.

Signature · 2 lines
Bad pun of the week: The formula 1 control computer suffered from a race
condition
#6 lore raw

PATCH 4/4 fs/unionfs/: Don't duplicate the struct nameidata

In reply to Josef 'Jeff' Sipek

The only fields that we have to watch out for are the dentry and vfsmount. Additionally, this makes Unionfs gentler on the stack as nameidata is rather large.

---
 fs/unionfs/inode.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
fs/unionfs/inode.c +16 -6
index 3b4a388..1b2e8a8 100644
@@ -191,15 +191,25 @@ static struct dentry *unionfs_lookup(struct inode *parent,
 				     struct dentry *dentry,
 				     struct nameidata *nd)
 {
-	struct nameidata lowernd; /* TODO: be gentler to the stack */
+	struct path path_save;
+	struct dentry *ret;
 
-	if (nd)
-		memcpy(&lowernd, nd, sizeof(struct nameidata));
-	else
-		memset(&lowernd, 0, sizeof(struct nameidata));
+	/* save the dentry & vfsmnt from namei */
+	if (nd) {
+		path_save.dentry = nd->dentry;
+		path_save.mnt = nd->mnt;
+	}
 
 	/* The locking is done by unionfs_lookup_backend. */
-	return unionfs_lookup_backend(dentry, &lowernd, INTERPOSE_LOOKUP);
+	ret = unionfs_lookup_backend(dentry, nd, INTERPOSE_LOOKUP);
+
+	/* restore the dentry & vfsmnt in namei */
+	if (nd) {
+		nd->dentry = path_save.dentry;
+		nd->mnt = path_save.mnt;
+	}
+
+	return ret;
 }
 
 static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
Signature · 1 line
1.5.0.rc1.g5355
#7 lore raw

Re: [PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata

Quoted 3 lines · Josef 'Jeff' Sipek

The only fields that we have to watch out for are the dentry and vfsmount. Additionally, this makes Unionfs gentler on the stack as nameidata is rather large.

That's onviously not true at all. To handle any filesystems using intents (e.g. NFSv4) you need to do much more. Then again doing things correctly doesn't seem to be interesting to the stackable filesystems crowd an this problem has been constantly ignored over the last year, including merging ecryptfs which has been broken in the same way.

Folks, if you want your stackable filesystem toys taken seriously you need to fix these kind of issues instead of talking them away. And yes, this will involve some surgery to the VFS.

#8 lore raw

Re: [PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata

Quoted 11 lines · Christoph Hellwig
Quoted 3 lines · Josef 'Jeff' Sipek

The only fields that we have to watch out for are the dentry and vfsmount. Additionally, this makes Unionfs gentler on the stack as nameidata is rather large.

That's onviously not true at all. To handle any filesystems using intents (e.g. NFSv4) you need to do much more. Then again doing things correctly doesn't seem to be interesting to the stackable filesystems crowd an this problem has been constantly ignored over the last year, including merging ecryptfs which has been broken in the same way.

Quoted 3 lines

Folks, if you want your stackable filesystem toys taken seriously you need to fix these kind of issues instead of talking them away. And yes, this will involve some surgery to the VFS.

Indeed. I asked around (#linuxfs) and it seemed that restoring the dentry/vfsmount was sufficient for the purpose of passing intents down. If this is not the case, I'll revert the patch to do the full namei allocation.

Josef "Jeff" Sipek.

Signature · 3 lines
Computer Science is no more about computers than astronomy is about
telescopes.
		- Edsger Dijkstra