Re: [PATCH 1/1] Unionfs: cache-coherency - dentries

2007-09-06 Thread Josef 'Jeff' Sipek
On Mon, Sep 03, 2007 at 07:39:48PM -0400, Josef 'Jeff' Sipek wrote:
...
  /*
 + * Determine if the lower inode objects have changed from below the unionfs
 + * inode.  Return 1 if changed, 0 otherwise.
 + */
 +bool is_newer_lower(const struct dentry *dentry)
 +{
 + int bindex;
 + struct inode *inode;
 + struct inode *lower_inode;
 +
 + /* ignore if we're called on semi-initialized dentries/inodes */
 + if (!dentry || !UNIONFS_D(dentry))
 + return false;
 + inode = dentry-d_inode;
 + if (!inode || !UNIONFS_I(inode) ||
 + ibstart(inode)  0 || ibend(inode)  0)
 + return false;
 +
 + for (bindex = ibstart(inode); bindex = ibend(inode); bindex++) {
 + lower_inode = unionfs_lower_inode_idx(inode, bindex);
 + if (!lower_inode)
 + continue;
 + /*
 +  * We may want to apply other tests to determine if the
 +  * lower inode's data has changed, but checking for changed
 +  * ctime and mtime on the lower inode should be enough.
 +  */
 + if (timespec_compare(inode-i_mtime,
 +  lower_inode-i_mtime)  0) {
 + printk(unionfs: new lower inode mtime 
 +(bindex=%d, name=%s)\n, bindex,
 +dentry-d_name.name);
 + return true; /* mtime changed! */
 + }
 + if (timespec_compare(inode-i_ctime,
 +  lower_inode-i_ctime)  0) {
 + printk(unionfs: new lower inode ctime 
 +(bindex=%d, name=%s)\n, bindex,
 +dentry-d_name.name);
 + return true; /* ctime changed! */
 + }
 + }
 + return true;/* default: lower is not newer */

This was a thinko, it should have returned false. I'll send an updated
patch for completeness.

Josef 'Jeff' Sipek.

-- 
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
- Albert Einstein
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] Unionfs: cache-coherency - dentries

2007-09-06 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Utility functions to check if lower dentries/inodes are newer than upper
ones, and purging cached data if lower objects are newer.  Also passed flag
to our d_revalidate_chain, to tell it if the caller may be writing data or
just reading it.

[jsipek: changed purge_inode_data to take a struct inode]
Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |2 +-
 fs/unionfs/dentry.c |  143 ++-
 fs/unionfs/inode.c  |   24 +---
 fs/unionfs/rename.c |4 +-
 fs/unionfs/super.c  |2 +-
 fs/unionfs/union.h  |5 +-
 fs/unionfs/unlink.c |   12 +++-
 fs/unionfs/xattr.c  |8 +-
 8 files changed, 164 insertions(+), 36 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 28cb4e9..0dc7492 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -287,7 +287,7 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 * but not unhashed dentries.
 */
if (!d_deleted(dentry) 
-   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   !__unionfs_d_revalidate_chain(dentry, NULL, willwrite)) {
err = -ESTALE;
goto out_nofree;
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 4a3c479..647a347 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -23,19 +23,18 @@
  * Assume that dentry's info node is locked.
  * Assume that parent(s) are all valid already, but
  * the child may not yet be valid.
- * Returns 1 if valid, 0 otherwise.
+ * Returns true if valid, false otherwise.
  */
-static int __unionfs_d_revalidate_one(struct dentry *dentry,
+static bool __unionfs_d_revalidate_one(struct dentry *dentry,
  struct nameidata *nd)
 {
-   int valid = 1;  /* default is valid (1); invalid is 0. */
+   bool valid = true;  /* default is valid */
struct dentry *lower_dentry;
int bindex, bstart, bend;
int sbgen, dgen;
int positive = 0;
int locked = 0;
int interpose_flag;
-
struct nameidata lowernd; /* TODO: be gentler to the stack */
 
if (nd)
@@ -128,7 +127,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
interpose_flag);
if (result) {
if (IS_ERR(result)) {
-   valid = 0;
+   valid = false;
goto out;
}
/*
@@ -142,7 +141,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
if (positive  UNIONFS_I(dentry-d_inode)-stale) {
make_bad_inode(dentry-d_inode);
d_drop(dentry);
-   valid = 0;
+   valid = false;
goto out;
}
goto out;
@@ -158,12 +157,12 @@ static int __unionfs_d_revalidate_one(struct dentry 
*dentry,
|| !lower_dentry-d_op-d_revalidate)
continue;
if (!lower_dentry-d_op-d_revalidate(lower_dentry,
-  lowernd))
-   valid = 0;
+ lowernd))
+   valid = false;
}
 
if (!dentry-d_inode)
-   valid = 0;
+   valid = false;
 
if (valid) {
/*
@@ -184,12 +183,94 @@ out:
 }
 
 /*
+ * Determine if the lower inode objects have changed from below the unionfs
+ * inode.  Return true if changed, false otherwise.
+ */
+bool is_newer_lower(const struct dentry *dentry)
+{
+   int bindex;
+   struct inode *inode;
+   struct inode *lower_inode;
+
+   /* ignore if we're called on semi-initialized dentries/inodes */
+   if (!dentry || !UNIONFS_D(dentry))
+   return false;
+   inode = dentry-d_inode;
+   if (!inode || !UNIONFS_I(inode) ||
+   ibstart(inode)  0 || ibend(inode)  0)
+   return false;
+
+   for (bindex = ibstart(inode); bindex = ibend(inode); bindex++) {
+   lower_inode = unionfs_lower_inode_idx(inode, bindex);
+   if (!lower_inode)
+   continue;
+   /*
+* We may want to apply other tests to determine if the
+* lower inode's data has changed, but checking for changed
+* ctime and mtime on the lower inode should be enough.
+*/
+   if (timespec_compare(inode-i_mtime,
+lower_inode-i_mtime)  0) {
+   printk(unionfs: new lower inode mtime 
+  (bindex=%d, name

Re: [PATCH 12/32] Unionfs: documentation updates

2007-09-03 Thread Josef 'Jeff' Sipek
On Mon, Sep 03, 2007 at 08:59:02AM +0200, Jan Engelhardt wrote:
 
 On Sep 2 2007 22:20, Josef 'Jeff' Sipek wrote:
 +
 +While rebuilding Unionfs's objects, we also purge any page mappings and
 +truncate inode pages (see fs/Unionfs/dentry.c:purge_inode_data).  This is to
 
 fs/unionfs/dentry.c
 
 +Unionfs maintains the following important invariant regarding mtime's,
 +ctime's, and atime's: the upper inode object's times are the max() of all of
 
 utimes, ctimes and atimes.
 
 +2. Lockdep (a debugging feature) isn't aware of stacking, and so it
 +   incorrectly complains about locking problems.  The problem boils down to
 +   this: Lockdep considers all objects of a certain type to be in the same
 +   class, for example, all inodes.  Lockdep doesn't like to see a lock held
 +   on two inodes within the same task, and warns that it could lead to a
 +   deadlock.  However, stackable file systems do precisely that: they lock
 +   an upper object, and then a lower object, in a strict order to avoid
 +   locking problems; in addition, Unionfs, as a fan-out file system, may
 +   have to lock several lower inodes.  We are currently looking into Lockdep
 +   to see how to make it aware of stackable file systems.  In the mean time,
 
 meantime
 
 @@ -86,5 +86,12 @@ command:
  
  # mount -t unionfs -o remount,incgen none MOUNTPOINT
  
 +Note that the older way of incrementing the generation number using an
 +ioctl, is no longer supported in Unionfs 2.0.  Ioctls in general are not
 
 2.1?

Thanks.

Jeff.

-- 
Penguin : Linux version 2.4.20-46.9.legacysmp on an i386 machine (2778.72 
BogoMips).
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/32] Unionfs: cache-coherency - dentries

2007-09-03 Thread Josef 'Jeff' Sipek
On Mon, Sep 03, 2007 at 08:52:17AM +0200, Jan Engelhardt wrote:
 
 On Sep 2 2007 22:20, Josef 'Jeff' Sipek wrote:
 @@ -184,10 +183,92 @@ out:
  }
  
  /*
 + * Determine if the lower inode objects have changed from below the unionfs
 + * inode.  Return 1 if changed, 0 otherwise.
 + */
 +int is_newer_lower(const struct dentry *dentry)
 
 Could use bool and true/false as return value.
 
I remember that way back when there was a discussion about the bool type.
What how did that end? Is bool preferred?

 -int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata 
 *nd)
 +int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata 
 *nd,
 + int willwrite)
 
 also looks like a bool (willwrite)

Right.

 -if (!__unionfs_d_revalidate_chain(dentry, NULL)) {
 +if (!__unionfs_d_revalidate_chain(dentry, NULL, 0)) {
 
 (Are there any callers with ,1?)

Indirectly yes. There are callers that pass a value they get. Very large
majority is 0.

Jeff.

-- 
Bad pun of the week: The formula 1 control computer suffered from a race
condition

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/32] VFS: export release_open_intent symbol

2007-09-03 Thread Josef 'Jeff' Sipek
On Mon, Sep 03, 2007 at 09:59:15PM +0530, Satyam Sharma wrote:
 
 
 On Sun, 2 Sep 2007, Josef 'Jeff' Sipek wrote:
  
  diff --git a/fs/namei.c b/fs/namei.c
  index a83160a..b2b7c8e 100644
  --- a/fs/namei.c
  +++ b/fs/namei.c
  @@ -374,6 +374,7 @@ void release_open_intent(struct nameidata *nd)
  else
  fput(nd-intent.open.file);
   }
  +EXPORT_SYMBOL(release_open_intent);
 
 Hmm, why is this being pushed into mainline? This also looks like an
 -mm only patch to me, there are no modular users of release_open_intent()
 in mainline, and the next patch doesn't add one either.

Err...a thinko. Good catch.

Josef 'Jeff' Sipek.

-- 
I abhor a system designed for the user, if that word is a coded pejorative
meaning stupid and unsophisticated.
- Ken Thompson
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] Unionfs: cache-coherency - dentries

2007-09-03 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Utility functions to check if lower dentries/inodes are newer than upper
ones, and purging cached data if lower objects are newer.  Also passed flag
to our d_revalidate_chain, to tell it if the caller may be writing data or
just reading it.

[jsipek: changed purge_inode_data to take a struct inode]
Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |2 +-
 fs/unionfs/dentry.c |  143 ++-
 fs/unionfs/inode.c  |   24 +---
 fs/unionfs/rename.c |4 +-
 fs/unionfs/super.c  |2 +-
 fs/unionfs/union.h  |5 +-
 fs/unionfs/unlink.c |   12 +++-
 fs/unionfs/xattr.c  |8 +-
 8 files changed, 164 insertions(+), 36 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 28cb4e9..0dc7492 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -287,7 +287,7 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 * but not unhashed dentries.
 */
if (!d_deleted(dentry) 
-   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   !__unionfs_d_revalidate_chain(dentry, NULL, willwrite)) {
err = -ESTALE;
goto out_nofree;
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 4a3c479..d937329 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -23,19 +23,18 @@
  * Assume that dentry's info node is locked.
  * Assume that parent(s) are all valid already, but
  * the child may not yet be valid.
- * Returns 1 if valid, 0 otherwise.
+ * Returns true if valid, false otherwise.
  */
-static int __unionfs_d_revalidate_one(struct dentry *dentry,
+static bool __unionfs_d_revalidate_one(struct dentry *dentry,
  struct nameidata *nd)
 {
-   int valid = 1;  /* default is valid (1); invalid is 0. */
+   bool valid = true;  /* default is valid */
struct dentry *lower_dentry;
int bindex, bstart, bend;
int sbgen, dgen;
int positive = 0;
int locked = 0;
int interpose_flag;
-
struct nameidata lowernd; /* TODO: be gentler to the stack */
 
if (nd)
@@ -128,7 +127,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
interpose_flag);
if (result) {
if (IS_ERR(result)) {
-   valid = 0;
+   valid = false;
goto out;
}
/*
@@ -142,7 +141,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
if (positive  UNIONFS_I(dentry-d_inode)-stale) {
make_bad_inode(dentry-d_inode);
d_drop(dentry);
-   valid = 0;
+   valid = false;
goto out;
}
goto out;
@@ -158,12 +157,12 @@ static int __unionfs_d_revalidate_one(struct dentry 
*dentry,
|| !lower_dentry-d_op-d_revalidate)
continue;
if (!lower_dentry-d_op-d_revalidate(lower_dentry,
-  lowernd))
-   valid = 0;
+ lowernd))
+   valid = false;
}
 
if (!dentry-d_inode)
-   valid = 0;
+   valid = false;
 
if (valid) {
/*
@@ -184,12 +183,94 @@ out:
 }
 
 /*
+ * Determine if the lower inode objects have changed from below the unionfs
+ * inode.  Return 1 if changed, 0 otherwise.
+ */
+bool is_newer_lower(const struct dentry *dentry)
+{
+   int bindex;
+   struct inode *inode;
+   struct inode *lower_inode;
+
+   /* ignore if we're called on semi-initialized dentries/inodes */
+   if (!dentry || !UNIONFS_D(dentry))
+   return false;
+   inode = dentry-d_inode;
+   if (!inode || !UNIONFS_I(inode) ||
+   ibstart(inode)  0 || ibend(inode)  0)
+   return false;
+
+   for (bindex = ibstart(inode); bindex = ibend(inode); bindex++) {
+   lower_inode = unionfs_lower_inode_idx(inode, bindex);
+   if (!lower_inode)
+   continue;
+   /*
+* We may want to apply other tests to determine if the
+* lower inode's data has changed, but checking for changed
+* ctime and mtime on the lower inode should be enough.
+*/
+   if (timespec_compare(inode-i_mtime,
+lower_inode-i_mtime)  0) {
+   printk(unionfs: new lower inode mtime 
+  (bindex=%d, name=%s)\n

[GIT PULL -mm] Unionfs/fsstack/eCryptfs updates/cleanups/fixes

2007-09-02 Thread Josef 'Jeff' Sipek
The following is a series of patches related to Unionfs, which include three
small VFS/fsstack patches and one eCryptfs patch; the rest are Unionfs
patches.  The patches here represent several months of work and testing
under various conditions, especially low-memory, SMP, and preemption
situations with an assortment of lower systems: ext2/3/4, xfs, reiserfs,
nfs, jffs2, ramfs, tmpfs, cramfs, and squashfs.

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

As I already mentioned to Andrew, some of these patches should go into
Linus's tree, but the remainder depends on them.

Additionally, as Andrew said earlier today, let's figure out whether or not
Unionfs gets merged.


For Linus:
  VFS: export release_open_intent symbol
  VFS/fsstack: remove 3rd argument to fsstack_copy_attr_all
  VFS/fsstack: cpp endif comments

For Andrew:
  Unionfs: fixed compilation error
  Unionfs: do not use fsstack_copy_attr_all
  Unionfs: copyright corrections and updates
  Unionfs: cpp endif comments
  Unionfs: cache-coherency - update inode times
  Unionfs: cache-coherency - dentries
  Unionfs: cache-coherency - file flush
  Unionfs: cache-coherency and fixes for unionfs_rename
  Unionfs: documentation updates
  Unionfs: copyup updates
  Unionfs: file_revalidate updates
  Unionfs: implement f/async
  Unionfs: minor file_release updates
  Unionfs: interpose updates
  Unionfs: unionfs_ioctl bug fixes
  Unionfs: partial_lookup update
  Unionfs: lower nameidata support
  Unionfs: mmap fixes
  Unionfs: handling lower vfsmount fixes
  Unionfs: mount-time option parsing fix
  Unionfs: remove old nfsro option
  Unionfs: readonly branch test fix
  Unionfs: minor remount fixes
  Unionfs: extended attributes fixes
  Unionfs: use file f_path field
  Unionfs: assorted comment and style updates
  Unionfs: update unionfs version number
  Unionfs: debugging and validation of fan-out invariants
  Unionfs: unionfs_create rewrite


Josef 'Jeff' Sipek, on behalf of the Unionfs team.

[EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/32] Unionfs: minor file_release updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 612207a..1050c49 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -593,8 +593,7 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
struct unionfs_inode_info *inodeinfo;
struct super_block *sb = inode-i_sb;
int bindex, bstart, bend;
-   int fgen;
-   int err;
+   int fgen, err = 0;
 
unionfs_read_lock(sb);
/*
@@ -618,7 +617,7 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
 
if (lower_file) {
fput(lower_file);
-   branchput(inode-i_sb, bindex);
+   branchput(sb, bindex);
}
}
kfree(fileinfo-lower_files);
@@ -640,6 +639,7 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
fileinfo-rdstate = NULL;
}
kfree(fileinfo);
+
 out:
unionfs_read_unlock(sb);
return err;
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/32] Unionfs: handling lower vfsmount fixes

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Properly increase/release lower vfsmounts.
Validate proper use of unionfs mntget/put.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/dentry.c |6 --
 fs/unionfs/inode.c  |   11 +++
 fs/unionfs/lookup.c |   11 ++-
 fs/unionfs/union.h  |   47 +++
 4 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index c7bbeca..0be958f 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -450,9 +450,11 @@ static void unionfs_d_release(struct dentry *dentry)
bend = dbend(dentry);
for (bindex = bstart; bindex = bend; bindex++) {
dput(unionfs_lower_dentry_idx(dentry, bindex));
-   unionfs_mntput(dentry, bindex);
-
unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
+   /* NULL lower mnt is ok if this is a negative dentry */
+   if (!dentry-d_inode  !unionfs_lower_mnt_idx(dentry,bindex))
+   continue;
+   unionfs_mntput(dentry, bindex);
unionfs_set_lower_mnt_idx(dentry, bindex, NULL);
}
/* free private data (unionfs_dentry_info) here */
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index a219a40..d6a79d5 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -222,8 +222,11 @@ out:
dput(wh_dentry);
kfree(name);
 
+   if (!err)
+   unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
unionfs_read_unlock(dentry-d_sb);
+
return err;
 }
 
@@ -563,8 +566,12 @@ out:
d_drop(dentry);
 
kfree(name);
+   if (!err)
+   unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
+
unionfs_read_unlock(dentry-d_sb);
+
return err;
 }
 
@@ -835,8 +842,12 @@ out:
 
kfree(name);
 
+   if (!err)
+   unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
+
unionfs_read_unlock(dentry-d_sb);
+
return err;
 }
 
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 152d421..38ee21f 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -314,24 +314,25 @@ out_negative:
if (lookupmode == INTERPOSE_REVAL) {
if (dentry-d_inode)
UNIONFS_I(dentry-d_inode)-stale = 1;
-
goto out;
}
/* This should only happen if we found a whiteout. */
if (first_dentry_offset == -1) {
first_lower_dentry = lookup_one_len(name, lower_dir_dentry,
-namelen);
+   namelen);
first_dentry_offset = bindex;
if (IS_ERR(first_lower_dentry)) {
err = PTR_ERR(first_lower_dentry);
goto out;
}
-   
-   /* FIXME: the following line needs to be changed to allow
+
+   /*
+* FIXME: the following line needs to be changed to allow
 * mount-point crossing
 */
first_dentry = dentry;
-   first_lower_mnt = unionfs_mntget(dentry, bindex);
+   first_lower_mnt = unionfs_mntget(dentry-d_sb-s_root,
+bindex);
}
unionfs_set_lower_dentry_idx(dentry, first_dentry_offset,
 first_lower_dentry);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 9f3e68a..33c2137 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -459,18 +459,49 @@ static inline void unlock_dir(struct dentry *dir)
 static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
  int bindex)
 {
-   BUG_ON(!dentry || bindex  0);
-
-   return mntget(unionfs_lower_mnt_idx(dentry, bindex));
+   struct vfsmount *mnt;
+
+   if (!dentry) {
+   if (bindex  0)
+   return NULL;
+   if (!dentry  bindex = 0) {
+   return NULL;
+   }
+   }
+   mnt = unionfs_lower_mnt_idx(dentry, bindex);
+   if (!mnt) {
+   if (bindex  0)
+   return NULL;
+   if (!mnt  bindex = 0) {
+   return NULL;
+   }
+   }
+   mnt = mntget(mnt);
+   return mnt;
 }
 
 static inline void unionfs_mntput(struct dentry *dentry, int bindex)
 {
-   if (!dentry)
-   return;
+   struct vfsmount *mnt;
+
+   if (!dentry) {
+   if (bindex  0)
+   return;
+   if (!dentry  bindex = 0) {
+   return;
+   }
+   }
+   mnt

[PATCH 02/32] VFS/fsstack: remove 3rd argument to fsstack_copy_attr_all

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Unionfs needs a special fan-out version of fsstack_copy_attr_all. A
single-level stackable file systems such as eCryptfs can therefore use a
simplified fsstack_copy_attr_all function; remove its 3rd argument, which
was never used by eCryptfs and was only used by Unionfs.

Acked-by: Michael Halcrow [EMAIL PROTECTED]
Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/ecryptfs/dentry.c |2 +-
 fs/ecryptfs/inode.c  |6 +++---
 fs/ecryptfs/main.c   |2 +-
 fs/stack.c   |   13 ++---
 include/linux/fs_stack.h |4 +---
 5 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index cb20b96..a8c1686 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -62,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, 
struct nameidata *nd)
struct inode *lower_inode =
ecryptfs_inode_to_lower(dentry-d_inode);
 
-   fsstack_copy_attr_all(dentry-d_inode, lower_inode, NULL);
+   fsstack_copy_attr_all(dentry-d_inode, lower_inode);
}
 out:
return rc;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 131954b..fc4c6cb 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -601,9 +601,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
lower_new_dir_dentry-d_inode, lower_new_dentry);
if (rc)
goto out_lock;
-   fsstack_copy_attr_all(new_dir, lower_new_dir_dentry-d_inode, NULL);
+   fsstack_copy_attr_all(new_dir, lower_new_dir_dentry-d_inode);
if (new_dir != old_dir)
-   fsstack_copy_attr_all(old_dir, lower_old_dir_dentry-d_inode, 
NULL);
+   fsstack_copy_attr_all(old_dir, lower_old_dir_dentry-d_inode);
 out_lock:
unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
dput(lower_new_dentry-d_parent);
@@ -961,7 +961,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct 
iattr *ia)
}
rc = notify_change(lower_dentry, ia);
 out:
-   fsstack_copy_attr_all(inode, lower_inode, NULL);
+   fsstack_copy_attr_all(inode, lower_inode);
return rc;
 }
 
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index a984972..cb349a4 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -151,7 +151,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct 
dentry *dentry,
d_add(dentry, inode);
else
d_instantiate(dentry, inode);
-   fsstack_copy_attr_all(inode, lower_inode, NULL);
+   fsstack_copy_attr_all(inode, lower_inode);
/* This size will be overwritten for real files w/ headers and
 * other metadata */
fsstack_copy_inode_size(inode, lower_inode);
diff --git a/fs/stack.c b/fs/stack.c
index 4368d4b..a548aac 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -30,8 +30,7 @@ EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
  * copy all attributes; get_nlinks is optional way to override the i_nlink
  * copying
  */
-void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
-  int (*get_nlinks)(struct inode *))
+void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 {
dest-i_mode = src-i_mode;
dest-i_uid = src-i_uid;
@@ -42,14 +41,6 @@ void fsstack_copy_attr_all(struct inode *dest, const struct 
inode *src,
dest-i_ctime = src-i_ctime;
dest-i_blkbits = src-i_blkbits;
dest-i_flags = src-i_flags;
-
-   /*
-* Update the nlinks AFTER updating the above fields, because the
-* get_links callback may depend on them.
-*/
-   if (!get_nlinks)
-   dest-i_nlink = src-i_nlink;
-   else
-   dest-i_nlink = (*get_nlinks)(dest);
+   dest-i_nlink = src-i_nlink;
 }
 EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);
diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index f3cd7f4..6b52faf 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -20,9 +20,7 @@
 #include linux/fs.h
 
 /* externs for fs/stack.c */
-extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
- int (*get_nlinks)(struct inode *));
-
+extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src);
 extern void fsstack_copy_inode_size(struct inode *dst,
const struct inode *src);
 
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/32] Unionfs: minor remount fixes

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 1de41ea..339afab 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -736,7 +736,7 @@ out_no_change:
for (i=dbstart(sb-s_root); i=dbend(sb-s_root); i++) {
struct dentry *lower_dentry =
unionfs_lower_dentry_idx(sb-s_root, i);
-   atomic_inc(lower_dentry-d_inode-i_count);
+   igrab(lower_dentry-d_inode);
new_lower_inodes[i] = lower_dentry-d_inode;
}
/* 2. release reference on all older lower inodes */
@@ -758,11 +758,11 @@ out_no_change:
i = atomic_inc_return(UNIONFS_SB(sb)-generation);
atomic_set(UNIONFS_D(sb-s_root)-generation, i);
atomic_set(UNIONFS_I(sb-s_root-d_inode)-generation, i);
-
-   err = 0;/* reset to success */
-
if (!(*flags  MS_SILENT))
printk(unionfs: new generation number %d\n, i);
+   /* finally, update the root dentry's times */
+   unionfs_copy_attr_times(sb-s_root-d_inode);
+   err = 0;/* reset to success */
 
/*
 * The code above falls through to the next label, and releases the
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/32] Unionfs: fixed compilation error

2007-09-02 Thread Josef 'Jeff' Sipek
From: Andrew Morton [EMAIL PROTECTED]

Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 include/linux/mm.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index d823db0..aee99b6 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -20,6 +20,7 @@ struct anon_vma;
 struct file_ra_state;
 struct user_struct;
 struct writeback_control;
+struct super_block;
 
 #ifndef CONFIG_DISCONTIGMEM  /* Don't use mapnrs, do it properly */
 extern unsigned long max_mapnr;
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/32] Unionfs: cache-coherency - update inode times

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Part of cache-coherency support (as per OLS'07 talk and
Documentation/filesystems/unionfs/concepts.txt): update our inode time if
lower had changed.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/file.c   |7 +--
 fs/unionfs/inode.c  |   11 +++
 fs/unionfs/unlink.c |3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index ad6821c..47b63f3 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -67,17 +67,20 @@ out:
unionfs_read_unlock(file-f_path.dentry-d_sb);
return err;
 }
-static ssize_t unionfs_write(struct file * file, const char __user * buf,
+
+static ssize_t unionfs_write(struct file *file, const char __user *buf,
 size_t count, loff_t *ppos)
 {
int err = 0;
 
unionfs_read_lock(file-f_path.dentry-d_sb);
-
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
 
err = do_sync_write(file, buf, count, ppos);
+   /* update our inode times upon a successful lower write */
+   if (err = 0)
+   unionfs_copy_attr_times(file-f_path.dentry-d_inode);
 
 out:
unionfs_read_unlock(file-f_path.dentry-d_sb);
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 9261bed..66614e3 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -245,6 +245,12 @@ static struct dentry *unionfs_lookup(struct inode *parent,
nd-dentry = path_save.dentry;
nd-mnt = path_save.mnt;
}
+   if (!IS_ERR(ret)) {
+   if (ret)
+   dentry = ret;
+   /* parent times may have changed */
+   unionfs_copy_attr_times(dentry-d_parent-d_inode);
+   }
 
unionfs_read_unlock(dentry-d_sb);
 
@@ -675,8 +681,11 @@ out:
 
kfree(name);
 
+   if (!err)
+   unionfs_copy_attr_times(dentry-d_inode);
unionfs_unlock_dentry(dentry);
unionfs_read_unlock(dentry-d_sb);
+
return err;
 }
 
@@ -1006,6 +1015,8 @@ static int unionfs_permission(struct inode *inode, int 
mask,
break;
}
}
+   /* sync times which may have changed (asynchronously) below */
+   unionfs_copy_attr_times(inode);
 
 out:
return err;
diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c
index 822bffe..7ad19ec 100644
--- a/fs/unionfs/unlink.c
+++ b/fs/unionfs/unlink.c
@@ -41,6 +41,9 @@ static int unionfs_unlink_whiteout(struct inode *dir, struct 
dentry *dentry)
dget(lower_dentry);
if (!(err = is_robranch_super(dentry-d_sb, bindex)))
err = vfs_unlink(lower_dir_dentry-d_inode, lower_dentry);
+   /* if vfs_unlink succeeded, update our inode's times */
+   if (!err)
+   unionfs_copy_attr_times(dentry-d_inode);
dput(lower_dentry);
fsstack_copy_attr_times(dir, lower_dir_dentry-d_inode);
unlock_dir(lower_dir_dentry);
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/32] Unionfs: cache-coherency - dentries

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Utility functions to check if lower dentries/inodes are newer than upper
ones, and purging cached data if lower objects are newer.  Also passed flag
to our d_revalidate_chain, to tell it if the caller may be writing data or
just reading it.

[jsipek: changed purge_inode_data to take a struct inode]
Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |2 +-
 fs/unionfs/dentry.c |  127 --
 fs/unionfs/inode.c  |   24 ++---
 fs/unionfs/rename.c |4 +-
 fs/unionfs/super.c  |2 +-
 fs/unionfs/union.h  |3 +-
 fs/unionfs/unlink.c |   12 +++-
 fs/unionfs/xattr.c  |8 ++--
 8 files changed, 155 insertions(+), 27 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 28cb4e9..0dc7492 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -287,7 +287,7 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 * but not unhashed dentries.
 */
if (!d_deleted(dentry) 
-   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   !__unionfs_d_revalidate_chain(dentry, NULL, willwrite)) {
err = -ESTALE;
goto out_nofree;
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 4a3c479..c7bbeca 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -35,7 +35,6 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
int positive = 0;
int locked = 0;
int interpose_flag;
-
struct nameidata lowernd; /* TODO: be gentler to the stack */
 
if (nd)
@@ -158,7 +157,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
|| !lower_dentry-d_op-d_revalidate)
continue;
if (!lower_dentry-d_op-d_revalidate(lower_dentry,
-  lowernd))
+ lowernd))
valid = 0;
}
 
@@ -184,10 +183,92 @@ out:
 }
 
 /*
+ * Determine if the lower inode objects have changed from below the unionfs
+ * inode.  Return 1 if changed, 0 otherwise.
+ */
+int is_newer_lower(const struct dentry *dentry)
+{
+   int bindex;
+   struct inode *inode;
+   struct inode *lower_inode;
+
+   /* ignore if we're called on semi-initialized dentries/inodes */
+   if (!dentry || !UNIONFS_D(dentry))
+   return 0;
+   inode = dentry-d_inode;
+   if (!inode || !UNIONFS_I(inode) ||
+   ibstart(inode)  0 || ibend(inode)  0)
+   return 0;
+
+   for (bindex = ibstart(inode); bindex = ibend(inode); bindex++) {
+   lower_inode = unionfs_lower_inode_idx(inode, bindex);
+   if (!lower_inode)
+   continue;
+   /*
+* We may want to apply other tests to determine if the
+* lower inode's data has changed, but checking for changed
+* ctime and mtime on the lower inode should be enough.
+*/
+   if (timespec_compare(inode-i_mtime,
+lower_inode-i_mtime)  0) {
+   printk(unionfs: new lower inode mtime 
+  (bindex=%d, name=%s)\n, bindex,
+  dentry-d_name.name);
+   return 1; /* mtime changed! */
+   }
+   if (timespec_compare(inode-i_ctime,
+lower_inode-i_ctime)  0) {
+   printk(unionfs: new lower inode ctime 
+  (bindex=%d, name=%s)\n, bindex,
+  dentry-d_name.name);
+   return 1; /* ctime changed! */
+   }
+   }
+   return 0;   /* default: lower is not newer */
+}
+
+/*
+ * Purge/remove/unmap all date pages of a unionfs inode.  This is called
+ * when the lower inode has changed, and we have to force processes to get
+ * the new data.
+ *
+ * XXX: Our implementation works in that as long as a user process will have
+ * caused Unionfs to be called, directly or indirectly, even to just do
+ * -d_revalidate; then we will have purged the current Unionfs data and the
+ * process will see the new data.  For example, a process that continually
+ * re-reads the same file's data will see the NEW data as soon as the lower
+ * file had changed, upon the next read(2) syscall (even if the file is
+ * still open!)  However, this doesn't work when the process re-reads the
+ * open file's data via mmap(2) (unless the user unmaps/closes the file and
+ * remaps/reopens it).  Once we respond to -readpage(s), then the kernel
+ * maps the page into the process's address space and there doesn't appear
+ * to be a way to force the kernel

[PATCH 20/32] Unionfs: lower nameidata support

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Create and free custom nameidata structures, and pass them to lower file
systems when needed via vfs_create.  (This code will get updated when/if
nameidata is split into an intent structure and a VFS-level only structure.)

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/copyup.c |8 ++-
 fs/unionfs/lookup.c |   58 +++
 fs/unionfs/rename.c |   15 +++-
 fs/unionfs/subr.c   |   14 ++-
 fs/unionfs/union.h  |2 +
 5 files changed, 92 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 9c476cd..4c45790 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -177,19 +177,25 @@ static int __copyup_ndentry(struct dentry 
*old_lower_dentry,
run_sioq(__unionfs_mknod, args);
err = args.err;
} else if (S_ISREG(old_mode)) {
+   struct nameidata nd;
+   err = init_lower_nd(nd, LOOKUP_CREATE);
+   if (err  0)
+   goto out;
+   args.create.nd = nd;
args.create.parent = new_lower_parent_dentry-d_inode;
args.create.dentry = new_lower_dentry;
args.create.mode = old_mode;
-   args.create.nd = NULL;
 
run_sioq(__unionfs_create, args);
err = args.err;
+   release_lower_nd(nd, err);
} else {
printk(KERN_ERR unionfs: unknown inode type %d\n,
   old_mode);
BUG();
}
 
+out:
return err;
 }
 
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index d05daa5..152d421 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -564,3 +564,61 @@ void update_bstart(struct dentry *dentry)
unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
}
 }
+
+
+/*
+ * Initialize a nameidata structure (the intent part) we can pass to a lower
+ * file system.  Returns 0 on success or -error (only -ENOMEM possible).
+ * Inside that nd structure, this function may also return an allocated
+ * struct file (for open intents).  The caller, when done with this nd, must
+ * kfree the intent file (using release_lower_nd).
+ */
+int init_lower_nd(struct nameidata *nd, unsigned int flags)
+{
+   int err = 0;
+#ifdef ALLOC_LOWER_ND_FILE
+   /*
+* XXX: one day we may need to have the lower return an open file
+* for us.  It is not needed in 2.6.23-rc1 for nfs2/nfs3, but may
+* very well be needed for nfs4.
+*/
+   struct file *file;
+#endif /* ALLOC_LOWER_ND_FILE */
+
+   memset(nd, 0, sizeof(struct nameidata));
+
+   switch (flags) {
+   case LOOKUP_CREATE:
+   nd-flags = LOOKUP_CREATE;
+   nd-intent.open.flags = FMODE_READ | FMODE_WRITE | O_CREAT;
+#ifdef ALLOC_LOWER_ND_FILE
+   file = kzalloc(sizeof(struct file), GFP_KERNEL);
+   if (!file) {
+   err = -ENOMEM;
+   break; /* exit switch statement and thus return */
+   }
+   nd-intent.open.file = file;
+#endif /* ALLOC_LOWER_ND_FILE */
+   break;
+   default:
+   /*
+* We should never get here, for now.
+* We can add new cases here later on.
+*/
+   BUG();
+   break;
+   }
+
+   return err;
+}
+
+void release_lower_nd(struct nameidata *nd, int err)
+{
+   if (!nd-intent.open.file)
+   return;
+   if (!err)
+   release_open_intent(nd);
+#ifdef ALLOC_LOWER_ND_FILE
+   kfree(nd-intent.open.file);
+#endif /* ALLOC_LOWER_ND_FILE */
+}
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index acf829a..a02d678 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -256,10 +256,20 @@ static int do_unionfs_rename(struct inode *old_dir,
 */
if ((old_bstart != old_bend) || (do_copyup != -1)) {
struct dentry *lower_parent;
-   BUG_ON(!wh_old || wh_old-d_inode || bwh_old  0);
+   struct nameidata nd;
+   if (!wh_old || wh_old-d_inode || bwh_old  0) {
+   printk(KERN_ERR unionfs: rename error 
+  (wh_old=%p/%p bwh_old=%d)\n, wh_old,
+  (wh_old ? wh_old-d_inode : NULL), bwh_old);
+   err = -EIO;
+   goto out;
+   }
+   err = init_lower_nd(nd, LOOKUP_CREATE);
+   if (err  0)
+   goto out;
lower_parent = lock_parent(wh_old);
local_err = vfs_create(lower_parent-d_inode, wh_old, S_IRUGO,
-  NULL);
+  nd);
unlock_dir(lower_parent

[PATCH 06/32] Unionfs: copyright corrections and updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/mmap.c |2 +-
 fs/unionfs/sioq.c |   13 +++--
 fs/unionfs/sioq.h |   13 +++--
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index e03ca00..969fd16 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -10,7 +10,7 @@
  * Copyright (c) 2003  Puja Gupta
  * Copyright (c) 2003  Harikesavan Krishnan
  * Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New 
York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index 575f08d..2a8c88e 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -1,10 +1,11 @@
 /*
- * Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
- * Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of SUNY
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006  Charles P. Wright
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006  Junjiro Okajima
+ * Copyright (c) 2006  David P. Quigley
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 6d0d01f..bedd7af 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -1,10 +1,11 @@
 /*
- * Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
- * Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of SUNY
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006  Charles P. Wright
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006  Junjiro Okajima
+ * Copyright (c) 2006  David P. Quigley
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/32] Unionfs: readonly branch test fix

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Bug fix to test if a lower branch is readonly, even when given negative
dentries.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/union.h |   19 ++-
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 33c2137..26d886e 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -396,14 +396,23 @@ static inline int is_robranch_super(const struct 
super_block *sb, int index)
 /* Is this file on a read-only branch? */
 static inline int is_robranch_idx(const struct dentry *dentry, int index)
 {
-   int err = 0;
+   struct super_block *lower_sb;
 
BUG_ON(index  0);
 
-   if ((!(branchperms(dentry-d_sb, index)  MAY_WRITE)) ||
-   IS_RDONLY(unionfs_lower_dentry_idx(dentry, index)-d_inode))
-   err = -EROFS;
-   return err;
+   if (!(branchperms(dentry-d_sb, index)  MAY_WRITE))
+   return -EROFS;
+
+   lower_sb = unionfs_lower_super_idx(dentry-d_sb, index);
+   BUG_ON(lower_sb == NULL);
+   /*
+* test sb flags directly, not IS_RDONLY(lower_inode) because the
+* lower_dentry could be a negative.
+*/
+   if (lower_sb-s_flags  MS_RDONLY)
+   return -EROFS;
+
+   return 0;
 }
 
 static inline int is_robranch(const struct dentry *dentry)
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/32] Unionfs: debugging and validation of fan-out invariants

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Introduce debugging functionality, Makefile support to turn it on at compile
time, and hooks in the main code to verify fan-out invariants.  This is very
similar to how other file systems provide debugging functionality.  This
code has been very useful in detecting and fixing problems, especially when
stacking on top of assorted file systems.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/Kconfig  |6 +
 fs/unionfs/Makefile |2 +
 fs/unionfs/commonfops.c |   17 ++
 fs/unionfs/copyup.c |2 +
 fs/unionfs/debug.c  |  502 +++
 fs/unionfs/dentry.c |4 +
 fs/unionfs/file.c   |   19 ++-
 fs/unionfs/inode.c  |   22 ++
 fs/unionfs/mmap.c   |5 +
 fs/unionfs/rename.c |4 +
 fs/unionfs/super.c  |3 +
 fs/unionfs/union.h  |  105 +++---
 fs/unionfs/unlink.c |6 +
 fs/unionfs/xattr.c  |4 +
 14 files changed, 668 insertions(+), 33 deletions(-)
 create mode 100644 fs/unionfs/debug.c

diff --git a/fs/Kconfig b/fs/Kconfig
index d53d8ca..0c58d02 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1063,6 +1063,12 @@ config UNION_FS_XATTR
 
  If unsure, say N.
 
+config UNION_FS_DEBUG
+   bool Debug Unionfs
+   depends on UNION_FS
+   help
+ If you say Y here, you can turn on debugging output from Unionfs.
+
 endmenu
 
 menu Miscellaneous filesystems
diff --git a/fs/unionfs/Makefile b/fs/unionfs/Makefile
index 78be3e7..38fed90 100644
--- a/fs/unionfs/Makefile
+++ b/fs/unionfs/Makefile
@@ -5,3 +5,5 @@ unionfs-y := subr.o dentry.o file.o inode.o main.o super.o \
lookup.o commonfops.o dirfops.o sioq.o mmap.o
 
 unionfs-$(CONFIG_UNION_FS_XATTR) += xattr.o
+
+unionfs-$(CONFIG_UNION_FS_DEBUG) += debug.o
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 341b6f2..724128d 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -91,6 +91,8 @@ retry:
unlock_dir(lower_dir_dentry);
 
 out:
+   if (!err)
+   unionfs_check_dentry(dentry);
return err;
 }
 
@@ -247,6 +249,8 @@ static int do_delayed_copyup(struct file *file)
 
BUG_ON(!S_ISREG(dentry-d_inode-i_mode));
 
+   unionfs_check_file(file);
+   unionfs_check_dentry(dentry);
for (bindex = bstart - 1; bindex = 0; bindex--) {
if (!d_deleted(dentry))
err = copyup_file(parent_inode, file, bstart,
@@ -286,6 +290,8 @@ static int do_delayed_copyup(struct file *file)
ibend(dentry-d_inode) = ibstart(dentry-d_inode);
 
 out:
+   unionfs_check_file(file);
+   unionfs_check_dentry(dentry);
return err;
 }
 
@@ -399,6 +405,8 @@ out:
kfree(UNIONFS_F(file)-saved_branch_ids);
}
 out_nofree:
+   if (!err)
+   unionfs_check_file(file);
unionfs_unlock_dentry(dentry);
return err;
 }
@@ -576,6 +584,11 @@ out:
}
 out_nofree:
unionfs_read_unlock(inode-i_sb);
+   unionfs_check_inode(inode);
+   if (!err) {
+   unionfs_check_file(file);
+   unionfs_check_dentry(file-f_path.dentry-d_parent);
+   }
return err;
 }
 
@@ -601,6 +614,7 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
 */
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
+   unionfs_check_file(file);
fileinfo = UNIONFS_F(file);
BUG_ON(file-f_path.dentry-d_inode != inode);
inodeinfo = UNIONFS_I(inode);
@@ -764,6 +778,7 @@ long unionfs_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
 
 out:
unionfs_read_unlock(file-f_path.dentry-d_sb);
+   unionfs_check_file(file);
return err;
 }
 
@@ -778,6 +793,7 @@ int unionfs_flush(struct file *file, fl_owner_t id)
 
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
+   unionfs_check_file(file);
 
if (!atomic_dec_and_test(UNIONFS_I(dentry-d_inode)-totalopens))
goto out;
@@ -814,5 +830,6 @@ out_lock:
unionfs_unlock_dentry(dentry);
 out:
unionfs_read_unlock(dentry-d_sb);
+   unionfs_check_file(file);
return err;
 }
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 36f751e..23ac4c8 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -532,6 +532,8 @@ out_free:
unionfs_postcopyup_setmnt(dentry);
/* sync inode times from copied-up inode to our inode */
unionfs_copy_attr_times(dentry-d_inode);
+   unionfs_check_inode(dir);
+   unionfs_check_dentry(dentry);
 out:
return err;
 }
diff --git a/fs/unionfs/debug.c b/fs/unionfs/debug.c
new file mode 100644
index 000..f678534
--- /dev/null
+++ b/fs/unionfs/debug.c
@@ -0,0 +1,502 @@
+/*
+ * Copyright (c) 2003-2007 Erez Zadok
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2003-2007

[PATCH 24/32] Unionfs: remove old nfsro option

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Ensure that a branch set as 'ro' behaves like a real readonly mounted lower
file system.  This allows us to remove the old 'nfsro' option.  Now unionfs
handles even an readonly exported NFS file system, which was mounted on the
client in readwrite mode.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c   |   48 ++---
 include/linux/union_fs.h |3 --
 2 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index d6a79d5..4574fbe 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -948,47 +948,44 @@ static void unionfs_put_link(struct dentry *dentry, 
struct nameidata *nd,
  * Basically copied from the kernel vfs permission(), but we've changed
  * the following:
  *   (1) the IS_RDONLY check is skipped, and
- *   (2) if you set the mount option `mode=nfsro', we assume that -EACCES
- *   means that the export is read-only and we should check standard Unix
- *   permissions.  This means that NFS ACL checks (or other advanced
- *   permission features) are bypassed. Note however, that we do call
- *   security_inode_permission, and therefore security inside SELinux, etc.
- *   are performed.
+ *   (2) We return 0 (success) if the non-leftmost branch is mounted
+ *   readonly, to allow copyup to work.
+ *   (3) we do call security_inode_permission, and therefore security inside
+ *   SELinux, etc. are performed.
  */
-static int inode_permission(struct inode *inode, int mask,
+static int inode_permission(struct super_block *sb, struct inode *inode, int 
mask,
struct nameidata *nd, int bindex)
 {
int retval, submask;
 
if (mask  MAY_WRITE) {
+   umode_t mode = inode-i_mode;
/* The first branch is allowed to be really readonly. */
-   if (bindex == 0) {
-   umode_t mode = inode-i_mode;
-   if (IS_RDONLY(inode) 
-   (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
-   return -EROFS;
-   }
+   if (bindex == 0 
+   IS_RDONLY(inode) 
+   (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
+   return -EROFS;
/*
 * Nobody gets write access to an immutable file.
 */
if (IS_IMMUTABLE(inode))
return -EACCES;
+   /*
+* For all other branches than the first one, we ignore
+* EROFS or if the branch is mounted as readonly, to let
+* copyup take place.
+*/
+   if (bindex  0 
+   is_robranch_super(sb, bindex) 
+   (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
+   return 0;
}
 
/* Ordinary permission routines do not understand MAY_APPEND. */
submask = mask  ~MAY_APPEND;
-   if (inode-i_op  inode-i_op-permission) {
+   if (inode-i_op  inode-i_op-permission)
retval = inode-i_op-permission(inode, submask, nd);
-   if ((retval == -EACCES)  (submask  MAY_WRITE) 
-   (!strcmp(nfs, (inode)-i_sb-s_type-name)) 
-   (nd)  (nd-mnt)  (nd-mnt-mnt_sb)) {
-   int perms;
-   perms = branchperms(nd-mnt-mnt_sb, bindex);
-   if (perms  MAY_NFSRO)
-   retval = generic_permission(inode, submask,
-   NULL);
-   }
-   } else
+   else
retval = generic_permission(inode, submask, NULL);
 
if (retval  retval != -EROFS) /* ignore EROFS */
@@ -1046,7 +1043,8 @@ static int unionfs_permission(struct inode *inode, int 
mask,
 * We use our own special version of permission, such that
 * only the first branch returns -EROFS.
 */
-   err = inode_permission(lower_inode, mask, nd, bindex);
+   err = inode_permission(inode-i_sb, lower_inode, mask, nd,
+  bindex);
 
/*
 * The permissions are an intersection of the overall directory
diff --git a/include/linux/union_fs.h b/include/linux/union_fs.h
index 223ccab..9bc4e3b 100644
--- a/include/linux/union_fs.h
+++ b/include/linux/union_fs.h
@@ -22,8 +22,5 @@
 /* We don't support normal remount, but unionctl uses it. */
 # define UNIONFS_REMOUNT_MAGIC 0x4a5a4380
 
-/* should be at least LAST_USED_UNIONFS_PERMISSION1 */
-#define MAY_NFSRO  16
-
 #endif /* _LINUX_UNIONFS_H */
 
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body

[PATCH 28/32] Unionfs: use file f_path field

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Start using file-f_path.dentry instead of file-f_dentry

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   42 --
 fs/unionfs/dirfops.c|6 +++---
 fs/unionfs/mmap.c   |5 ++---
 fs/unionfs/rdstate.c|2 +-
 4 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index eee68b8..341b6f2 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -158,7 +158,7 @@ static int open_all_files(struct file *file)
int bindex, bstart, bend, err = 0;
struct file *lower_file;
struct dentry *lower_dentry;
-   struct dentry *dentry = file-f_dentry;
+   struct dentry *dentry = file-f_path.dentry;
struct super_block *sb = dentry-d_sb;
 
bstart = dbstart(dentry);
@@ -193,8 +193,7 @@ static int open_highest_file(struct file *file, int 
willwrite)
int bindex, bstart, bend, err = 0;
struct file *lower_file;
struct dentry *lower_dentry;
-
-   struct dentry *dentry = file-f_dentry;
+   struct dentry *dentry = file-f_path.dentry;
struct inode *parent_inode = dentry-d_parent-d_inode;
struct super_block *sb = dentry-d_sb;
size_t inode_size = dentry-d_inode-i_size;
@@ -302,10 +301,9 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
int sbgen, fgen, dgen;
int bstart, bend;
int size;
-
int err = 0;
 
-   dentry = file-f_dentry;
+   dentry = file-f_path.dentry;
unionfs_lock_dentry(dentry);
sb = dentry-d_sb;
 
@@ -412,20 +410,20 @@ static int __open_dir(struct inode *inode, struct file 
*file)
struct file *lower_file;
int bindex, bstart, bend;
 
-   bstart = fbstart(file) = dbstart(file-f_dentry);
-   bend = fbend(file) = dbend(file-f_dentry);
+   bstart = fbstart(file) = dbstart(file-f_path.dentry);
+   bend = fbend(file) = dbend(file-f_path.dentry);
 
for (bindex = bstart; bindex = bend; bindex++) {
lower_dentry =
-   unionfs_lower_dentry_idx(file-f_dentry, bindex);
+   unionfs_lower_dentry_idx(file-f_path.dentry, bindex);
if (!lower_dentry)
continue;
 
dget(lower_dentry);
-   unionfs_mntget(file-f_dentry, bindex);
+   unionfs_mntget(file-f_path.dentry, bindex);
lower_file = dentry_open(lower_dentry,
-unionfs_lower_mnt_idx(file-f_dentry,
-   bindex),
+
unionfs_lower_mnt_idx(file-f_path.dentry,
+  bindex),
 file-f_flags);
if (IS_ERR(lower_file))
return PTR_ERR(lower_file);
@@ -450,17 +448,17 @@ static int __open_file(struct inode *inode, struct file 
*file)
int lower_flags;
int bindex, bstart, bend;
 
-   lower_dentry = unionfs_lower_dentry(file-f_dentry);
+   lower_dentry = unionfs_lower_dentry(file-f_path.dentry);
lower_flags = file-f_flags;
 
-   bstart = fbstart(file) = dbstart(file-f_dentry);
-   bend = fbend(file) = dbend(file-f_dentry);
+   bstart = fbstart(file) = dbstart(file-f_path.dentry);
+   bend = fbend(file) = dbend(file-f_path.dentry);
 
/*
 * check for the permission for lower file.  If the error is
 * COPYUP_ERR, copyup the file.
 */
-   if (lower_dentry-d_inode  is_robranch(file-f_dentry)) {
+   if (lower_dentry-d_inode  is_robranch(file-f_path.dentry)) {
/*
 * if the open will change the file, copy it up otherwise
 * defer it.
@@ -472,7 +470,7 @@ static int __open_file(struct inode *inode, struct file 
*file)
/* copyup the file */
for (bindex = bstart - 1; bindex = 0; bindex--) {
err = copyup_file(
-   file-f_dentry-d_parent-d_inode,
+   file-f_path.dentry-d_parent-d_inode,
file, bstart, bindex, size);
if (!err)
break;
@@ -488,10 +486,10 @@ static int __open_file(struct inode *inode, struct file 
*file)
 * dentry_open will decrement mnt refcnt if err.
 * otherwise fput() will do an mntput() for us upon file close.
 */
-   unionfs_mntget(file-f_dentry, bstart);
+   unionfs_mntget(file-f_path.dentry, bstart);
lower_file =
dentry_open(lower_dentry,
-   unionfs_lower_mnt_idx

[PATCH 13/32] Unionfs: copyup updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Fixes, updates, and better documentation for the file-copyup functionality.
Include two additional utility functions useful for copyup code callers.
Parent directory copyup updates: create_parents now takes a string name
instead of the whole dentry.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |  135 +++
 fs/unionfs/copyup.c |  348 +++---
 fs/unionfs/inode.c  |   33 --
 fs/unionfs/rename.c |   26 +++--
 fs/unionfs/subr.c   |4 +-
 fs/unionfs/union.h  |   11 +-
 fs/unionfs/unlink.c |2 +
 7 files changed, 338 insertions(+), 221 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index edb52c0..64bd0bd 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -31,7 +31,6 @@ static int copyup_deleted_file(struct file *file, struct 
dentry *dentry,
const int countersize = sizeof(counter) * 2;
const int nlen = sizeof(.unionfs) + i_inosize + countersize - 1;
char name[nlen + 1];
-
int err;
struct dentry *tmp_dentry = NULL;
struct dentry *lower_dentry;
@@ -42,7 +41,6 @@ static int copyup_deleted_file(struct file *file, struct 
dentry *dentry,
sprintf(name, .unionfs%*.*lx,
i_inosize, i_inosize, lower_dentry-d_inode-i_ino);
 
-retry:
/*
 * Loop, looking for an unused temp name to copyup to.
 *
@@ -52,6 +50,7 @@ retry:
 * the name exists in the dest branch, but it'd be nice to catch it
 * sooner than later.
 */
+retry:
tmp_dentry = NULL;
do {
char *suffix = name + nlen - countersize;
@@ -73,14 +72,20 @@ retry:
dput(tmp_dentry);
 
err = copyup_named_file(dentry-d_parent-d_inode, file, name, bstart,
-   bindex, file-f_dentry-d_inode-i_size);
-   if (err == -EEXIST)
-   goto retry;
-   else if (err)
+   bindex, file-f_path.dentry-d_inode-i_size);
+   if (err) {
+   if (err == -EEXIST)
+   goto retry;
goto out;
+   }
 
/* bring it to the same state as an unlinked file */
lower_dentry = unionfs_lower_dentry_idx(dentry, dbstart(dentry));
+   if (!unionfs_lower_inode_idx(dentry-d_inode, bindex)) {
+   atomic_inc(lower_dentry-d_inode-i_count);
+   unionfs_set_lower_inode_idx(dentry-d_inode, bindex,
+   lower_dentry-d_inode);
+   }
lower_dir_dentry = lock_parent(lower_dentry);
err = vfs_unlink(lower_dir_dentry-d_inode, lower_dentry);
unlock_dir(lower_dir_dentry);
@@ -96,48 +101,52 @@ out:
 static void cleanup_file(struct file *file)
 {
int bindex, bstart, bend;
-   struct file **lf;
-   struct super_block *sb = file-f_dentry-d_sb;
+   struct file **lower_files;
+   struct file *lower_file;
+   struct super_block *sb = file-f_path.dentry-d_sb;
 
-   lf = UNIONFS_F(file)-lower_files;
+   lower_files = UNIONFS_F(file)-lower_files;
bstart = fbstart(file);
bend = fbend(file);
 
for (bindex = bstart; bindex = bend; bindex++) {
-   if (unionfs_lower_file_idx(file, bindex)) {
-   /*
-* Find new index of matching branch with an open
-* file, since branches could have been added or
-* deleted causing the one with open files to shift.
-*/
-   int i;  /* holds (possibly) updated branch index */
-   int old_bid;
-
-   old_bid = UNIONFS_F(file)-saved_branch_ids[bindex];
-   i = branch_id_to_idx(sb, old_bid);
-   if (i  0)
-   printk(KERN_ERR unionfs: no superblock for 
-  file %p\n, file);
-   else {
-   /* decrement count of open files */
-   branchput(sb, i);
-   /*
-* fput will perform an mntput for us on the
-* correct branch.  Although we're using the
-* file's old branch configuration, bindex,
-* which is the old index, correctly points
-* to the right branch in the file's branch
-* list.  In other words, we're going to
-* mntput the correct branch even if
-* branches have been added/removed.
-*/
-   fput(unionfs_lower_file_idx

[PATCH 07/32] Unionfs: cpp endif comments

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Add comments to #endif's to help clarify code.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/copyup.c |2 +-
 fs/unionfs/inode.c  |4 ++--
 fs/unionfs/sioq.h   |2 +-
 fs/unionfs/union.h  |2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index cc7a816..410ce07 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -433,7 +433,7 @@ static int copyup_named_dentry(struct inode *dir, struct 
dentry *dentry,
/* Selinux uses extended attributes for permissions. */
if ((err = copyup_xattrs(old_lower_dentry, new_lower_dentry)))
goto out_unlink;
-#endif
+#endif /* CONFIG_UNION_FS_XATTR */
 
/* do not allow files getting deleted to be re-interposed */
if (!d_deleted(dentry))
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index cbbde6f..9261bed 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -1122,7 +1122,7 @@ struct inode_operations unionfs_dir_iops = {
.getxattr   = unionfs_getxattr,
.removexattr= unionfs_removexattr,
.listxattr  = unionfs_listxattr,
-#endif
+#endif /* CONFIG_UNION_FS_XATTR */
 };
 
 struct inode_operations unionfs_main_iops = {
@@ -1133,5 +1133,5 @@ struct inode_operations unionfs_main_iops = {
.getxattr   = unionfs_getxattr,
.removexattr= unionfs_removexattr,
.listxattr  = unionfs_listxattr,
-#endif
+#endif /* CONFIG_UNION_FS_XATTR */
 };
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index bedd7af..afb71ee 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -89,4 +89,4 @@ extern void __unionfs_unlink(struct work_struct *work);
 extern void __delete_whiteouts(struct work_struct *work);
 extern void __is_opaque_dir(struct work_struct *work);
 
-#endif /* _SIOQ_H */
+#endif /* not _SIOQ_H */
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 2a8f763..b7e5a93 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -419,7 +419,7 @@ static inline int is_robranch(const struct dentry *dentry)
 
 #ifndef DEFAULT_POLLMASK
 #define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM)
-#endif
+#endif /* not DEFAULT_POLLMASK */
 
 /*
  * EXTERNALS:
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/32] Unionfs: file_revalidate updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Correctly revalidate a file and account for lower mnts, even when branches
are updated or inserted.  Better info upon file copyup.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   25 +
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 64bd0bd..612207a 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -333,6 +333,9 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 */
if (!d_deleted(dentry) 
(sbgen  fgen || dbstart(dentry) != fbstart(file))) {
+   /* save orig branch ID */
+   int orig_brid = 
UNIONFS_F(file)-saved_branch_ids[fbstart(file)];
+
/* First we throw out the existing files. */
cleanup_file(file);
 
@@ -359,22 +362,36 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
if (err)
goto out;
} else {
+   int new_brid;
/* We only open the highest priority branch. */
err = open_highest_file(file, willwrite);
if (err)
goto out;
+   new_brid = UNIONFS_F(file)-
+ saved_branch_ids[fbstart(file)];
+   if (new_brid != orig_brid  sbgen  fgen) {
+   /*
+* If we re-opened the file on a different
+* branch than the original one, and this
+* was due to a new branch inserted, then
+* update the mnt counts of the old and new
+* branches accordingly.
+*/
+   unionfs_mntget(dentry, bstart);
+   unionfs_mntput(sb-s_root,
+  branch_id_to_idx(sb, orig_brid));
+   }
}
atomic_set(UNIONFS_F(file)-generation,
-  atomic_read(UNIONFS_I(dentry-d_inode)-
-  generation));
+  
atomic_read(UNIONFS_I(dentry-d_inode)-generation));
}
 
/* Copyup on the first write to a file on a readonly branch. */
if (willwrite  IS_WRITE_FLAG(file-f_flags) 
!IS_WRITE_FLAG(unionfs_lower_file(file)-f_flags) 
is_robranch(dentry)) {
-   printk(KERN_DEBUG unionfs: Doing delayed copyup of a 
-  read-write file on a read-only branch.\n);
+   printk(KERN_DEBUG unionfs: do delay copyup of \%s\\n,
+  dentry-d_name.name);
err = do_delayed_copyup(file);
}
 
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/32] Unionfs: mount-time option parsing fix

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/main.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index bc5c105..ce08d96 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -337,8 +337,12 @@ static int parse_dirs_option(struct super_block *sb, 
struct unionfs_dentry_info
int perms;
char *mode = strchr(name, '=');
 
-   if (!name || !*name)
+   if (!name)
continue;
+   if (!*name) {   /* bad use of ':' (extra colons) */
+   err = -EINVAL;
+   goto out;
+   }
 
branches++;
 
@@ -404,10 +408,9 @@ static int parse_dirs_option(struct super_block *sb, 
struct unionfs_dentry_info
 * branch-overlapping test.
 */
for (i = 0; i  branches; i++) {
+   dent1 = lower_root_info-lower_paths[i].dentry;
for (j = i + 1; j  branches; j++) {
-   dent1 = lower_root_info-lower_paths[i].dentry;
dent2 = lower_root_info-lower_paths[j].dentry;
-
if (is_branch_overlap(dent1, dent2)) {
printk(KERN_WARNING unionfs: branches %d and 
   %d overlap\n, i, j);
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/32] Unionfs: unionfs_ioctl bug fixes

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Properly update lower objects, and release lower mnts upon ioctl success or
failure.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   25 +++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 1050c49..eee68b8 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -684,12 +684,15 @@ static int unionfs_ioctl_queryfile(struct file *file, 
unsigned int cmd,
 {
int err = 0;
fd_set branchlist;
-
int bstart = 0, bend = 0, bindex = 0;
+   int orig_bstart, orig_bend;
struct dentry *dentry, *lower_dentry;
+   struct vfsmount *mnt;
 
-   dentry = file-f_dentry;
+   dentry = file-f_path.dentry;
unionfs_lock_dentry(dentry);
+   orig_bstart = dbstart(dentry);
+   orig_bend = dbend(dentry);
if ((err = unionfs_partial_lookup(dentry)))
goto out;
bstart = dbstart(dentry);
@@ -703,7 +706,25 @@ static int unionfs_ioctl_queryfile(struct file *file, 
unsigned int cmd,
continue;
if (lower_dentry-d_inode)
FD_SET(bindex, branchlist);
+   /* purge any lower objects after partial_lookup */
+   if (bindex  orig_bstart || bindex  orig_bend) {
+   dput(lower_dentry);
+   unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
+   iput(unionfs_lower_inode_idx(dentry-d_inode, bindex));
+   unionfs_set_lower_inode_idx(dentry-d_inode, bindex,
+   NULL);
+   mnt = unionfs_lower_mnt_idx(dentry, bindex);
+   if (!mnt)
+   continue;
+   unionfs_mntput(dentry, bindex);
+   unionfs_set_lower_mnt_idx(dentry, bindex, NULL);
+   }
}
+   /* restore original dentry's offsets */
+   set_dbstart(dentry, orig_bstart);
+   set_dbend(dentry, orig_bend);
+   ibstart(dentry-d_inode) = orig_bstart;
+   ibend(dentry-d_inode) = orig_bend;
 
err = copy_to_user((void __user *)arg, branchlist, sizeof(fd_set));
if (err)
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/32] Unionfs: implement f/async

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Unionfs needs its own fsync and fasync instead of calling the generic
file_fsync, because it may have to sync multiple writable lower branches
(not just one).  This also allows Unionfs to compile with CONFIG_BLOCK=n.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/dirfops.c |2 +
 fs/unionfs/file.c|   91 +-
 fs/unionfs/union.h   |3 ++
 3 files changed, 95 insertions(+), 1 deletions(-)

diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 8503411..0e93bd7 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -273,4 +273,6 @@ struct file_operations unionfs_dir_fops = {
.open   = unionfs_open,
.release= unionfs_file_release,
.flush  = unionfs_flush,
+   .fsync  = unionfs_fsync,
+   .fasync = unionfs_fasync,
 };
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 47b63f3..0555b6c 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -135,6 +135,94 @@ out:
return err;
 }
 
+int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
+{
+   int bindex, bstart, bend;
+   struct file *lower_file;
+   struct dentry *lower_dentry;
+   struct inode *lower_inode, *inode;
+   int err = -EINVAL;
+
+   unionfs_read_lock(file-f_path.dentry-d_sb);
+   if ((err = unionfs_file_revalidate(file, 1)))
+   goto out;
+
+   bstart = fbstart(file);
+   bend = fbend(file);
+   if (bstart  0 || bend  0)
+   goto out;
+
+   inode = dentry-d_inode;
+   if (!inode) {
+   printk(KERN_ERR
+  unionfs: null lower inode in unionfs_fsync\n);
+   goto out;
+   }
+   for (bindex = bstart; bindex = bend; bindex++) {
+   lower_inode = unionfs_lower_inode_idx(inode, bindex);
+   if (!lower_inode || !lower_inode-i_fop-fsync)
+   continue;
+   lower_file = unionfs_lower_file_idx(file, bindex);
+   lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
+   mutex_lock(lower_inode-i_mutex);
+   err = lower_inode-i_fop-fsync(lower_file,
+   lower_dentry,
+   datasync);
+   mutex_unlock(lower_inode-i_mutex);
+   if (err)
+   goto out;
+   }
+
+   unionfs_copy_attr_times(inode);
+
+out:
+   unionfs_read_unlock(file-f_path.dentry-d_sb);
+   return err;
+}
+
+int unionfs_fasync(int fd, struct file *file, int flag)
+{
+   int bindex, bstart, bend;
+   struct file *lower_file;
+   struct dentry *dentry;
+   struct inode *lower_inode, *inode;
+   int err = 0;
+
+   unionfs_read_lock(file-f_path.dentry-d_sb);
+   if ((err = unionfs_file_revalidate(file, 1)))
+   goto out;
+
+   bstart = fbstart(file);
+   bend = fbend(file);
+   if (bstart  0 || bend  0)
+   goto out;
+
+   dentry = file-f_path.dentry;
+   inode = dentry-d_inode;
+   if (!inode) {
+   printk(KERN_ERR
+  unionfs: null lower inode in unionfs_fasync\n);
+   goto out;
+   }
+   for (bindex = bstart; bindex = bend; bindex++) {
+   lower_inode = unionfs_lower_inode_idx(inode, bindex);
+   if (!lower_inode || !lower_inode-i_fop-fasync)
+   continue;
+   lower_file = unionfs_lower_file_idx(file, bindex);
+   mutex_lock(lower_inode-i_mutex);
+   err = lower_inode-i_fop-fasync(fd, lower_file, flag);
+   mutex_unlock(lower_inode-i_mutex);
+   if (err)
+   goto out;
+   }
+
+   unionfs_copy_attr_times(inode);
+
+out:
+   unionfs_read_unlock(file-f_path.dentry-d_sb);
+   return err;
+}
+
 struct file_operations unionfs_main_fops = {
.llseek = generic_file_llseek,
.read   = unionfs_read,
@@ -147,6 +235,7 @@ struct file_operations unionfs_main_fops = {
.open   = unionfs_open,
.flush  = unionfs_flush,
.release= unionfs_file_release,
-   .fsync  = file_fsync,
+   .fsync  = unionfs_fsync,
+   .fasync = unionfs_fasync,
.splice_read= generic_file_splice_read,
 };
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index f8a9cd2..ec33155 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -312,6 +312,9 @@ extern int unionfs_file_release(struct inode *inode, struct 
file *file);
 extern int unionfs_flush(struct file *file, fl_owner_t id);
 extern long unionfs_ioctl(struct file *file, unsigned int cmd,
  unsigned long arg);
+extern int unionfs_fsync(struct

[PATCH 27/32] Unionfs: extended attributes fixes

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/copyup.c |   43 +++
 fs/unionfs/union.h  |6 --
 fs/unionfs/xattr.c  |   16 ++--
 3 files changed, 37 insertions(+), 28 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 4c45790..36f751e 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -32,27 +32,39 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
ssize_t list_size = -1;
char *name_list = NULL;
char *attr_value = NULL;
-   char *name_list_orig = NULL;
+   char *name_list_buf = NULL;
 
+   /* query the actual size of the xattr list */
list_size = vfs_listxattr(old_lower_dentry, NULL, 0);
-
if (list_size = 0) {
err = list_size;
goto out;
}
 
+   /* allocate space for the actual list */
name_list = unionfs_xattr_alloc(list_size + 1, XATTR_LIST_MAX);
if (!name_list || IS_ERR(name_list)) {
err = PTR_ERR(name_list);
goto out;
}
+
+   name_list_buf = name_list; /* save for kfree at end */
+
+   /* now get the actual xattr list of the source file */
list_size = vfs_listxattr(old_lower_dentry, name_list, list_size);
+   if (list_size = 0) {
+   err = list_size;
+   goto out;
+   }
+
+   /* allocate space to hold each xattr's value */
attr_value = unionfs_xattr_alloc(XATTR_SIZE_MAX, XATTR_SIZE_MAX);
if (!attr_value || IS_ERR(attr_value)) {
err = PTR_ERR(name_list);
goto out;
}
-   name_list_orig = name_list;
+
+   /* in a loop, get and set each xattr from src to dst file */
while (*name_list) {
ssize_t size;
 
@@ -65,7 +77,6 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
err = size;
goto out;
}
-
if (size  XATTR_SIZE_MAX) {
err = -E2BIG;
goto out;
@@ -73,19 +84,27 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
/* Don't lock here since vfs_setxattr does it for us. */
err = vfs_setxattr(new_lower_dentry, name_list, attr_value,
   size, 0);
-
+   /*
+* Selinux depends on security.* xattrs, so to maintain
+* the security of copied-up files, if Selinux is active,
+* then we must copy these xattrs as well.  So we need to
+* temporarily get FOWNER privileges.
+* XXX: move entire copyup code to SIOQ.
+*/
+   if (err == -EPERM  !capable(CAP_FOWNER)) {
+   cap_raise(current-cap_effective, CAP_FOWNER);
+   err = vfs_setxattr(new_lower_dentry, name_list,
+  attr_value, size, 0);
+   cap_lower(current-cap_effective, CAP_FOWNER);
+   }
if (err  0)
goto out;
name_list += strlen(name_list) + 1;
}
 out:
-   name_list = name_list_orig;
-
-   if (name_list)
-   unionfs_xattr_free(name_list, list_size + 1);
-   if (attr_value)
-   unionfs_xattr_free(attr_value, XATTR_SIZE_MAX);
-   /* It is no big deal if this fails, we just roll with the punches. */
+   unionfs_xattr_kfree(name_list_buf);
+   unionfs_xattr_kfree(attr_value);
+   /* Ignore if xattr isn't supported */
if (err == -ENOTSUPP || err == -EOPNOTSUPP)
err = 0;
return err;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 26d886e..d1232ac 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -341,8 +341,10 @@ extern struct dentry *unionfs_interpose(struct dentry 
*this_dentry,
 #ifdef CONFIG_UNION_FS_XATTR
 /* Extended attribute functions. */
 extern void *unionfs_xattr_alloc(size_t size, size_t limit);
-extern void unionfs_xattr_free(void *ptr, size_t size);
-
+static inline void unionfs_xattr_kfree(const void *p)
+{
+   kfree(p);
+}
 extern ssize_t unionfs_getxattr(struct dentry *dentry, const char *name,
void *value, size_t size);
 extern int unionfs_removexattr(struct dentry *dentry, const char *name);
diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 46f3d4e..6ab92f3 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@ -28,25 +28,13 @@ void *unionfs_xattr_alloc(size_t size, size_t limit)
 
if (!size)  /* size request, no buffer is needed */
return NULL;
-   else if (size = PAGE_SIZE)
-   ptr = kmalloc(size, GFP_KERNEL);
-   else
-   ptr = vmalloc(size

[PATCH 05/32] Unionfs: do not use fsstack_copy_attr_all

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Unionfs needs a special fan-out version of fsstack_copy_attr_all, which is
called unionfs_copy_attr_all.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/dentry.c |   12 +---
 fs/unionfs/fanout.h |   50 +-
 fs/unionfs/inode.c  |   13 -
 fs/unionfs/main.c   |2 +-
 fs/unionfs/subr.c   |2 +-
 fs/unionfs/union.h  |5 +++--
 6 files changed, 71 insertions(+), 13 deletions(-)

diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index f88a285..4a3c479 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -166,9 +166,15 @@ static int __unionfs_d_revalidate_one(struct dentry 
*dentry,
valid = 0;
 
if (valid) {
-   fsstack_copy_attr_all(dentry-d_inode,
- unionfs_lower_inode(dentry-d_inode),
- unionfs_get_nlinks);
+   /*
+* If we get here, and we copy the meta-data from the lower
+* inode to our inode, then it is vital that we have already
+* purged all unionfs-level file data.  We do that in the
+* caller (__unionfs_d_revalidate_chain) by calling
+* purge_inode_data.
+*/
+   unionfs_copy_attr_all(dentry-d_inode,
+ unionfs_lower_inode(dentry-d_inode));
fsstack_copy_inode_size(dentry-d_inode,
unionfs_lower_inode(dentry-d_inode));
}
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 4da34c6..5908bc7 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -305,4 +305,52 @@ static inline void verify_locked(struct dentry *d)
BUG_ON(!mutex_is_locked(UNIONFS_D(d)-lock));
 }
 
-#endif /* _FANOUT_H */
+/* copy a/m/ctime from the lower branch with the newest times */
+static inline void unionfs_copy_attr_times(struct inode *upper)
+{
+   int bindex;
+   struct inode *lower;
+
+   if (!upper)
+   return;
+   for (bindex=ibstart(upper); bindex = ibend(upper); bindex++) {
+   lower = unionfs_lower_inode_idx(upper, bindex);
+   if (!lower)
+   continue; /* not all lower dir objects may exist */
+   if (timespec_compare(upper-i_mtime, lower-i_mtime)  0)
+   upper-i_mtime = lower-i_mtime;
+   if (timespec_compare(upper-i_ctime, lower-i_ctime)  0)
+   upper-i_ctime = lower-i_ctime;
+   if (timespec_compare(upper-i_atime, lower-i_atime)  0)
+   upper-i_atime = lower-i_atime;
+   /* XXX: should we notify_change on our upper inode? */
+   }
+}
+
+/*
+ * A unionfs/fanout version of fsstack_copy_attr_all.  Uses a
+ * unionfs_get_nlinks to properly calcluate the number of links to a file.
+ * Also, copies the max() of all a/m/ctimes for all lower inodes (which is
+ * important if the lower inode is a directory type)
+ */
+static inline void unionfs_copy_attr_all(struct inode *dest,
+const struct inode *src)
+{
+   dest-i_mode = src-i_mode;
+   dest-i_uid = src-i_uid;
+   dest-i_gid = src-i_gid;
+   dest-i_rdev = src-i_rdev;
+
+   unionfs_copy_attr_times(dest);
+
+   dest-i_blkbits = src-i_blkbits;
+   dest-i_flags = src-i_flags;
+
+   /*
+* Update the nlinks AFTER updating the above fields, because the
+* get_links callback may depend on them.
+*/
+   dest-i_nlink = unionfs_get_nlinks(dest);
+}
+
+#endif /* not _FANOUT_H */
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 59bb418..cbbde6f 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -369,12 +369,13 @@ check_link:
/* Its a hard link, so use the same inode */
new_dentry-d_inode = igrab(old_dentry-d_inode);
d_instantiate(new_dentry, new_dentry-d_inode);
-   fsstack_copy_attr_all(dir, lower_new_dentry-d_parent-d_inode,
- unionfs_get_nlinks);
+   unionfs_copy_attr_all(dir, lower_new_dentry-d_parent-d_inode);
fsstack_copy_inode_size(dir, lower_new_dentry-d_parent-d_inode);
 
/* propagate number of hard-links */
old_dentry-d_inode-i_nlink = unionfs_get_nlinks(old_dentry-d_inode);
+   /* new dentry's ctime may have changed due to hard-link counts */
+   unionfs_copy_attr_times(new_dentry-d_inode);
 
 out:
if (!new_dentry-d_inode)
@@ -1084,13 +1085,15 @@ static int unionfs_setattr(struct dentry *dentry, 
struct iattr *ia)
}
 
/* get the size from the first lower inode */
-   lower_inode = unionfs_lower_inode(dentry-d_inode);
-   fsstack_copy_attr_all(inode, lower_inode, unionfs_get_nlinks);
+   lower_inode = unionfs_lower_inode(inode

[PATCH 30/32] Unionfs: update unionfs version number

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Update version number from 2.0 to 2.1 to reflect the amount of work that had
gone in since 2.0 was first released, and also to sync up with Unionfs 2.x
releases for earlier kernels.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 include/linux/union_fs.h |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/include/linux/union_fs.h b/include/linux/union_fs.h
index 9bc4e3b..7f8dcc3 100644
--- a/include/linux/union_fs.h
+++ b/include/linux/union_fs.h
@@ -12,7 +12,8 @@
 #ifndef _LINUX_UNION_FS_H
 #define _LINUX_UNION_FS_H
 
-#define UNIONFS_VERSION  2.0
+#define UNIONFS_VERSION  2.1-mm
+
 /*
  * DEFINITIONS FOR USER AND KERNEL CODE:
  */
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/32] Unionfs: partial_lookup update

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Handle new semantics of lookup_backend.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/lookup.c |   22 --
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index e4e8470..d05daa5 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -425,20 +425,30 @@ out:
return ERR_PTR(err);
 }
 
-/* This is a utility function that fills in a unionfs dentry */
+/*
+ * This is a utility function that fills in a unionfs dentry.
+ *
+ * Returns: 0 (ok), or -ERRNO if an error occurred.
+ */
 int unionfs_partial_lookup(struct dentry *dentry)
 {
struct dentry *tmp;
struct nameidata nd = { .flags = 0 };
+   int err = -ENOSYS;
 
tmp = unionfs_lookup_backend(dentry, nd, INTERPOSE_PARTIAL);
-   if (!tmp)
-   return 0;
-   if (IS_ERR(tmp))
-   return PTR_ERR(tmp);
+   if (!tmp) {
+   err = 0;
+   goto out;
+   }
+   if (IS_ERR(tmp)) {
+   err = PTR_ERR(tmp);
+   goto out;
+   }
/* need to change the interface */
BUG_ON(tmp != dentry);
-   return -ENOSYS;
+out:
+   return err;
 }
 
 /* The dentry cache is just so we have properly sized dentries. */
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/32] Unionfs: cache-coherency - file flush

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Update our inode's time after flush.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 0dc7492..edb52c0 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -742,6 +742,11 @@ int unionfs_flush(struct file *file, fl_owner_t id)
 
}
 
+   /* on success, update our times */
+   unionfs_copy_attr_times(dentry-d_inode);
+   /* parent time could have changed too (async) */
+   unionfs_copy_attr_times(dentry-d_parent-d_inode);
+
 out_lock:
unionfs_unlock_dentry(dentry);
 out:
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/32] Unionfs: unionfs_create rewrite

2007-09-02 Thread Josef 'Jeff' Sipek
The code was hard to follow and violated some invariants (e.g., never modify
a read only branch, and always create on branch 0).

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c |  207 +++-
 1 files changed, 58 insertions(+), 149 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 9adf272..08c1ae0 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -24,9 +24,7 @@ static int unionfs_create(struct inode *parent, struct dentry 
*dentry,
int err = 0;
struct dentry *lower_dentry = NULL;
struct dentry *wh_dentry = NULL;
-   struct dentry *new_lower_dentry;
struct dentry *lower_parent_dentry = NULL;
-   int bindex = 0, bstart;
char *name = NULL;
int valid = 0;
 
@@ -47,177 +45,88 @@ static int unionfs_create(struct inode *parent, struct 
dentry *dentry,
 */
BUG_ON(!valid  dentry-d_inode);
 
-   /* We start out in the leftmost branch. */
-   bstart = dbstart(dentry);
-   lower_dentry = unionfs_lower_dentry(dentry);
-
/*
-* check if whiteout exists in this branch, i.e. lookup .wh.foo
-* first.
+* We shouldn't create things in a read-only branch; this check is a
+* bit redundant as we don't allow branch 0 to be read-only at the
+* moment
 */
-   name = alloc_whname(dentry-d_name.name, dentry-d_name.len);
-   if (IS_ERR(name)) {
-   err = PTR_ERR(name);
-   goto out;
-   }
-
-   wh_dentry = lookup_one_len(name, lower_dentry-d_parent,
-  dentry-d_name.len + UNIONFS_WHLEN);
-   if (IS_ERR(wh_dentry)) {
-   err = PTR_ERR(wh_dentry);
-   wh_dentry = NULL;
+   if ((err = is_robranch_super(dentry-d_sb, 0))) {
+   err = -EROFS;
goto out;
}
 
-   if (wh_dentry-d_inode) {
+   /*
+* We _always_ create on branch 0
+*/
+   lower_dentry = unionfs_lower_dentry_idx(dentry, 0);
+   if (lower_dentry) {
/*
-* .wh.foo has been found.
-* First truncate it and then rename it to foo (hence having
-* the same overall effect as a normal create.
+* check if whiteout exists in this branch, i.e. lookup .wh.foo
+* first.
 */
-   struct dentry *lower_dir_dentry;
-   struct iattr newattrs;
-
-   mutex_lock(wh_dentry-d_inode-i_mutex);
-   newattrs.ia_valid = ATTR_CTIME | ATTR_MODE | ATTR_ATIME
-   | ATTR_MTIME | ATTR_UID | ATTR_GID | ATTR_FORCE
-   | ATTR_KILL_SUID | ATTR_KILL_SGID;
-
-   newattrs.ia_mode = mode  ~current-fs-umask;
-   newattrs.ia_uid = current-fsuid;
-   newattrs.ia_gid = current-fsgid;
-
-   if (wh_dentry-d_inode-i_size != 0) {
-   newattrs.ia_valid |= ATTR_SIZE;
-   newattrs.ia_size = 0;
-   }
-
-   err = notify_change(wh_dentry, newattrs);
-
-   mutex_unlock(wh_dentry-d_inode-i_mutex);
-
-   if (err)
-   printk(KERN_WARNING unionfs: %s:%d: notify_change 
-  failed: %d, ignoring..\n,
-  __FILE__, __LINE__, err);
-
-   new_lower_dentry = unionfs_lower_dentry(dentry);
-   dget(new_lower_dentry);
-
-   lower_dir_dentry = dget_parent(wh_dentry);
-   lock_rename(lower_dir_dentry, lower_dir_dentry);
-
-   if (!(err = is_robranch_super(dentry-d_sb, bstart))) {
-   err = vfs_rename(lower_dir_dentry-d_inode,
-wh_dentry,
-lower_dir_dentry-d_inode,
-new_lower_dentry);
-   }
-   if (!err) {
-   fsstack_copy_attr_times(parent,
-   new_lower_dentry-d_parent-
-   d_inode);
-   fsstack_copy_inode_size(parent,
-   new_lower_dentry-d_parent-
-   d_inode);
-   parent-i_nlink = unionfs_get_nlinks(parent);
+   name = alloc_whname(dentry-d_name.name, dentry-d_name.len);
+   if (IS_ERR(name)) {
+   err = PTR_ERR(name);
+   goto out;
}
 
-   unlock_rename(lower_dir_dentry, lower_dir_dentry);
-   dput(lower_dir_dentry);
-
-   dput(new_lower_dentry);
-
-   if (err) {
-   /* exit if the error returned was NOT -EROFS

[PATCH 03/32] VFS/fsstack: cpp endif comments

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Add comments to #endif's to help clarify code.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 include/linux/fs_stack.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index 6b52faf..28543ad 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -39,4 +39,4 @@ static inline void fsstack_copy_attr_times(struct inode *dest,
dest-i_ctime = src-i_ctime;
 }
 
-#endif /* _LINUX_FS_STACK_H */
+#endif /* not _LINUX_FS_STACK_H */
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/32] Unionfs: interpose updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Update unionfs_interpose to handle spliced dentries, which is important for
NFS exporting.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c  |   40 +++
 fs/unionfs/lookup.c |   22 +++-
 fs/unionfs/main.c   |  138 +--
 fs/unionfs/union.h  |4 +-
 4 files changed, 141 insertions(+), 63 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 6cec564..a219a40 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -152,7 +152,12 @@ static int unionfs_create(struct inode *parent, struct 
dentry *dentry,
 wh_dentry);
wh_dentry = NULL;
 
-   err = unionfs_interpose(dentry, parent-i_sb, 0);
+   /*
+* Only INTERPOSE_LOOKUP can return a value other
+* than 0 on err.
+*/
+   err = PTR_ERR(unionfs_interpose(dentry,
+   parent-i_sb, 0));
goto out;
}
}
@@ -194,11 +199,14 @@ static int unionfs_create(struct inode *parent, struct 
dentry *dentry,
if (!IS_COPYUP_ERR(err))
break;
} else {
-   err = unionfs_interpose(dentry, parent-i_sb, 0);
+   /*
+* Only INTERPOSE_LOOKUP can return a value other
+* than 0 on err.
+*/
+   err = PTR_ERR(unionfs_interpose(dentry,
+   parent-i_sb, 0));
if (!err) {
-   fsstack_copy_attr_times(parent,
-   lower_parent_dentry-
-   d_inode);
+   unionfs_copy_attr_times(parent);
fsstack_copy_inode_size(parent,
lower_parent_dentry-
d_inode);
@@ -527,7 +535,12 @@ static int unionfs_symlink(struct inode *dir, struct 
dentry *dentry,
if (!IS_COPYUP_ERR(err))
break;
} else {
-   err = unionfs_interpose(dentry, dir-i_sb, 0);
+   /*
+* Only INTERPOSE_LOOKUP can return a value other
+* than 0 on err.
+*/
+   err = PTR_ERR(unionfs_interpose(dentry,
+   dir-i_sb, 0));
if (!err) {
fsstack_copy_attr_times(dir,
lower_dir_dentry-
@@ -664,10 +677,13 @@ static int unionfs_mkdir(struct inode *parent, struct 
dentry *dentry, int mode)
}
set_dbend(dentry, bindex);
 
-   err = unionfs_interpose(dentry, parent-i_sb, 0);
+   /*
+* Only INTERPOSE_LOOKUP can return a value other than 0 on
+* err.
+*/
+   err = PTR_ERR(unionfs_interpose(dentry, parent-i_sb, 0));
if (!err) {
-   fsstack_copy_attr_times(parent,
-   lower_parent_dentry-d_inode);
+   unionfs_copy_attr_times(parent);
fsstack_copy_inode_size(parent,
lower_parent_dentry-d_inode);
 
@@ -795,7 +811,11 @@ static int unionfs_mknod(struct inode *dir, struct dentry 
*dentry, int mode,
break;
}
 
-   err = unionfs_interpose(dentry, dir-i_sb, 0);
+   /*
+* Only INTERPOSE_LOOKUP can return a value other than 0 on
+* err.
+*/
+   err = PTR_ERR(unionfs_interpose(dentry, dir-i_sb, 0));
if (!err) {
fsstack_copy_attr_times(dir,
lower_parent_dentry-d_inode);
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 61ee50d..e4e8470 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -72,7 +72,12 @@ out:
return err;
 }
 
-/* main (and complex) driver function for Unionfs's lookup */
+/*
+ * Main (and complex) driver function for Unionfs's lookup
+ *
+ * Returns: NULL (ok), ERR_PTR if an error occurred, or a non-null non-error
+ * PTR if d_splice returned a different dentry.
+ */
 struct dentry *unionfs_lookup_backend(struct dentry *dentry

[PATCH 21/32] Unionfs: mmap fixes

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Most important fixes prevent deadlocks especially under low-memory
conditions, when one is not supposed to cause more memory pressure; also
handle AOP_WRITEPAGE_ACTIVATE from lower file systems.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/file.c |6 +-
 fs/unionfs/mmap.c |  132 ++---
 2 files changed, 98 insertions(+), 40 deletions(-)

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 0555b6c..b55da4f 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -101,9 +101,6 @@ static int unionfs_mmap(struct file *file, struct 
vm_area_struct *vma)
 
unionfs_read_lock(file-f_path.dentry-d_sb);
 
-   if ((err = unionfs_file_revalidate(file, 1)))
-   goto out;
-
/* This might be deferred to mmap's writepage */
willwrite = ((vma-vm_flags | VM_SHARED | VM_WRITE) == vma-vm_flags);
if ((err = unionfs_file_revalidate(file, willwrite)))
@@ -132,6 +129,9 @@ static int unionfs_mmap(struct file *file, struct 
vm_area_struct *vma)
 
 out:
unionfs_read_unlock(file-f_path.dentry-d_sb);
+   if (!err)
+   /* copyup could cause parent dir times to change */
+   unionfs_copy_attr_times(file-f_path.dentry-d_parent-d_inode);
return err;
 }
 
diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index 969fd16..d26b572 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -21,7 +21,7 @@
 
 /*
  * Unionfs doesn't implement -writepages, which is OK with the VFS and
- * nkeeps our code simpler and smaller.  Nevertheless, somehow, our own
+ * keeps our code simpler and smaller.  Nevertheless, somehow, our own
  * -writepage must be called so we can sync the upper pages with the lower
  * pages: otherwise data changed at the upper layer won't get written to the
  * lower layer.
@@ -64,10 +64,31 @@ static int unionfs_writepage(struct page *page, struct 
writeback_control *wbc)
inode = page-mapping-host;
lower_inode = unionfs_lower_inode(inode);
 
-   /* find lower page (returns a locked page) */
-   lower_page = grab_cache_page(lower_inode-i_mapping, page-index);
-   if (!lower_page)
+   /*
+* find lower page (returns a locked page)
+*
+* NOTE: we used to call grab_cache_page(), but that was unnecessary
+* as it would have tried to create a new lower page if it didn't
+* exist, leading to deadlocks (esp. under memory-pressure
+* conditions, when it is really a bad idea to *consume* more
+* memory).  Instead, we assume the lower page exists, and if we can
+* find it, then we -writepage on it; if we can't find it, then it
+* couldn't have disappeared unless the kernel already flushed it,
+* in which case we're still OK.  This is especially correct if
+* wbc-sync_mode is WB_SYNC_NONE (as per
+* Documentation/filesystems/vfs.txt).  If we can't flush our page
+* because we can't find a lower page, then at least we re-mark our
+* page as dirty, and return AOP_WRITEPAGE_ACTIVATE as the VFS
+* expects us to.  (Note, if in the future it'd turn out that we
+* have to find a lower page no matter what, then we'd have to
+* resort to RAIF's page pointer flipping trick.)
+*/
+   lower_page = find_lock_page(lower_inode-i_mapping, page-index);
+   if (!lower_page) {
+   err = AOP_WRITEPAGE_ACTIVATE;
+   set_page_dirty(page);
goto out;
+   }
 
/* get page address, and encode it */
kaddr = kmap(page);
@@ -85,24 +106,41 @@ static int unionfs_writepage(struct page *page, struct 
writeback_control *wbc)
wbc-for_writepages = 0;
 
/* call lower writepage (expects locked page) */
+   clear_page_dirty_for_io(lower_page); /* emulate VFS behavior */
err = lower_inode-i_mapping-a_ops-writepage(lower_page, wbc);
wbc-for_writepages = saved_for_writepages; /* restore value */
 
-   /*
-* update mtime and ctime of lower level file system
-* unionfs' mtime and ctime are updated by generic_file_write
-*/
-   lower_inode-i_mtime = lower_inode-i_ctime = CURRENT_TIME;
-
-   page_cache_release(lower_page); /* b/c grab_cache_page increased refcnt 
*/
-
+   /* b/c find_lock_page locked it and -writepage unlocks on success */
if (err)
+   unlock_page(lower_page);
+   /* b/c grab_cache_page increased refcnt */
+   page_cache_release(lower_page);
+
+   if (err  0) {
ClearPageUptodate(page);
-   else
-   SetPageUptodate(page);
+   goto out;
+   }
+   if (err == AOP_WRITEPAGE_ACTIVATE) {
+   /*
+* Lower file systems such as ramfs and tmpfs, may return
+* AOP_WRITEPAGE_ACTIVATE so

[PATCH 29/32] Unionfs: assorted comment and style updates

2007-09-02 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/dirhelper.c |2 --
 fs/unionfs/fanout.h|9 +++--
 fs/unionfs/file.c  |6 --
 fs/unionfs/inode.c |2 +-
 fs/unionfs/lookup.c|2 +-
 fs/unionfs/main.c  |7 +++
 fs/unionfs/rename.c|8 
 fs/unionfs/super.c |7 ++-
 fs/unionfs/union.h |   14 +++---
 fs/unionfs/unlink.c|1 -
 10 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index 24bd327..a72f711 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -31,7 +31,6 @@ int do_delete_whiteouts(struct dentry *dentry, int bindex,
struct dentry *lower_dentry;
char *name = NULL, *p;
struct inode *lower_dir;
-
int i;
struct list_head *pos;
struct filldir_node *cursor;
@@ -95,7 +94,6 @@ int delete_whiteouts(struct dentry *dentry, int bindex,
struct super_block *sb;
struct dentry *lower_dir_dentry;
struct inode *lower_dir;
-
struct sioq_args args;
 
sb = dentry-d_sb;
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 5908bc7..c5bf454 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -65,9 +65,9 @@ static inline void new_branch_id(struct super_block *sb, int 
index)
 }
 
 /*
- * Find new index of matching branch with an existing superblock a a known
+ * Find new index of matching branch with an existing superblock of a known
  * (possibly old) id.  This is needed because branches could have been
- * added/deleted causing the branchs of any open files to shift.
+ * added/deleted causing the branches of any open files to shift.
  *
  * @sb: the new superblock which may have new/different branch IDs
  * @id: the old/existing id we're looking for
@@ -80,10 +80,7 @@ static inline int branch_id_to_idx(struct super_block *sb, 
int id)
if (branch_id(sb, i) == id)
return i;
}
-   /*
-* XXX: maybe we should BUG_ON if not found new branch index?
-* (really that should never happen).
-*/
+   /* in the non-ODF code, this should really never happen */
printk(KERN_WARNING unionfs: cannot find branch with id %d\n, id);
return -1;
 }
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index b55da4f..b33f44f 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -18,17 +18,12 @@
 
 #include union.h
 
-/***
- * File Operations *
- ***/
-
 static ssize_t unionfs_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
 {
int err;
 
unionfs_read_lock(file-f_path.dentry-d_sb);
-
if ((err = unionfs_file_revalidate(file, 0)))
goto out;
 
@@ -50,7 +45,6 @@ static ssize_t unionfs_aio_read(struct kiocb *iocb, const 
struct iovec *iov,
struct file *file = iocb-ki_filp;
 
unionfs_read_lock(file-f_path.dentry-d_sb);
-
if ((err = unionfs_file_revalidate(file, 0)))
goto out;
 
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 4574fbe..218320e 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -781,7 +781,6 @@ static int unionfs_mknod(struct inode *dir, struct dentry 
*dentry, int mode,
if (err) {
if (!IS_COPYUP_ERR(err))
goto out;
-
bstart--;
} else
whiteout_unlinked = 1;
@@ -882,6 +881,7 @@ static int unionfs_readlink(struct dentry *dentry, char 
__user *buf,
 out:
unionfs_unlock_dentry(dentry);
unionfs_read_unlock(dentry-d_sb);
+
return err;
 }
 
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 38ee21f..7fa6310 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -197,7 +197,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 
/* check if whiteout exists in this branch: lookup .wh.foo */
wh_lower_dentry = lookup_one_len(whname, lower_dir_dentry,
- namelen + UNIONFS_WHLEN);
+namelen + UNIONFS_WHLEN);
if (IS_ERR(wh_lower_dentry)) {
dput(first_lower_dentry);
unionfs_mntput(first_dentry, first_dentry_offset);
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index ce08d96..4faae44 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -226,6 +226,7 @@ void unionfs_reinterpose(struct dentry *dentry)
  */
 int check_branch(struct nameidata *nd)
 {
+   /* XXX: remove in ODF code -- stacking unions allowed there */
if (!strcmp(nd-dentry-d_sb-s_type-name, unionfs))
return -EINVAL;
if (!nd-dentry-d_inode

[PATCH 3/5] Unionfs: Use file-f_path instead of file-f_dentry

2007-06-29 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 8527ac6..28cb4e9 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -708,10 +708,10 @@ int unionfs_flush(struct file *file, fl_owner_t id)
 {
int err = 0;
struct file *lower_file = NULL;
-   struct dentry *dentry = file-f_dentry;
+   struct dentry *dentry = file-f_path.dentry;
int bindex, bstart, bend;
 
-   unionfs_read_lock(file-f_path.dentry-d_sb);
+   unionfs_read_lock(dentry-d_sb);
 
if ((err = unionfs_file_revalidate(file, 1)))
goto out;
@@ -745,6 +745,6 @@ int unionfs_flush(struct file *file, fl_owner_t id)
 out_lock:
unionfs_unlock_dentry(dentry);
 out:
-   unionfs_read_unlock(file-f_path.dentry-d_sb);
+   unionfs_read_unlock(dentry-d_sb);
return err;
 }
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] Unionfs: Clarification comment for unionfs_lookup

2007-06-29 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index f946b33..a86da5b 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -217,6 +217,11 @@ out:
return err;
 }
 
+/*
+ * unionfs_lookup is the only special function which takes a dentry, yet we
+ * do NOT want to call __unionfs_d_revalidate_chain because by definition,
+ * we don't have a valid dentry here yet.
+ */
 static struct dentry *unionfs_lookup(struct inode *parent,
 struct dentry *dentry,
 struct nameidata *nd)
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] Unionfs: Remove unnecessary BUG_ON in unionfs_follow_link

2007-06-29 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c |   30 --
 1 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index a86da5b..b5f9022 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -832,35 +832,21 @@ out:
 }
 
 /*
- * Check if dentry is valid or not, as per our generation numbers.
- * @dentry: dentry to check.
- * Returns 1 (valid) or 0 (invalid/stale).
+ * unionfs_follow_link takes a dentry, but it is simple.  It only needs to
+ * allocate some memory and then call our -readlink method.  Our
+ * unionfs_readlink *does* lock our dentry and revalidate the dentry.
+ * Therefore, we do not have to lock our dentry here, to prevent a deadlock;
+ * nor do we need to revalidate it either.  It is safe to not lock our
+ * dentry here, nor revalidate it, because unionfs_follow_link does not do
+ * anything (prior to calling -readlink) which could become inconsistent
+ * due to branch management.
  */
-static inline int is_valid_dentry(struct dentry *dentry)
-{
-   BUG_ON(!UNIONFS_D(dentry));
-   BUG_ON(!UNIONFS_SB(dentry-d_sb));
-   return (atomic_read(UNIONFS_D(dentry)-generation) ==
-   atomic_read(UNIONFS_SB(dentry-d_sb)-generation));
-}
-
-/* We don't lock the dentry here, because readlink does the heavy lifting. */
 static void *unionfs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
char *buf;
int len = PAGE_SIZE, err;
mm_segment_t old_fs;
 
-   /*
-* FIXME: Really nasty...we can get called from two distinct places:
-* 1) read_link - locks the dentry
-* 2) VFS lookup code - does NOT lock the dentry
-*
-* The proper thing would be to call dentry revalidate. It however
-* expects a locked dentry, and we can't cleanly guarantee that.
-*/
-   BUG_ON(!is_valid_dentry(dentry));
-
unionfs_read_lock(dentry-d_sb);
 
/* This is freed by the put_link method assuming a successful call. */
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] Unionfs: Add missing unlock call in unionfs_file_release

2007-06-29 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 6d87426..8527ac6 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -559,7 +559,7 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
 * support.
 */
if ((err = unionfs_file_revalidate(file, 1)))
-   return err;
+   goto out;
fileinfo = UNIONFS_F(file);
BUG_ON(file-f_dentry-d_inode != inode);
inodeinfo = UNIONFS_I(inode);
@@ -596,7 +596,9 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
fileinfo-rdstate = NULL;
}
kfree(fileinfo);
-   return 0;
+out:
+   unionfs_read_unlock(sb);
+   return err;
 }
 
 /* pass the ioctl to the lower fs */
-- 
1.5.2.2.238.g7cbf2f2

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/16] Unionfs: Change free_dentry_private_info to take a struct dentry

2007-06-17 Thread Josef 'Jeff' Sipek
This makes it more symmetric with new_dentry_private_info.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/dentry.c |3 +--
 fs/unionfs/lookup.c |   13 ++---
 fs/unionfs/main.c   |2 +-
 fs/unionfs/union.h  |2 +-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index db0ef43..9bd521b 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -334,8 +334,7 @@ static void unionfs_d_release(struct dentry *dentry)
 
 out_free:
/* No need to unlock it, because it is disappeared. */
-   free_dentry_private_data(UNIONFS_D(dentry));
-   dentry-d_fsdata = NULL;/* just to be safe */
+   free_dentry_private_data(dentry);
 
 out:
return;
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 246a67a..8a09540 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -452,11 +452,12 @@ void unionfs_destroy_dentry_cache(void)
kmem_cache_destroy(unionfs_dentry_cachep);
 }
 
-void free_dentry_private_data(struct unionfs_dentry_info *udi)
+void free_dentry_private_data(struct dentry *dentry)
 {
-   if (!udi)
+   if (!dentry || !dentry-d_fsdata)
return;
-   kmem_cache_free(unionfs_dentry_cachep, udi);
+   kmem_cache_free(unionfs_dentry_cachep, dentry-d_fsdata);
+   dentry-d_fsdata = NULL;
 }
 
 static inline int __realloc_dentry_private_data(struct dentry *dentry)
@@ -493,8 +494,7 @@ int realloc_dentry_private_data(struct dentry *dentry)
return 0;
 
kfree(UNIONFS_D(dentry)-lower_paths);
-   free_dentry_private_data(UNIONFS_D(dentry));
-   dentry-d_fsdata = NULL;
+   free_dentry_private_data(dentry);
return -ENOMEM;
 }
 
@@ -520,8 +520,7 @@ int new_dentry_private_data(struct dentry *dentry)
return 0;
 
mutex_unlock(info-lock);
-   free_dentry_private_data(info);
-   dentry-d_fsdata = NULL;
+   free_dentry_private_data(dentry);
return -ENOMEM;
 }
 
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 2bcc84c..b9fe431 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -632,7 +632,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
 out_freedpd:
if (UNIONFS_D(sb-s_root)) {
kfree(UNIONFS_D(sb-s_root)-lower_paths);
-   free_dentry_private_data(UNIONFS_D(sb-s_root));
+   free_dentry_private_data(sb-s_root);
}
dput(sb-s_root);
 
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 7e0c318..6eb151e 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -235,7 +235,7 @@ static inline void unionfs_double_lock_dentry(struct dentry 
*d1,
 
 extern int realloc_dentry_private_data(struct dentry *dentry);
 extern int new_dentry_private_data(struct dentry *dentry);
-extern void free_dentry_private_data(struct unionfs_dentry_info *udi);
+extern void free_dentry_private_data(struct dentry *dentry);
 extern void update_bstart(struct dentry *dentry);
 
 /*
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/16] Unionfs: Cleanup new_dentry_private_data

2007-06-17 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/lookup.c |   96 +++---
 fs/unionfs/union.h  |1 +
 2 files changed, 60 insertions(+), 37 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 758c813..246a67a 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -106,11 +106,22 @@ struct dentry *unionfs_lookup_backend(struct dentry 
*dentry,
BUG_ON(UNIONFS_D(dentry) != NULL);
locked_child = 1;
}
-   if (lookupmode != INTERPOSE_PARTIAL) {
-   if ((err = new_dentry_private_data(dentry)))
-   goto out;
-   allocated_new_info = 1;
+
+   switch(lookupmode) {
+   case INTERPOSE_PARTIAL:
+   break;
+   case INTERPOSE_LOOKUP:
+   if ((err = new_dentry_private_data(dentry)))
+   goto out;
+   allocated_new_info = 1;
+   break;
+   default:
+   if ((err = realloc_dentry_private_data(dentry)))
+   goto out;
+   allocated_new_info = 1;
+   break;
}
+
/* must initialize dentry operations */
dentry-d_op = unionfs_dops;
 
@@ -448,58 +459,69 @@ void free_dentry_private_data(struct unionfs_dentry_info 
*udi)
kmem_cache_free(unionfs_dentry_cachep, udi);
 }
 
-/* allocate new dentry private data, free old one if necessary */
-int new_dentry_private_data(struct dentry *dentry)
+static inline int __realloc_dentry_private_data(struct dentry *dentry)
 {
-   int size;
struct unionfs_dentry_info *info = UNIONFS_D(dentry);
void *p;
-   int unlock_on_err = 0;
-
-   spin_lock(dentry-d_lock);
-   if (!info) {
-   dentry-d_fsdata = kmem_cache_alloc(unionfs_dentry_cachep,
-   GFP_ATOMIC);
-   
-   info = UNIONFS_D(dentry);
-   if (!info)
-   goto out;
+   int size;
 
-   mutex_init(info-lock);
-   mutex_lock(info-lock);
-   unlock_on_err = 1;
+   BUG_ON(!info);
 
-   info-lower_paths = NULL;
-   }
+   size = sizeof(struct path) * sbmax(dentry-d_sb);
+   p = krealloc(info-lower_paths, size, GFP_ATOMIC);
+   if (!p)
+   return -ENOMEM;
+
+   info-lower_paths = p;
 
info-bstart = -1;
info-bend = -1;
info-bopaque = -1;
info-bcount = sbmax(dentry-d_sb);
atomic_set(info-generation,
-  atomic_read(UNIONFS_SB(dentry-d_sb)-generation));
-
-   size = sizeof(struct path) * sbmax(dentry-d_sb);
-
-   p = krealloc(info-lower_paths, size, GFP_ATOMIC);
-   if (!p)
-   goto out_free;
+   atomic_read(UNIONFS_SB(dentry-d_sb)-generation));
 
-   info-lower_paths = p;
memset(info-lower_paths, 0, size);
 
-   spin_unlock(dentry-d_lock);
return 0;
+}
 
-out_free:
-   kfree(info-lower_paths);
-   if (unlock_on_err)
-   mutex_unlock(info-lock);
+/* UNIONFS_D(dentry)-lock must be locked */
+int realloc_dentry_private_data(struct dentry *dentry)
+{
+   if (!__realloc_dentry_private_data(dentry))
+   return 0;
 
-out:
+   kfree(UNIONFS_D(dentry)-lower_paths);
+   free_dentry_private_data(UNIONFS_D(dentry));
+   dentry-d_fsdata = NULL;
+   return -ENOMEM;
+}
+
+/* allocate new dentry private data */
+int new_dentry_private_data(struct dentry *dentry)
+{
+   struct unionfs_dentry_info *info = UNIONFS_D(dentry);
+
+   BUG_ON(info);
+
+   info = kmem_cache_alloc(unionfs_dentry_cachep, GFP_ATOMIC);
+   if (!info)
+   return -ENOMEM;
+
+   mutex_init(info-lock);
+   mutex_lock(info-lock);
+
+   info-lower_paths = NULL;
+
+   dentry-d_fsdata = info;
+
+   if (!__realloc_dentry_private_data(dentry))
+   return 0;
+
+   mutex_unlock(info-lock);
free_dentry_private_data(info);
dentry-d_fsdata = NULL;
-   spin_unlock(dentry-d_lock);
return -ENOMEM;
 }
 
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 28eb622..7e0c318 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -233,6 +233,7 @@ static inline void unionfs_double_lock_dentry(struct dentry 
*d1,
unionfs_lock_dentry(d2);
 }
 
+extern int realloc_dentry_private_data(struct dentry *dentry);
 extern int new_dentry_private_data(struct dentry *dentry);
 extern void free_dentry_private_data(struct unionfs_dentry_info *udi);
 extern void update_bstart(struct dentry *dentry);
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org

[PATCH 16/16] Unionfs: Remove superfluous check for NULL pointer

2007-06-17 Thread Josef 'Jeff' Sipek
Since we use containers and the struct inode is _inside_ the
unionfs_inode_info structure, UNIONFS_I will always (given a non-NULL inode
pointer), return a valid non-NULL pointer.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/fanout.h |8 +++-
 fs/unionfs/super.c  |6 --
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index d4933ce..4da34c6 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -18,7 +18,13 @@
 #ifndef _FANOUT_H_
 #define _FANOUT_H_
 
-/* Inode to private data */
+/*
+ * Inode to private data
+ *
+ * Since we use containers and the struct inode is _inside_ the
+ * unionfs_inode_info structure, UNIONFS_I will always (given a non-NULL
+ * inode pointer), return a valid non-NULL pointer.
+ */
 static inline struct unionfs_inode_info *UNIONFS_I(const struct inode *inode)
 {
return container_of(inode, struct unionfs_inode_info, vfs_inode);
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 9f248b9..0e6dad1 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -32,12 +32,6 @@ static void unionfs_read_inode(struct inode *inode)
 
unionfs_read_lock(inode-i_sb);
 
-   if (!info) {
-   printk(KERN_ERR unionfs: no kernel memory when allocating 
-  inode private data!\n);
-   BUG();
-   }
-
memset(info, 0, offsetof(struct unionfs_inode_info, vfs_inode));
info-bstart = -1;
info-bend = -1;
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/16] Unionfs: Add BUG_ONs to unionfs_lower_*

2007-06-17 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/fanout.h |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 0319835..d4933ce 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -42,16 +42,19 @@ static inline struct unionfs_inode_info *UNIONFS_I(const 
struct inode *inode)
 /* macros to manipulate branch IDs in stored in our superblock */
 static inline int branch_id(struct super_block *sb, int index)
 {
+   BUG_ON(!sb || index  0);
return UNIONFS_SB(sb)-data[index].branch_id;
 }
 
 static inline void set_branch_id(struct super_block *sb, int index, int val)
 {
+   BUG_ON(!sb || index  0);
UNIONFS_SB(sb)-data[index].branch_id = val;
 }
 
 static inline void new_branch_id(struct super_block *sb, int index)
 {
+   BUG_ON(!sb || index  0);
set_branch_id(sb, index, ++UNIONFS_SB(sb)-high_branch_id);
 }
 
@@ -82,18 +85,21 @@ static inline int branch_id_to_idx(struct super_block *sb, 
int id)
 /* File to lower file. */
 static inline struct file *unionfs_lower_file(const struct file *f)
 {
+   BUG_ON(!f);
return UNIONFS_F(f)-lower_files[fbstart(f)];
 }
 
 static inline struct file *unionfs_lower_file_idx(const struct file *f,
  int index)
 {
+   BUG_ON(!f || index  0);
return UNIONFS_F(f)-lower_files[index];
 }
 
 static inline void unionfs_set_lower_file_idx(struct file *f, int index,
  struct file *val)
 {
+   BUG_ON(!f || index  0);
UNIONFS_F(f)-lower_files[index] = val;
/* save branch ID (may be redundant?) */
UNIONFS_F(f)-saved_branch_ids[index] =
@@ -102,29 +108,34 @@ static inline void unionfs_set_lower_file_idx(struct file 
*f, int index,
 
 static inline void unionfs_set_lower_file(struct file *f, struct file *val)
 {
+   BUG_ON(!f);
unionfs_set_lower_file_idx((f), fbstart(f), (val));
 }
 
 /* Inode to lower inode. */
 static inline struct inode *unionfs_lower_inode(const struct inode *i)
 {
+   BUG_ON(!i);
return UNIONFS_I(i)-lower_inodes[ibstart(i)];
 }
 
 static inline struct inode *unionfs_lower_inode_idx(const struct inode *i,
int index)
 {
+   BUG_ON(!i || index  0);
return UNIONFS_I(i)-lower_inodes[index];
 }
 
 static inline void unionfs_set_lower_inode_idx(struct inode *i, int index,
   struct inode *val)
 {
+   BUG_ON(!i || index  0);
UNIONFS_I(i)-lower_inodes[index] = val;
 }
 
 static inline void unionfs_set_lower_inode(struct inode *i, struct inode *val)
 {
+   BUG_ON(!i);
UNIONFS_I(i)-lower_inodes[ibstart(i)] = val;
 }
 
@@ -132,6 +143,7 @@ static inline void unionfs_set_lower_inode(struct inode *i, 
struct inode *val)
 static inline struct super_block *unionfs_lower_super(
const struct super_block *sb)
 {
+   BUG_ON(!sb);
return UNIONFS_SB(sb)-data[sbstart(sb)].sb;
 }
 
@@ -139,6 +151,7 @@ static inline struct super_block *unionfs_lower_super_idx(
const struct super_block *sb,
int index)
 {
+   BUG_ON(!sb || index  0);
return UNIONFS_SB(sb)-data[index].sb;
 }
 
@@ -146,75 +159,89 @@ static inline void unionfs_set_lower_super_idx(struct 
super_block *sb,
   int index,
   struct super_block *val)
 {
+   BUG_ON(!sb || index  0);
UNIONFS_SB(sb)-data[index].sb = val;
 }
 
 static inline void unionfs_set_lower_super(struct super_block *sb,
   struct super_block *val)
 {
+   BUG_ON(!sb);
UNIONFS_SB(sb)-data[sbstart(sb)].sb = val;
 }
 
 /* Branch count macros. */
 static inline int branch_count(const struct super_block *sb, int index)
 {
+   BUG_ON(!sb || index  0);
return atomic_read(UNIONFS_SB(sb)-data[index].open_files);
 }
 
 static inline void set_branch_count(struct super_block *sb, int index, int val)
 {
+   BUG_ON(!sb || index  0);
atomic_set(UNIONFS_SB(sb)-data[index].open_files, val);
 }
 
 static inline void branchget(struct super_block *sb, int index)
 {
+   BUG_ON(!sb || index  0);
atomic_inc(UNIONFS_SB(sb)-data[index].open_files);
 }
 
 static inline void branchput(struct super_block *sb, int index)
 {
+   BUG_ON(!sb || index  0);
atomic_dec(UNIONFS_SB(sb)-data[index].open_files);
 }
 
 /* Dentry macros */
 static inline struct unionfs_dentry_info *UNIONFS_D(const struct dentry *dent)
 {
+   BUG_ON(!dent);
return dent-d_fsdata;
 }
 
 static inline int dbstart(const struct dentry *dent)
 {
+   BUG_ON(!dent);
return UNIONFS_D(dent)-bstart;
 }
 
 static inline

[PATCH 11/16] Unionfs: Revalidate dentries passed to all inode/super operations

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Be sure to properly revalidate all dentry chains passed to all inode and
super_block operations.  Remove the older BUG_ON test is_valid_dentry().
This should help improve cache-coherency.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c  |   71 ---
 fs/unionfs/rename.c |   13 +++--
 fs/unionfs/super.c  |9 ++-
 fs/unionfs/union.h  |   13 -
 fs/unionfs/unlink.c |   15 ---
 fs/unionfs/xattr.c  |   34 ++--
 6 files changed, 111 insertions(+), 44 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 9f1acc4..aaabfcf 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -47,7 +47,7 @@ static int unionfs_create(struct inode *parent, struct dentry 
*dentry,
valid = __unionfs_d_revalidate_chain(dentry-d_parent, nd);
unionfs_unlock_dentry(dentry-d_parent);
if (!valid) {
-   err = -ENOENT;  /* same as what real_lookup does */
+   err = -ESTALE;  /* same as what real_lookup does */
goto out;
}
valid = __unionfs_d_revalidate_chain(dentry, nd);
@@ -234,6 +234,12 @@ static struct dentry *unionfs_lookup(struct inode *parent,
struct path path_save;
struct dentry *ret;
 
+   /*
+* lookup is the only special function which takes a dentry, yet we
+* do NOT want to call __unionfs_d_revalidate_chain because by
+* definition, we don't have a valid dentry here yet.
+*/
+
/* save the dentry  vfsmnt from namei */
if (nd) {
path_save.dentry = nd-dentry;
@@ -262,11 +268,18 @@ static int unionfs_link(struct dentry *old_dentry, struct 
inode *dir,
struct dentry *whiteout_dentry;
char *name = NULL;
 
-   BUG_ON(!is_valid_dentry(new_dentry));
-   BUG_ON(!is_valid_dentry(old_dentry));
-
unionfs_double_lock_dentry(new_dentry, old_dentry);
 
+   if (!__unionfs_d_revalidate_chain(old_dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+   if (new_dentry-d_inode 
+   !__unionfs_d_revalidate_chain(new_dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+
hidden_new_dentry = unionfs_lower_dentry(new_dentry);
 
/*
@@ -392,10 +405,14 @@ static int unionfs_symlink(struct inode *dir, struct 
dentry *dentry,
int bindex = 0, bstart;
char *name = NULL;
 
-   BUG_ON(!is_valid_dentry(dentry));
-
unionfs_lock_dentry(dentry);
 
+   if (dentry-d_inode 
+   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+
/* We start out in the leftmost branch. */
bstart = dbstart(dentry);
 
@@ -534,9 +551,14 @@ static int unionfs_mkdir(struct inode *parent, struct 
dentry *dentry, int mode)
int whiteout_unlinked = 0;
struct sioq_args args;
 
-   BUG_ON(!is_valid_dentry(dentry));
-
unionfs_lock_dentry(dentry);
+
+   if (dentry-d_inode 
+   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+
bstart = dbstart(dentry);
 
hidden_dentry = unionfs_lower_dentry(dentry);
@@ -667,9 +689,14 @@ static int unionfs_mknod(struct inode *dir, struct dentry 
*dentry, int mode,
char *name = NULL;
int whiteout_unlinked = 0;
 
-   BUG_ON(!is_valid_dentry(dentry));
-
unionfs_lock_dentry(dentry);
+
+   if (dentry-d_inode 
+   !__unionfs_d_revalidate_chain(dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+
bstart = dbstart(dentry);
 
hidden_dentry = unionfs_lower_dentry(dentry);
@@ -774,9 +801,13 @@ static int unionfs_readlink(struct dentry *dentry, char 
__user *buf,
int err;
struct dentry *hidden_dentry;
 
-   BUG_ON(!is_valid_dentry(dentry));
-
unionfs_lock_dentry(dentry);
+
+   if (!__unionfs_d_revalidate_chain(dentry, NULL)) {
+   err = -ESTALE;
+   goto out;
+   }
+
hidden_dentry = unionfs_lower_dentry(dentry);
 
if (!hidden_dentry-d_inode-i_op ||
@@ -803,7 +834,13 @@ static void *unionfs_follow_link(struct dentry *dentry, 
struct nameidata *nd)
int len = PAGE_SIZE, err;
mm_segment_t old_fs;
 
-   BUG_ON(!is_valid_dentry(dentry));
+   unionfs_lock_dentry(dentry);
+
+   if (dentry-d_inode 
+   !__unionfs_d_revalidate_chain(dentry, nd)) {
+   err = -ESTALE;
+   goto out;
+   }
 
/* This is freed by the put_link method assuming a successful call. */
buf = kmalloc(len, GFP_KERNEL);
@@ -969,9 +1006,13 @@ static int unionfs_setattr(struct dentry *dentry, struct 
iattr *ia)
int i;
int

[PATCH 15/16] Unionfs: Change the semantics of sb info's rwsem

2007-06-17 Thread Josef 'Jeff' Sipek
This rw semaphore is used to make sure that a branch management operation...

1) will not begin before all currently in-flight operations complete

2) any new operations do not execute until the currently running branch
management operation completes

TODO: rename the functions unionfs_{read,write}_{,un}lock() to something
more descriptive.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   33 ---
 fs/unionfs/copyup.c |   10 ---
 fs/unionfs/dentry.c |7 +
 fs/unionfs/dirfops.c|   10 ---
 fs/unionfs/dirhelper.c  |   10 ---
 fs/unionfs/file.c   |   16 +-
 fs/unionfs/inode.c  |   66 ++
 fs/unionfs/main.c   |   23 
 fs/unionfs/rename.c |2 +
 fs/unionfs/super.c  |   34 +++-
 fs/unionfs/union.h  |   15 +++---
 fs/unionfs/unlink.c |4 +++
 fs/unionfs/xattr.c  |8 +
 13 files changed, 138 insertions(+), 100 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 731e3a9..a6917fe 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -119,10 +119,8 @@ static void cleanup_file(struct file *file)
printk(KERN_ERR unionfs: no superblock for 
   file %p\n, file);
else {
-   unionfs_read_lock(sb);
/* decrement count of open files */
branchput(sb, i);
-   unionfs_read_unlock(sb);
/*
 * fput will perform an mntput for us on the
 * correct branch.  Although we're using the
@@ -164,9 +162,7 @@ static int open_all_files(struct file *file)
 
dget(hidden_dentry);
unionfs_mntget(dentry, bindex);
-   unionfs_read_lock(sb);
branchget(sb, bindex);
-   unionfs_read_unlock(sb);
 
hidden_file =
dentry_open(hidden_dentry,
@@ -213,9 +209,7 @@ static int open_highest_file(struct file *file, int 
willwrite)
 
dget(hidden_dentry);
unionfs_mntget(dentry, bstart);
-   unionfs_read_lock(sb);
branchget(sb, bstart);
-   unionfs_read_unlock(sb);
hidden_file = dentry_open(hidden_dentry,
  unionfs_lower_mnt_idx(dentry, bstart),
  file-f_flags);
@@ -259,9 +253,7 @@ static int do_delayed_copyup(struct file *file, struct 
dentry *dentry)
bend = fbend(file);
for (bindex = bstart; bindex = bend; bindex++) {
if (unionfs_lower_file_idx(file, bindex)) {
-   unionfs_read_lock(dentry-d_sb);
branchput(dentry-d_sb, bindex);
-   unionfs_read_unlock(dentry-d_sb);
fput(unionfs_lower_file_idx(file, bindex));
unionfs_set_lower_file_idx(file, bindex, NULL);
}
@@ -400,9 +392,7 @@ static int __open_dir(struct inode *inode, struct file 
*file)
 * The branchget goes after the open, because otherwise
 * we would miss the reference on release.
 */
-   unionfs_read_lock(inode-i_sb);
branchget(inode-i_sb, bindex);
-   unionfs_read_unlock(inode-i_sb);
}
 
return 0;
@@ -463,9 +453,7 @@ static int __open_file(struct inode *inode, struct file 
*file)
return PTR_ERR(hidden_file);
 
unionfs_set_lower_file(file, hidden_file);
-   unionfs_read_lock(inode-i_sb);
branchget(inode-i_sb, bstart);
-   unionfs_read_unlock(inode-i_sb);
 
return 0;
 }
@@ -479,6 +467,7 @@ int unionfs_open(struct inode *inode, struct file *file)
int size;
 
unionfs_read_lock(inode-i_sb);
+
file-private_data =
kzalloc(sizeof(struct unionfs_file_info), GFP_KERNEL);
if (!UNIONFS_F(file)) {
@@ -529,9 +518,7 @@ int unionfs_open(struct inode *inode, struct file *file)
if (!hidden_file)
continue;
 
-   unionfs_read_lock(file-f_dentry-d_sb);
branchput(file-f_dentry-d_sb, bindex);
-   unionfs_read_unlock(file-f_dentry-d_sb);
/* fput calls dput for hidden_dentry */
fput(hidden_file);
}
@@ -550,7 +537,11 @@ out_nofree:
return err;
 }
 
-/* release all lower object references  free the file info structure */
+/*
+ * release all lower object references  free the file info structure
+ *
+ * No need to grab sb info's rwsem.
+ */
 int

[GIT PULL -mm] Unionfs cleanups, fixes, and mmap

2007-06-17 Thread Josef 'Jeff' Sipek
The following patches consist of mostly cleanups and bug fixes of the
Unionfs code. The major improvement is the new mmap implementation, as well
as a major locking overhaul.

As before, there is a git repo at:

git://git.kernel.org/pub/scm/linux/kernel/git/jsipek/unionfs.git

(master.kernel.org:/pub/scm/linux/kernel/git/jsipek/unionfs.git)

There are 16 new commits:

Erez Zadok (9):
  Unionfs: Don't revalidate dropped dentries
  Unionfs: Retry lookup for different silly-renamed files
  Unionfs: Set lower inodes correctly after branch management succeeds
  Unionfs: call statfs on lower file system properly
  MAINTAINERS: Add Erez Zadok as a maintainer of Unionfs
  Unionfs: Add standard copyright comment to include/linux/union_fs.h
  Unionfs: Remove unnecessary #define
  Unionfs: merge find_new_branch_index and branch_id_to_idx into one 
function
  Unionfs: Revalidate dentries passed to all inode/super operations

Josef 'Jeff' Sipek (5):
  Unionfs: Cleanup new_dentry_private_data
  Unionfs: Change free_dentry_private_info to take a struct dentry
  Unionfs: Add BUG_ONs to unionfs_lower_*
  Unionfs: Change the semantics of sb info's rwsem
  Unionfs: Remove superfluous check for NULL pointer

Randy Dunlap (1):
  unionfs section mismatch

Yiannis Pericleous (1):
  Unionfs: mmap implementation

Thanks,

Josef 'Jeff' Sipek [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/16] Unionfs: Don't revalidate dropped dentries

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

This fixes a harmless but annoying message that unionfs prints if a dropped
dentry is being revalidated, which could happen if you unlink open files.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 1045e51..89a236b 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -305,9 +305,12 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
unionfs_lock_dentry(dentry);
sb = dentry-d_sb;
 
-   /* first revalidate the dentry inside struct file */
-   if (!__unionfs_d_revalidate_chain(dentry, NULL) 
-   !d_deleted(dentry)) {
+   /*
+* First revalidate the dentry inside struct file,
+* but not unhashed dentries.
+*/
+   if (!d_deleted(dentry) 
+   !__unionfs_d_revalidate_chain(dentry, NULL)) {
err = -ESTALE;
goto out_nofree;
}
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/16] Unionfs: Set lower inodes correctly after branch management succeeds

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   50 +-
 1 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index fe02941..b3a5e64 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -335,7 +335,13 @@ found_insertion_point:
   new_branch, err);
goto out;
}
-   /* it's probably safe to check_mode the new branch to insert */
+   /*
+* It's probably safe to check_mode the new branch to insert.  Note:
+* we don't allow inserting branches which are unionfs's by
+* themselves (check_branch returns EINVAL in that case).  This is
+* because this code base doesn't support stacking unionfs: the ODF
+* code base supports that correctly.
+*/
if ((err = check_branch(nd))) {
printk(KERN_WARNING unionfs: hidden directory 
   \%s\ is not a valid branch\n, optarg);
@@ -400,15 +406,17 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
int i;
char *optionstmp, *tmp_to_free; /* kstrdup'ed of options */
char *optname;
-   int cur_branches;   /* no. of current branches */
-   int new_branches;   /* no. of branches actually left in the end */
+   int cur_branches = 0;   /* no. of current branches */
+   int new_branches = 0;   /* no. of branches actually left in the end */
int add_branches;   /* est. no. of branches to add */
int del_branches;   /* est. no. of branches to del */
int max_branches;   /* max possible no. of branches */
struct unionfs_data *new_data = NULL, *tmp_data = NULL;
struct path *new_lower_paths = NULL, *tmp_lower_paths = NULL;
+   struct inode **new_lower_inodes = NULL;
int new_high_branch_id; /* new high branch ID */
int size;   /* memory allocation size, temp var */
+   int old_ibstart, old_ibend;
 
unionfs_write_lock(sb);
 
@@ -640,6 +648,14 @@ out_no_change:
goto out_release;
}
 
+   /* allocate space for new pointers to lower inodes */
+   new_lower_inodes = kcalloc(new_branches,
+  sizeof(struct inode *), GFP_KERNEL);
+   if (!new_lower_inodes) {
+   err = -ENOMEM;
+   goto out_release;
+   }
+
/*
 * OK, just before we actually put the new set of branches in place,
 * we need to ensure that our own f/s has no dirty objects left.
@@ -660,7 +676,7 @@ out_no_change:
 * fsync_super() which would not have returned until all dirty pages
 * were flushed.
 *
-* But do w have to worry about locked pages?  Is there any chance
+* But do we have to worry about locked pages?  Is there any chance
 * that in here we'll get locked pages?
 *
 * XXX: what about pages mapped into pagetables?  Are these pages
@@ -687,8 +703,31 @@ out_no_change:
i = sbmax(sb);  /* save no. of branches to release at end */
sbend(sb) = new_branches - 1;
set_dbend(sb-s_root, new_branches - 1);
+   old_ibstart = ibstart(sb-s_root-d_inode);
+   old_ibend = ibend(sb-s_root-d_inode);
+   ibend(sb-s_root-d_inode) = new_branches - 1;
UNIONFS_D(sb-s_root)-bcount = new_branches;
-   new_branches = i;   /* no. of branches to release below */
+   new_branches = i; /* no. of branches to release below */
+
+   /*
+* Update lower inodes: 3 steps
+* 1. grab ref on all new lower inodes
+*/
+   for (i=dbstart(sb-s_root); i=dbend(sb-s_root); i++) {
+   struct dentry *lower_dentry =
+   unionfs_lower_dentry_idx(sb-s_root, i);
+   atomic_inc(lower_dentry-d_inode-i_count);
+   new_lower_inodes[i] = lower_dentry-d_inode;
+   }
+   /* 2. release reference on all older lower inodes */
+   for (i=old_ibstart; i=old_ibend; i++) {
+   iput(unionfs_lower_inode_idx(sb-s_root-d_inode, i));
+   unionfs_set_lower_inode_idx(sb-s_root-d_inode, i, NULL);
+   }
+   kfree(UNIONFS_I(sb-s_root-d_inode)-lower_inodes);
+   /* 3. update root dentry's inode to new lower_inodes array */
+   UNIONFS_I(sb-s_root-d_inode)-lower_inodes = new_lower_inodes;
+   new_lower_inodes = NULL;
 
/* maxbytes may have changed */
sb-s_maxbytes = unionfs_lower_super_idx(sb, 0)-s_maxbytes;
@@ -723,6 +762,7 @@ out_free:
kfree(tmp_data);
kfree(new_lower_paths);
kfree(new_data);
+   kfree(new_lower_inodes);
 out_error:
unionfs_write_unlock(sb);
return err;
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux

[PATCH 07/16] Unionfs: Add standard copyright comment to include/linux/union_fs.h

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 include/linux/union_fs.h |   11 +++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/include/linux/union_fs.h b/include/linux/union_fs.h
index b724031..223ccab 100644
--- a/include/linux/union_fs.h
+++ b/include/linux/union_fs.h
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2003-2007 Erez Zadok
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2003-2007 Stony Brook University
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
 #ifndef _LINUX_UNION_FS_H
 #define _LINUX_UNION_FS_H
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/16] Unionfs: Retry lookup for different silly-renamed files

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

When we have to copyup an open-but-unlinked file, we have to give it a
temporary name, similar to NFS's silly-renamed files.  So we generate
temporary file names until we find one that doesn't exist, and use it.  The
code had a bug where if the silly-renamed file name already existed, Unionfs
would oops upon copyup to that temp name.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 89a236b..28635d8 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -42,6 +42,7 @@ static int copyup_deleted_file(struct file *file, struct 
dentry *dentry,
sprintf(name, .unionfs%*.*lx,
i_inosize, i_inosize, hidden_dentry-d_inode-i_ino);
 
+retry:
/*
 * Loop, looking for an unused temp name to copyup to.
 *
@@ -68,13 +69,14 @@ static int copyup_deleted_file(struct file *file, struct 
dentry *dentry,
err = PTR_ERR(tmp_dentry);
goto out;
}
-   /* don't dput here because of do-while condition eval order */
} while (tmp_dentry-d_inode != NULL);  /* need negative dentry */
dput(tmp_dentry);
 
err = copyup_named_file(dentry-d_parent-d_inode, file, name, bstart,
bindex, file-f_dentry-d_inode-i_size);
-   if (err)
+   if (err == -EEXIST)
+   goto retry;
+   else if (err)
goto out;
 
/* bring it to the same state as an unlinked file */
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/16] Unionfs: merge find_new_branch_index and branch_id_to_idx into one function

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Useful code cleanup and consolidation between the ODF code and non-ODF code.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   35 +--
 fs/unionfs/fanout.h |   24 
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 0222393..731e3a9 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -90,31 +90,6 @@ out:
 }
 
 /*
- * Find new index of matching branch with an open file, since branches could
- * have been added/deleted causing the one with open files to shift.
- *
- * @file: current file whose branches may have changed
- * @bindex: index of branch within current file (could be old branch)
- * @new_sb: the new superblock which may have new branch IDs
- * Returns index of newly found branch (0 or greater), -1 otherwise.
- */
-static int find_new_branch_index(struct file *file, int bindex,
-struct super_block *new_sb)
-{
-   int old_branch_id = UNIONFS_F(file)-saved_branch_ids[bindex];
-   int i;
-
-   for (i = 0; i  sbmax(new_sb); i++)
-   if (old_branch_id == branch_id(new_sb, i))
-   return i;
-   /*
-* XXX: maybe we should BUG_ON if not found new branch index?
-* (really that should never happen).
-*/
-   return -1;
-}
-
-/*
  * put all references held by upper struct file and free lower file pointer
  * array
  */
@@ -130,8 +105,16 @@ static void cleanup_file(struct file *file)
 
for (bindex = bstart; bindex = bend; bindex++) {
if (unionfs_lower_file_idx(file, bindex)) {
+   /*
+* Find new index of matching branch with an open
+* file, since branches could have been added or
+* deleted causing the one with open files to shift.
+*/
int i;  /* holds (possibly) updated branch index */
-   i = find_new_branch_index(file, bindex, sb);
+   int old_bid;
+
+   old_bid = UNIONFS_F(file)-saved_branch_ids[bindex];
+   i = branch_id_to_idx(sb, old_bid);
if (i  0)
printk(KERN_ERR unionfs: no superblock for 
   file %p\n, file);
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 71052a3..0319835 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -55,6 +55,30 @@ static inline void new_branch_id(struct super_block *sb, int 
index)
set_branch_id(sb, index, ++UNIONFS_SB(sb)-high_branch_id);
 }
 
+/*
+ * Find new index of matching branch with an existing superblock a a known
+ * (possibly old) id.  This is needed because branches could have been
+ * added/deleted causing the branchs of any open files to shift.
+ *
+ * @sb: the new superblock which may have new/different branch IDs
+ * @id: the old/existing id we're looking for
+ * Returns index of newly found branch (0 or greater), -1 otherwise.
+ */
+static inline int branch_id_to_idx(struct super_block *sb, int id)
+{
+   int i;
+   for (i = 0; i  sbmax(sb); i++) {
+   if (branch_id(sb, i) == id)
+   return i;
+   }
+   /*
+* XXX: maybe we should BUG_ON if not found new branch index?
+* (really that should never happen).
+*/
+   printk(KERN_WARNING unionfs: cannot find branch with id %d\n, id);
+   return -1;
+}
+
 /* File to lower file. */
 static inline struct file *unionfs_lower_file(const struct file *f)
 {
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/16] [PATCH] unionfs section mismatch

2007-06-17 Thread Josef 'Jeff' Sipek
From: Randy Dunlap [EMAIL PROTECTED]

Fix section marker in header file:

WARNING: fs/unionfs/unionfs.o(.init.text+0x56): Section mismatch: reference to 
.exit.text:stop_sioq (between 'init_module' and 'init_sioq')

Signed-off-by: Randy Dunlap [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/sioq.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 55b781e..6d0d01f 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -76,7 +76,7 @@ struct sioq_args {
 
 /* Extern definitions for SIOQ functions */
 extern int __init init_sioq(void);
-extern __exit void stop_sioq(void);
+extern void stop_sioq(void);
 extern void run_sioq(work_func_t func, struct sioq_args *args);
 
 /* Extern definitions for our privilege escalation helpers */
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/16] Unionfs: Remove unnecessary #define

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

UNIONFS_TMPNAM_LEN is used in only one place, and we have calculate the
length of the string to begin with.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |2 +-
 fs/unionfs/union.h  |3 ---
 2 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 28635d8..db8c334 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -64,7 +64,7 @@ retry:
   dentry-d_name.name, name);
 
tmp_dentry = lookup_one_len(name, hidden_dentry-d_parent,
-   UNIONFS_TMPNAM_LEN);
+   nlen);
if (IS_ERR(tmp_dentry)) {
err = PTR_ERR(tmp_dentry);
goto out;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 335d579..01e29f3 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -54,9 +54,6 @@
 /* unionfs root inode number */
 #define UNIONFS_ROOT_INO 1
 
-/* number of characters while generating unique temporary file names */
-#defineUNIONFS_TMPNAM_LEN  12
-
 /* number of times we try to get a unique temporary file name */
 #define GET_TMPNAM_MAX_RETRY   5
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/16] Unionfs: call statfs on lower file system properly

2007-06-17 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Get the correct lower dentry to use to statfs the first branch (always),

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index b3a5e64..a7ff06c 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -112,18 +112,23 @@ static void unionfs_put_super(struct super_block *sb)
 static int unionfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
int err = 0;
-   struct super_block *sb, *hidden_sb;
+   struct super_block *sb;
+   struct dentry *lower_dentry;
 
BUG_ON(!is_valid_dentry(dentry));
 
sb = dentry-d_sb;
 
-   unionfs_read_lock(sb);
-   hidden_sb = unionfs_lower_super_idx(sb, sbstart(sb));
-   unionfs_read_unlock(sb);
-   err = vfs_statfs(hidden_sb-s_root, buf);
+   lower_dentry = unionfs_lower_dentry(sb-s_root);
+   err = vfs_statfs(lower_dentry, buf);
 
+   /* set return buf to our f/s to avoid confusing user-level utils */
buf-f_type = UNIONFS_SUPER_MAGIC;
+
+   /*
+* Our maximum file name can is shorter by a few bytes because every
+* file name could potentially be whited-out.
+*/
buf-f_namelen -= UNIONFS_WHLEN;
 
memset(buf-f_fsid, 0, sizeof(__kernel_fsid_t));
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -mm] Unionfs: Fix lock leak in unionfs_ioctl

2007-06-03 Thread Josef 'Jeff' Sipek
(This patch is already in the Unionfs git tree. This is just a heads up.)

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 83001aa..1045e51 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -635,7 +635,6 @@ static long do_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
}
 
 out:
-   unionfs_read_unlock(file-f_dentry-d_sb);
return err;
 }
 
@@ -709,6 +708,7 @@ long unionfs_ioctl(struct file *file, unsigned int cmd, 
unsigned long arg)
}
 
 out:
+   unionfs_read_unlock(file-f_dentry-d_sb);
return err;
 }
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] Documentation: Fix up docs still talking about i_sem

2007-05-24 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 Documentation/filesystems/directory-locking |5 +++--
 Documentation/filesystems/porting   |8 
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Documentation/filesystems/directory-locking 
b/Documentation/filesystems/directory-locking
index d7099a9..ff7b611 100644
--- a/Documentation/filesystems/directory-locking
+++ b/Documentation/filesystems/directory-locking
@@ -1,5 +1,6 @@
Locking scheme used for directory operations is based on two
-kinds of locks - per-inode (-i_sem) and per-filesystem (-s_vfs_rename_sem).
+kinds of locks - per-inode (-i_mutex) and per-filesystem
+(-s_vfs_rename_mutex).
 
For our purposes all operations fall in 5 classes:
 
@@ -63,7 +64,7 @@ objects - A  B iff A is an ancestor of B.
 attempt to acquire some lock and already holds at least one lock.  Let's
 consider the set of contended locks.  First of all, filesystem lock is
 not contended, since any process blocked on it is not holding any locks.
-Thus all processes are blocked on -i_sem.
+Thus all processes are blocked on -i_mutex.
 
Non-directory objects are not contended due to (3).  Thus link
 creation can't be a part of deadlock - it can't be blocked on source
diff --git a/Documentation/filesystems/porting 
b/Documentation/filesystems/porting
index 5531694..dac45c9 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -107,7 +107,7 @@ free to drop it...
 ---
 [informational]
 
--link() callers hold -i_sem on the object we are linking to.  Some of your
+-link() callers hold -i_mutex on the object we are linking to.  Some of your
 problems might be over...
 
 ---
@@ -130,9 +130,9 @@ went in - and hadn't been documented ;-/).  Just remove it 
from fs_flags
 ---
 [mandatory]
 
--setattr() is called without BKL now.  Caller _always_ holds -i_sem, so
-watch for -i_sem-grabbing code that might be used by your -setattr().
-Callers of notify_change() need -i_sem now.
+-setattr() is called without BKL now.  Caller _always_ holds -i_mutex, so
+watch for -i_mutex-grabbing code that might be used by your -setattr().
+Callers of notify_change() need -i_mutex now.
 
 ---
 [recommended]
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL -mm] Unionfs cleanups and fixes

2007-05-23 Thread Josef 'Jeff' Sipek
The following patches consist of mostly cleanups of the Unionfs code, as
well as fixes for several harder to hit bugs (resource/memory leaks).

As before, there is a git repo at:

git://git.kernel.org/pub/scm/linux/kernel/git/jsipek/unionfs.git

(master.kernel.org:/pub/scm/linux/kernel/git/jsipek/unionfs.git)

There are 21 new commits:

Unionfs: Correctly decrement refcounts of mnt's upon branch management
Unionfs: Removed a trailing whitespace
Unionfs: Actually catch bad use of unionfs_mnt{get,put}
Unionfs: Remove defunct unionfs_put_inode super op
Unionfs: Documentation update regarding overlapping branches and new 
lookup code
Unionfs: Disallow setting leftmost branch to readonly
Unionfs: Use krealloc instead of open-coding the functionality
Unionfs: Call realloc unconditionally
Unionfs: Don't leak resources when copyup fails partially
Unionfs: Prefix external functions with 'extern' properly
Unionfs: Combine unionfs_write with __unionfs_write.
Unionfs: Move unionfs_query_file to commonfops.c
Unionfs: Rename our do_rename to __unionfs_rename
Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion
Unionfs: Consistent pointer declaration spacing
Unionfs: Added numerous comments
Unionfs: Cleanup of strings and comments
Unionfs: Add missing copyright notices
Unionfs: Every printk should prefix with unionfs:  consistently
Unionfs: Coding style fixes
Unionfs: Tiny documentation fixups

Thanks,

Josef 'Jeff' Sipek [EMAIL PROTECTED]

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/21] Unionfs: Tiny documentation fixups

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 Documentation/filesystems/unionfs/usage.txt |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/filesystems/unionfs/usage.txt 
b/Documentation/filesystems/unionfs/usage.txt
index 13fbcea..1c7554b 100644
--- a/Documentation/filesystems/unionfs/usage.txt
+++ b/Documentation/filesystems/unionfs/usage.txt
@@ -81,10 +81,10 @@ CACHE CONSISTENCY
 If you modify any file on any of the lower branches directly, while there is
 a Unionfs 2.0 mounted above any of those branches, you should tell Unionfs
 to purge its caches and re-get the objects.  To do that, you have to
-incremenet the generation number of the superblock using the following
+increment the generation number of the superblock using the following
 command:
 
-# mount -t unionfs -o remount,remount,incgen none MOUNTPOINT
+# mount -t unionfs -o remount,incgen none MOUNTPOINT
 
 
 For more information, see http://unionfs.filesystems.org/.
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/21] Unionfs: Every printk should prefix with unionfs: consistently

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |7 ---
 fs/unionfs/copyup.c |2 +-
 fs/unionfs/dentry.c |8 +---
 fs/unionfs/inode.c  |   15 ---
 fs/unionfs/lookup.c |5 +++--
 fs/unionfs/main.c   |8 
 fs/unionfs/rdstate.c|4 ++--
 fs/unionfs/rename.c |   30 +++---
 fs/unionfs/sioq.c   |2 +-
 fs/unionfs/subr.c   |4 ++--
 fs/unionfs/super.c  |8 
 11 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 9cf6b81..778901f 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -355,8 +355,8 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
if (willwrite  IS_WRITE_FLAG(file-f_flags) 
!IS_WRITE_FLAG(unionfs_lower_file(file)-f_flags) 
is_robranch(dentry)) {
-   printk(KERN_DEBUG Doing delayed copyup of a read-write 
-  file on a read-only branch.\n);
+   printk(KERN_DEBUG unionfs: Doing delayed copyup of a 
+  read-write file on a read-only branch.\n);
err = do_delayed_copyup(file, dentry);
}
 
@@ -576,7 +576,8 @@ int unionfs_file_release(struct inode *inode, struct file 
*file)
 
if (fileinfo-rdstate) {
fileinfo-rdstate-access = jiffies;
-   printk(KERN_DEBUG Saving rdstate with cookie %u [%d.%lld]\n,
+   printk(KERN_DEBUG unionfs: saving rdstate with cookie 
+  %u [%d.%lld]\n,
   fileinfo-rdstate-cookie,
   fileinfo-rdstate-bindex,
   (long long)fileinfo-rdstate-dirpos);
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 502a40f..8fae308 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -183,7 +183,7 @@ static int __copyup_ndentry(struct dentry 
*old_hidden_dentry,
run_sioq(__unionfs_create, args);
err = args.err;
} else {
-   printk(KERN_ERR Unknown inode type %d\n,
+   printk(KERN_ERR unionfs: unknown inode type %d\n,
   old_mode);
BUG();
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 067732c..463cf4c 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -48,7 +48,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
 
/* if the dentry is unhashed, do NOT revalidate */
if (d_deleted(dentry)) {
-   printk(KERN_DEBUG unhashed dentry being revalidated: %*s\n,
+   printk(KERN_DEBUG unionfs: unhashed dentry being 
+  revalidated: %*s\n,
   dentry-d_name.len, dentry-d_name.name);
goto out;
}
@@ -297,12 +298,13 @@ static void unionfs_d_release(struct dentry *dentry)
 
/* this could be a negative dentry, so check first */
if (!UNIONFS_D(dentry)) {
-   printk(KERN_DEBUG dentry without private data: %.*s,
+   printk(KERN_DEBUG unionfs: dentry without private data: %.*s,
   dentry-d_name.len, dentry-d_name.name);
goto out;
} else if (dbstart(dentry)  0) {
/* this is due to a failed lookup */
-   printk(KERN_DEBUG dentry without hidden dentries : %.*s,
+   printk(KERN_DEBUG unionfs: dentry without hidden 
+  dentries: %.*s,
   dentry-d_name.len, dentry-d_name.name);
goto out_free;
}
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 0b9cb29..f0616ed 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -463,8 +463,9 @@ static int unionfs_symlink(struct inode *dir, struct dentry 
*dentry,
if (IS_ERR(hidden_dentry))
err = PTR_ERR(hidden_dentry);
 
-   printk(KERN_DEBUG hidden dentry NULL (or 
error)
-  for bindex = %d\n, bindex);
+   printk(KERN_DEBUG unionfs: hidden dentry 
+  NULL (or error) for bindex = %d\n,
+  bindex);
continue;
}
}
@@ -585,8 +586,8 @@ static int unionfs_mkdir(struct inode *parent, struct 
dentry *dentry, int mode)
if (!hidden_dentry) {
hidden_dentry = create_parents(parent, dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
-   printk(KERN_DEBUG hidden dentry NULL for 
-  bindex = %d\n, bindex

[PATCH 21/21] Unionfs: Correctly decrement refcounts of mnt's upon branch management

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

The old logic was broken in one place, which another place tried to fix
incorrectly.  Also added detailed comments to explain the new/correct logic.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |   17 -
 fs/unionfs/dentry.c |   18 +-
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 69d9c87..83001aa 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -135,14 +135,21 @@ static void cleanup_file(struct file *file)
   file %p\n, file);
else {
unionfs_read_lock(sb);
+   /* decrement count of open files */
branchput(sb, i);
unionfs_read_unlock(sb);
-   /* XXX: is it OK to use sb-s_root here? */
-   unionfs_mntput(sb-s_root, i);
-   /* mntget b/c fput below will call mntput */
-   unionfs_mntget(sb-s_root, bindex);
+   /*
+* fput will perform an mntput for us on the
+* correct branch.  Although we're using the
+* file's old branch configuration, bindex,
+* which is the old index, correctly points
+* to the right branch in the file's branch
+* list.  In other words, we're going to
+* mntput the correct branch even if
+* branches have been added/removed.
+*/
+   fput(unionfs_lower_file_idx(file, bindex));
}
-   fput(unionfs_lower_file_idx(file, bindex));
}
}
 
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 95cea3b..db0ef43 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -258,14 +258,22 @@ out_this:
/* finally, lock this dentry and revalidate it */
verify_locked(dentry);
dgen = atomic_read(UNIONFS_D(dentry)-generation);
-   saved_bstart = dbstart(dentry);
-   saved_bend = dbend(dentry);
valid = __unionfs_d_revalidate_one(dentry, nd);
 
-   if (valid  chain_len  0  sbgen != dgen) {
-   for (bindex = saved_bstart; bindex = saved_bend; bindex++)
+   /*
+* If __unionfs_d_revalidate_one() succeeded above, then it will
+* have incremented the refcnt of the mnt's, but also the branch
+* indices of the dentry will have been updated (to take into
+* account any branch insertions/deletion.  So the current
+* dbstart/dbend match the current, and new, indices of the mnts
+* which __unionfs_d_revalidate_one has incremented.  Note: the if
+* test below does not depend on whether chain_len was 0 or greater.
+*/
+   if (valid  sbgen != dgen)
+   for (bindex = dbstart(dentry);
+bindex = dbend(dentry);
+bindex++)
unionfs_mntput(dentry, bindex);
-   }
 
 out_free:
/* unlock/dput all dentries in chain and return status */
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/21] Unionfs: Documentation update regarding overlapping branches and new lookup code

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Added detailed comment and updated documentation to explain why overlapping
branches are disallowed, and better explain the cache coherency issues.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 Documentation/filesystems/unionfs/issues.txt |   16 
 fs/unionfs/main.c|   16 +++-
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/Documentation/filesystems/unionfs/issues.txt 
b/Documentation/filesystems/unionfs/issues.txt
index a434fee..c634604 100644
--- a/Documentation/filesystems/unionfs/issues.txt
+++ b/Documentation/filesystems/unionfs/issues.txt
@@ -5,14 +5,14 @@ KNOWN Unionfs 2.0 ISSUES:
This means we can't reliably detect a read-only NFS export.
 
 2. Modifying a Unionfs branch directly, while the union is mounted, is
-   currently unsupported.  We have tested Unionfs under such conditions, and
-   fixed any bugs we found (Unionfs comes with an extensive regression test
-   suite).  However, it may still be possible that changes made to lower
-   branches directly could cause cache incoherency which, in the worst case,
-   may case an oops.  We are currently addressing this problem for Unionfs
-   and also generically for all stackable file systems, by handing mmap and
-   introducing small VFS/MM changes that would allow a file system to handle
-   cache coherency correctly.
+   currently unsupported, because it could cause a cache incoherency between
+   the union layer and the lower file systems (for that reason, Unionfs
+   currently prohibits using branches which overlap with each other, even
+   partially).  We have tested Unionfs under such conditions, and fixed any
+   bugs we found (Unionfs comes with an extensive regression test suite).
+   However, it may still be possible that changes made to lower branches
+   directly could cause cache incoherency which, in the worst case, may case
+   an oops.
 
Unionfs 2.0 has a temporary workaround for this.  You can force Unionfs
to increase the superblock generation number, and hence purge all cached
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 84d3bf5..a9ad445 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -351,7 +351,21 @@ static int parse_dirs_option(struct super_block *sb, 
struct unionfs_dentry_info
 
BUG_ON(branches != (hidden_root_info-bend + 1));
 
-   /* ensure that no overlaps exist in the branches */
+   /*
+* Ensure that no overlaps exist in the branches.
+*
+* This test is required because the Linux kernel has no support
+* currently for ensuring coherency between stackable layers and
+* branches.  If we were to allow overlapping branches, it would be
+* possible, for example, to delete a file via one branch, which
+* would not be reflected in another branch.  Such incoherency could
+* lead to inconsistencies and even kernel oopses.  Rather than
+* implement hacks to work around some of these cache-coherency
+* problems, we prevent branch overlapping, for now.  A complete
+* solution will involve proper kernel/VFS support for cache
+* coherency, at which time we could safely remove this
+* branch-overlapping test.
+*/
for (i = 0; i  branches; i++) {
for (j = i + 1; j  branches; j++) {
dent1 = hidden_root_info-lower_paths[i].dentry;
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/21] Unionfs: Add missing copyright notices

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/stack.c   |   11 +++
 fs/unionfs/sioq.c|5 -
 fs/unionfs/sioq.h|   13 +
 include/linux/fs_stack.h |   11 +++
 4 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/fs/stack.c b/fs/stack.c
index 9aee8fc..1f5b161 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
 #include linux/module.h
 #include linux/fs.h
 #include linux/fs_stack.h
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index a1e8ffa..34e25b0 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -1,13 +1,8 @@
 /*
  * Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2003-2006 Charles P. Wright
  * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
  * Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2005  Arun M. Krishnakumar
  * Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
- * Copyright (c) 2003  Puja Gupta
- * Copyright (c) 2003  Harikesavan Krishnan
  * Copyright (c) 2003-2007 Stony Brook University
  * Copyright (c) 2003-2007 The Research Foundation of SUNY
  *
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 4827514..dd6c44b 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -1,3 +1,16 @@
+/*
+ * Copyright (c) 2003-2007 Erez Zadok
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2005-2006 Junjiro Okajima
+ * Copyright (c) 2004-2006 David P. Quigley
+ * Copyright (c) 2003-2007 Stony Brook University
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
 #ifndef _SIOQ_H
 #define _SIOQ_H
 
diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index 2fe2387..9a896d6 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
 #ifndef _LINUX_FS_STACK_H
 #define _LINUX_FS_STACK_H
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/21] Unionfs: Use krealloc instead of open-coding the functionality

2007-05-23 Thread Josef 'Jeff' Sipek
Change the branch management code to use krealloc instead of playing tricks
with kmalloc/memcpy/kfree.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   56 +---
 1 files changed, 14 insertions(+), 42 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index b7f0b45..3dee863 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -427,6 +427,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
struct unionfs_data *new_data = NULL, *tmp_data = NULL;
struct path *new_lower_paths = NULL, *tmp_lower_paths = NULL;
int new_high_branch_id; /* new high branch ID */
+   int size;   /* memory allocation size, temp var */
 
unionfs_write_lock(sb);
 
@@ -634,49 +635,20 @@ out_no_change:
 * Also handle invalidating any pages that will have to be re-read.
 ***/
 
-   /*
-* Allocate space for actual pointers, if needed.  By the time we
-* finish this block of code, new_branches and new_lower_paths will
-* have the correct size.  None of this code below would be needed
-* if the kernel had a realloc() function, at least one capable of
-* shrinking/truncating an allocation's size (hint, hint).
-*/
-   if (new_branches  max_branches) {
+   /* (re)allocate space for new pointers to hidden dentry */
+   size = new_branches * sizeof(struct unionfs_data);
+   new_data = krealloc(tmp_data, size, GFP_KERNEL);
+   if (!new_data) {
+   err = -ENOMEM;
+   goto out_release;
+   }
 
-   /* allocate space for new pointers to hidden dentry */
-   new_data = kcalloc(new_branches,
-  sizeof(struct unionfs_data), GFP_KERNEL);
-   if (!new_data) {
-   err = -ENOMEM;
-   goto out_release;
-   }
-   /* allocate space for new pointers to lower paths */
-   new_lower_paths = kcalloc(new_branches,
- sizeof(struct path), GFP_KERNEL);
-   if (!new_lower_paths) {
-   err = -ENOMEM;
-   goto out_release;
-   }
-   /*
-* copy current info into new placeholders, incrementing
-* refcounts.
-*/
-   memcpy(new_data, tmp_data,
-  new_branches * sizeof(struct unionfs_data));
-   memcpy(new_lower_paths, tmp_lower_paths,
-  new_branches * sizeof(struct path));
-   /*
-* Since we already hold various refcnts on the objects, we
-* don't need to redo it here.  Just free the older memory
-* and re-point the pointers.
-*/
-   kfree(tmp_data);
-   kfree(tmp_lower_paths);
-   /* no need to nullify pointers here */
-   } else {
-   /* number of branches didn't change, no need to re-alloc */
-   new_data = tmp_data;
-   new_lower_paths = tmp_lower_paths;
+   /* allocate space for new pointers to lower paths */
+   size = new_branches * sizeof(struct path);
+   new_lower_paths = krealloc(tmp_lower_paths, size, GFP_KERNEL);
+   if (!new_lower_paths) {
+   err = -ENOMEM;
+   goto out_release;
}
 
/*
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/21] Unionfs: Removed a trailing whitespace

2007-05-23 Thread Josef 'Jeff' Sipek
From: Yiannis Pericleous [EMAIL PROTECTED]

Signed-off-by: Yiannis Pericleous [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index bfd6c24..fe02941 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -699,10 +699,12 @@ out_no_change:
i = atomic_inc_return(UNIONFS_SB(sb)-generation);
atomic_set(UNIONFS_D(sb-s_root)-generation, i);
atomic_set(UNIONFS_I(sb-s_root-d_inode)-generation, i);
-   if (!(*flags  MS_SILENT)) 
-   printk(unionfs: new generation number %d\n, i);
+
err = 0;/* reset to success */
 
+   if (!(*flags  MS_SILENT))
+   printk(unionfs: new generation number %d\n, i);
+
/*
 * The code above falls through to the next label, and releases the
 * refcnts of the older ones (stored in tmp_*): if we fell through
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/21] Unionfs: Actually catch bad use of unionfs_mnt{get,put}

2007-05-23 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/union.h |   34 +++---
 1 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 5376b76..335d579 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -459,38 +459,18 @@ static inline void unlock_dir(struct dentry *dir)
 static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
  int bindex)
 {
-   struct vfsmount *mnt;
+   BUG_ON(!dentry || bindex  0);
 
-   if (!dentry) {
-   if (bindex  0)
-   return NULL;
-   BUG_ON(bindex  0);
-   }
-   mnt = unionfs_lower_mnt_idx(dentry, bindex);
-   if (!mnt) {
-   if (bindex  0)
-   return NULL;
-   BUG_ON(mnt  bindex  0);
-   }
-   mnt = mntget(mnt);
-   return mnt;
+   return mntget(unionfs_lower_mnt_idx(dentry, bindex));
 }
 
 static inline void unionfs_mntput(struct dentry *dentry, int bindex)
 {
-   struct vfsmount *mnt;
+   if (!dentry)
+   return;
 
-   if (!dentry) {
-   if (bindex  0)
-   return;
-   BUG_ON(dentry  bindex  0);
-   }
-   mnt = unionfs_lower_mnt_idx(dentry, bindex);
-   if (!mnt) {
-   if (bindex  0)
-   return;
-   BUG_ON(mnt  bindex  0);
-   }
-   mntput(mnt);
+   BUG_ON(bindex  0);
+
+   mntput(unionfs_lower_mnt_idx(dentry, bindex));
 }
 #endif /* not _UNION_H_ */
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/21] Unionfs: Consistent pointer declaration spacing

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Change instances of foo * var to foo *var for consistency.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/copyup.c |6 +++---
 fs/unionfs/file.c   |   14 +++---
 fs/unionfs/inode.c  |2 +-
 fs/unionfs/super.c  |2 +-
 fs/unionfs/xattr.c  |4 ++--
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 4924685..0975b6e 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -541,7 +541,7 @@ struct dentry *create_parents(struct inode *dir, struct 
dentry *dentry,
 }
 
 /* purge a dentry's lower-branch states (dput/mntput, etc.) */
-static void __cleanup_dentry(struct dentry * dentry, int bindex,
+static void __cleanup_dentry(struct dentry *dentry, int bindex,
 int old_bstart, int old_bend)
 {
int loop_start;
@@ -592,7 +592,7 @@ static void __cleanup_dentry(struct dentry * dentry, int 
bindex,
 }
 
 /* set lower inode ptr and update bstart  bend if necessary */
-static void __set_inode(struct dentry * upper, struct dentry * lower,
+static void __set_inode(struct dentry *upper, struct dentry *lower,
int bindex)
 {
unionfs_set_lower_inode_idx(upper-d_inode, bindex,
@@ -605,7 +605,7 @@ static void __set_inode(struct dentry * upper, struct 
dentry * lower,
 }
 
 /* set lower dentry ptr and update bstart  bend if necessary */
-static void __set_dentry(struct dentry * upper, struct dentry * lower,
+static void __set_dentry(struct dentry *upper, struct dentry *lower,
 int bindex)
 {
unionfs_set_lower_dentry_idx(upper, bindex, lower);
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 57f2bdd..1dfcfcb 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -53,8 +53,8 @@ out:
return err;
 }
 
-static 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 +78,8 @@ out:
 }
 
 /* helper function to unionfs_write */
-static 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 +123,8 @@ out:
return err;
 }
 
-static 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;
 
@@ -145,7 +145,7 @@ static int unionfs_file_readdir(struct file *file, void 
*dirent,
return -ENOTDIR;
 }
 
-static unsigned int unionfs_poll(struct file *file, poll_table * wait)
+static unsigned int unionfs_poll(struct file *file, poll_table *wait)
 {
unsigned int mask = DEFAULT_POLLMASK;
struct file *hidden_file = NULL;
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 2d0822a..c54b290 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -768,7 +768,7 @@ out:
return err;
 }
 
-static int unionfs_readlink(struct dentry *dentry, char __user * buf,
+static int unionfs_readlink(struct dentry *dentry, char __user *buf,
int bufsiz)
 {
int err;
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 39939ba..b7f0b45 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -824,7 +824,7 @@ static void unionfs_destroy_inode(struct inode *inode)
 }
 
 /* unionfs inode cache constructor */
-static void init_once(void *v, struct kmem_cache * cachep, unsigned long flags)
+static void init_once(void *v, struct kmem_cache *cachep, unsigned long flags)
 {
struct unionfs_inode_info *i = v;
 
diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 4dc8ada..12d618b 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@ -51,7 +51,7 @@ void unionfs_xattr_free(void *ptr, size_t size)
  * BKL held by caller.
  * dentry-d_inode-i_mutex locked
  */
-ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
+ssize_t unionfs_getxattr(struct dentry *dentry, const char *name, void *value,
 size_t size)
 {
struct dentry *hidden_dentry = NULL;
@@ -115,7 +115,7 @@ int unionfs_removexattr(struct dentry *dentry, const char 
*name)
  * BKL held by caller.
  * dentry-d_inode-i_mutex locked
  */
-ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
+ssize_t unionfs_listxattr(struct dentry *dentry, char *list, size_t size)
 {
struct dentry

[PATCH 16/21] Unionfs: Disallow setting leftmost branch to readonly

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Unionfs requires the leftmost branch to be writeable for copyup to work
properly and simply.  If, through branch-management commands (add, delete,
or mode change), the leftmost branch will becomes readonly, then return an
error (and tell the user to use remount,ro if they want a readonly union).

[jsipek: fixed up to apply cleanly]
Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 3dee863..446faf8 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -629,12 +629,20 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
 out_no_change:
 
/**
-* WE'RE ALMOST DONE: see if we need to allocate a small-sized new
-* vector, copy the vectors to their correct place, release the
-* refcnt of the older ones, and return.
-* Also handle invalidating any pages that will have to be re-read.
+* WE'RE ALMOST DONE: check if leftmost branch might be read-only,
+* see if we need to allocate a small-sized new vector, copy the
+* vectors to their correct place, release the refcnt of the older
+* ones, and return.  Also handle invalidating any pages that will
+* have to be re-read.
 ***/
 
+   if (!(tmp_data[0].branchperms  MAY_WRITE)) {
+   printk(unionfs: leftmost branch cannot be read-only 
+  (use \remount,ro\ to create a read-only union)\n);
+   err = -EINVAL;
+   goto out_release;
+   }
+
/* (re)allocate space for new pointers to hidden dentry */
size = new_branches * sizeof(struct unionfs_data);
new_data = krealloc(tmp_data, size, GFP_KERNEL);
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/21] Unionfs: Combine unionfs_write with __unionfs_write.

2007-05-23 Thread Josef 'Jeff' Sipek
The __unionfs_write helper function was used only by unionfs_write, and
there is really no reason why they should not be combined.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/file.c |   30 ++
 1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 1dfcfcb..2e5ec42 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -77,17 +77,20 @@ out:
return err;
 }
 
-/* helper function to unionfs_write */
-static 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;
+   int err;
struct file *hidden_file = NULL;
struct inode *inode;
struct inode *hidden_inode;
loff_t pos = *ppos;
int bstart, bend;
 
+   unionfs_read_lock(file-f_dentry-d_sb);
+   if ((err = unionfs_file_revalidate(file, 1)))
+   goto out;
+
inode = file-f_dentry-d_inode;
 
bstart = fbstart(file);
@@ -98,8 +101,10 @@ static ssize_t __unionfs_write(struct file *file, const 
char __user *buf,
hidden_file = unionfs_lower_file(file);
hidden_inode = hidden_file-f_dentry-d_inode;
 
-   if (!hidden_file-f_op || !hidden_file-f_op-write)
+   if (!hidden_file-f_op || !hidden_file-f_op-write) {
+   err = -EINVAL;
goto out;
+   }
 
/* adjust for append -- seek to the end of the file */
if (file-f_flags  O_APPEND)
@@ -120,21 +125,6 @@ static ssize_t __unionfs_write(struct file *file, const 
char __user *buf,
if (pos  inode-i_size)
inode-i_size = pos;
 out:
-   return err;
-}
-
-static ssize_t unionfs_write(struct file *file, const char __user *buf,
-size_t count, loff_t *ppos)
-{
-   int err = 0;
-
-   unionfs_read_lock(file-f_dentry-d_sb);
-   if ((err = unionfs_file_revalidate(file, 1)))
-   goto out;
-
-   err = __unionfs_write(file, buf, count, ppos);
-
-out:
unionfs_read_unlock(file-f_dentry-d_sb);
return err;
 }
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/21] Unionfs: Prefix external functions with 'extern' properly

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/sioq.h  |1 +
 fs/unionfs/union.h |   50 +-
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 5a96f66..55b781e 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -74,6 +74,7 @@ struct sioq_args {
};
 };
 
+/* Extern definitions for SIOQ functions */
 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/union.h b/fs/unionfs/union.h
index dab408f..5376b76 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -183,26 +183,26 @@ struct unionfs_dir_state {
 #include fanout.h
 #include sioq.h
 
-/* Cache creation/deletion routines. */
-void unionfs_destroy_filldir_cache(void);
-int unionfs_init_filldir_cache(void);
-int unionfs_init_inode_cache(void);
-void unionfs_destroy_inode_cache(void);
-int unionfs_init_dentry_cache(void);
-void unionfs_destroy_dentry_cache(void);
+/* externs for cache creation/deletion routines */
+extern void unionfs_destroy_filldir_cache(void);
+extern int unionfs_init_filldir_cache(void);
+extern int unionfs_init_inode_cache(void);
+extern void unionfs_destroy_inode_cache(void);
+extern int unionfs_init_dentry_cache(void);
+extern void unionfs_destroy_dentry_cache(void);
 
 /* Initialize and free readdir-specific  state. */
-int init_rdstate(struct file *file);
-struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int bindex);
-struct unionfs_dir_state *find_rdstate(struct inode *inode, loff_t fpos);
-void free_rdstate(struct unionfs_dir_state *state);
-int add_filldir_node(struct unionfs_dir_state *rdstate, const char *name,
-int namelen, int bindex, int whiteout);
-struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
-  const char *name, int namelen);
-
-struct dentry **alloc_new_dentries(int objs);
-struct unionfs_data *alloc_new_data(int objs);
+extern int init_rdstate(struct file *file);
+extern struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int 
bindex);
+extern struct unionfs_dir_state *find_rdstate(struct inode *inode, loff_t 
fpos);
+extern void free_rdstate(struct unionfs_dir_state *state);
+extern int add_filldir_node(struct unionfs_dir_state *rdstate, const char 
*name,
+   int namelen, int bindex, int whiteout);
+extern struct filldir_node *find_filldir_node(struct unionfs_dir_state 
*rdstate,
+ const char *name, int namelen);
+
+extern struct dentry **alloc_new_dentries(int objs);
+extern struct unionfs_data *alloc_new_data(int objs);
 
 /* We can only use 32-bits of offset for rdstate --- blech! */
 #define DIREOF (0xf)
@@ -236,8 +236,8 @@ static inline void unionfs_double_lock_dentry(struct dentry 
*d1,
 }
 
 extern int new_dentry_private_data(struct dentry *dentry);
-void free_dentry_private_data(struct unionfs_dentry_info *udi);
-void update_bstart(struct dentry *dentry);
+extern void free_dentry_private_data(struct unionfs_dentry_info *udi);
+extern void update_bstart(struct dentry *dentry);
 
 /*
  * EXTERNALS:
@@ -246,6 +246,7 @@ void update_bstart(struct dentry *dentry);
 /* replicates the directory structure up to given dentry in given branch */
 extern struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
 int bindex);
+extern int make_dir_opaque(struct dentry *dir, int bindex);
 
 /* partial lookup */
 extern int unionfs_partial_lookup(struct dentry *dentry);
@@ -304,10 +305,11 @@ extern long unionfs_ioctl(struct file *file, unsigned int 
cmd,
 /* Inode operations */
 extern int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  struct inode *new_dir, struct dentry *new_dentry);
-int unionfs_unlink(struct inode *dir, struct dentry *dentry);
-int unionfs_rmdir(struct inode *dir, struct dentry *dentry);
+extern int unionfs_unlink(struct inode *dir, struct dentry *dentry);
+extern int unionfs_rmdir(struct inode *dir, struct dentry *dentry);
 
-int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd);
+extern int __unionfs_d_revalidate_chain(struct dentry *dentry,
+   struct nameidata *nd);
 
 /* The values for unionfs_interpose's flag. */
 #define INTERPOSE_DEFAULT  0
@@ -454,8 +456,6 @@ static inline void unlock_dir(struct dentry *dir)
dput(dir);
 }
 
-extern int make_dir_opaque(struct dentry *dir, int bindex);
-
 static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
  int bindex)
 {
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body

[PATCH 10/21] Unionfs: Move unionfs_query_file to commonfops.c

2007-05-23 Thread Josef 'Jeff' Sipek
Moved unionfs_query_file closer to its one user in commonfops.c.
Additionally, it can now become static, and branchman.c can be removed as it
is empty.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/Makefile |4 +-
 fs/unionfs/branchman.c  |   60 ---
 fs/unionfs/commonfops.c |   41 
 fs/unionfs/union.h  |6 
 4 files changed, 43 insertions(+), 68 deletions(-)
 delete mode 100644 fs/unionfs/branchman.c

diff --git a/fs/unionfs/Makefile b/fs/unionfs/Makefile
index e6b2e0c..6986d79 100644
--- a/fs/unionfs/Makefile
+++ b/fs/unionfs/Makefile
@@ -1,7 +1,7 @@
 obj-$(CONFIG_UNION_FS) += unionfs.o
 
 unionfs-y := subr.o dentry.o file.o inode.o main.o super.o \
-   branchman.o rdstate.o copyup.o dirhelper.o rename.o \
-   unlink.o lookup.o commonfops.o dirfops.o sioq.o
+   rdstate.o copyup.o dirhelper.o rename.o unlink.o \
+   lookup.o commonfops.o dirfops.o sioq.o
 
 unionfs-$(CONFIG_UNION_FS_XATTR) += xattr.o
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
deleted file mode 100644
index 4545e18..000
--- a/fs/unionfs/branchman.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2003-2006 Charles P. Wright
- * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
- * Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2005  Arun M. Krishnakumar
- * Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
- * Copyright (c) 2003  Puja Gupta
- * Copyright (c) 2003  Harikesavan Krishnan
- * Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of SUNY
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include union.h
-
-/*
- * return to user-space the branch indices containing the file in question
- *
- * We use fd_set and therefore we are limited to the number of the branches
- * to FD_SETSIZE, which is currently 1024 - plenty for most people
- */
-int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
-   unsigned long arg)
-{
-   int err = 0;
-   fd_set branchlist;
-
-   int bstart = 0, bend = 0, bindex = 0;
-   struct dentry *dentry, *hidden_dentry;
-
-   dentry = file-f_dentry;
-   unionfs_lock_dentry(dentry);
-   if ((err = unionfs_partial_lookup(dentry)))
-   goto out;
-   bstart = dbstart(dentry);
-   bend = dbend(dentry);
-
-   FD_ZERO(branchlist);
-
-   for (bindex = bstart; bindex = bend; bindex++) {
-   hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
-   if (!hidden_dentry)
-   continue;
-   if (hidden_dentry-d_inode)
-   FD_SET(bindex, branchlist);
-   }
-
-   err = copy_to_user((void __user *)arg, branchlist, sizeof(fd_set));
-   if (err)
-   err = -EFAULT;
-
-out:
-   unionfs_unlock_dentry(dentry);
-   return err  0 ? err : bend;
-}
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index a57471e..69d9c87 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -632,6 +632,47 @@ out:
return err;
 }
 
+/*
+ * return to user-space the branch indices containing the file in question
+ *
+ * We use fd_set and therefore we are limited to the number of the branches
+ * to FD_SETSIZE, which is currently 1024 - plenty for most people
+ */
+static int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
+  unsigned long arg)
+{
+   int err = 0;
+   fd_set branchlist;
+
+   int bstart = 0, bend = 0, bindex = 0;
+   struct dentry *dentry, *hidden_dentry;
+
+   dentry = file-f_dentry;
+   unionfs_lock_dentry(dentry);
+   if ((err = unionfs_partial_lookup(dentry)))
+   goto out;
+   bstart = dbstart(dentry);
+   bend = dbend(dentry);
+
+   FD_ZERO(branchlist);
+
+   for (bindex = bstart; bindex = bend; bindex++) {
+   hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
+   if (!hidden_dentry)
+   continue;
+   if (hidden_dentry-d_inode)
+   FD_SET(bindex, branchlist);
+   }
+
+   err = copy_to_user((void __user *)arg, branchlist, sizeof(fd_set));
+   if (err)
+   err = -EFAULT;
+
+out:
+   unionfs_unlock_dentry(dentry);
+   return err  0 ? err : bend;
+}
+
 long unionfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
long err;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index fee4f88..dab408f 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -319,12 +319,6 @@ int __unionfs_d_revalidate_chain(struct dentry

[PATCH 09/21] Unionfs: Rename our do_rename to __unionfs_rename

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

To avoid confusion with the VFS function do_rename, and to help ctags,
rename our utility (static) function do_rename to __unionfs_rename.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/rename.c |   21 +++--
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 0e1e71a..edc5a5c 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -18,9 +18,9 @@
 
 #include union.h
 
-static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
-struct inode *new_dir, struct dentry *new_dentry,
-int bindex, struct dentry **wh_old)
+static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+   struct inode *new_dir, struct dentry *new_dentry,
+   int bindex, struct dentry **wh_old)
 {
int err = 0;
struct dentry *hidden_old_dentry;
@@ -144,7 +144,7 @@ out:
 /*
  * Main rename code.  This is sufficienly complex, that it's documented in
  * Docmentation/filesystems/unionfs/rename.txt.  This routine calls
- * do_rename() above to perform some of the work.
+ * __unionfs_rename() above to perform some of the work.
  */
 static int do_unionfs_rename(struct inode *old_dir,
 struct dentry *old_dentry,
@@ -171,8 +171,8 @@ static int do_unionfs_rename(struct inode *old_dir,
new_bend = dbend(new_dentry);
 
/* Rename source to destination. */
-   err = do_rename(old_dir, old_dentry, new_dir, new_dentry, old_bstart,
-   wh_old);
+   err = __unionfs_rename(old_dir, old_dentry, new_dir, new_dentry,
+  old_bstart, wh_old);
if (err) {
if (!IS_COPYUP_ERR(err))
goto out;
@@ -230,8 +230,9 @@ static int do_unionfs_rename(struct inode *old_dir,
if (!err) {
dput(wh_old);
bwh_old = bindex;
-   err = do_rename(old_dir, old_dentry, new_dir,
-   new_dentry, bindex, wh_old);
+   err = __unionfs_rename(old_dir, old_dentry,
+  new_dir, new_dentry,
+  bindex, wh_old);
break;
}
}
@@ -306,8 +307,8 @@ revert:
goto revert_out;
}
 
-   local_err = do_rename(new_dir, new_dentry,
- old_dir, old_dentry, old_bstart, NULL);
+   local_err = __unionfs_rename(new_dir, new_dentry,
+old_dir, old_dentry, old_bstart, NULL);
 
/* If we can't fix it, then we cop-out with -EIO. */
if (local_err) {
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/21] Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

To avoid potential confusion with a VFS function, rename our version of
double_lock_dentry to unionfs_double_lock_dentry.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/inode.c  |2 +-
 fs/unionfs/rename.c |2 +-
 fs/unionfs/union.h  |3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index c54b290..627c2a7 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -265,7 +265,7 @@ static int unionfs_link(struct dentry *old_dentry, struct 
inode *dir,
BUG_ON(!is_valid_dentry(new_dentry));
BUG_ON(!is_valid_dentry(old_dentry));
 
-   double_lock_dentry(new_dentry, old_dentry);
+   unionfs_double_lock_dentry(new_dentry, old_dentry);
 
hidden_new_dentry = unionfs_lower_dentry(new_dentry);
 
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 231866e..0e1e71a 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -400,7 +400,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
BUG_ON(!is_valid_dentry(old_dentry));
BUG_ON(!is_valid_dentry(new_dentry));
 
-   double_lock_dentry(old_dentry, new_dentry);
+   unionfs_double_lock_dentry(old_dentry, new_dentry);
 
if (!S_ISDIR(old_dentry-d_inode-i_mode))
err = unionfs_partial_lookup(old_dentry);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 0ce3a27..fee4f88 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -223,7 +223,8 @@ static inline off_t rdstate2offset(struct unionfs_dir_state 
*buf)
 #define unionfs_write_lock(sb)  down_write(UNIONFS_SB(sb)-rwsem)
 #define unionfs_write_unlock(sb) up_write(UNIONFS_SB(sb)-rwsem)
 
-static inline void double_lock_dentry(struct dentry *d1, struct dentry *d2)
+static inline void unionfs_double_lock_dentry(struct dentry *d1,
+ struct dentry *d2)
 {
if (d2  d1) {
struct dentry *tmp = d1;
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/21] Unionfs: Cleanup of strings and comments

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Includes:
- consistent style for multi-line comments
- spell-check of all strings and comments

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/stack.c   |6 --
 fs/unionfs/branchman.c   |3 ++-
 fs/unionfs/commonfops.c  |   26 +-
 fs/unionfs/copyup.c  |   46 +-
 fs/unionfs/dentry.c  |6 --
 fs/unionfs/dirfops.c |6 --
 fs/unionfs/dirhelper.c   |3 ++-
 fs/unionfs/file.c|2 +-
 fs/unionfs/inode.c   |   45 +
 fs/unionfs/lookup.c  |   39 +--
 fs/unionfs/main.c|   24 
 fs/unionfs/rdstate.c |   15 ++-
 fs/unionfs/rename.c  |   27 +--
 fs/unionfs/sioq.c|3 ++-
 fs/unionfs/sioq.h|2 +-
 fs/unionfs/subr.c|   15 ++-
 fs/unionfs/super.c   |   21 +
 fs/unionfs/union.h   |   17 +++--
 fs/unionfs/xattr.c   |   12 
 include/linux/fs_stack.h |3 ++-
 20 files changed, 207 insertions(+), 114 deletions(-)

diff --git a/fs/stack.c b/fs/stack.c
index 1f5b161..4368d4b 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -13,7 +13,8 @@
 #include linux/fs.h
 #include linux/fs_stack.h
 
-/* does _NOT_ require i_mutex to be held.
+/*
+ * does _NOT_ require i_mutex to be held.
  *
  * This function cannot be inlined since i_size_{read,write} is rather
  * heavy-weight on 32-bit systems
@@ -25,7 +26,8 @@ void fsstack_copy_inode_size(struct inode *dst, const struct 
inode *src)
 }
 EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
 
-/* copy all attributes; get_nlinks is optional way to override the i_nlink
+/*
+ * copy all attributes; get_nlinks is optional way to override the i_nlink
  * copying
  */
 void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
index eba2221..4545e18 100644
--- a/fs/unionfs/branchman.c
+++ b/fs/unionfs/branchman.c
@@ -18,7 +18,8 @@
 
 #include union.h
 
-/* return to userspace the branch indices containing the file in question
+/*
+ * return to user-space the branch indices containing the file in question
  *
  * We use fd_set and therefore we are limited to the number of the branches
  * to FD_SETSIZE, which is currently 1024 - plenty for most people
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 778901f..666b3c7 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -18,7 +18,8 @@
 
 #include union.h
 
-/* 1) Copyup the file
+/*
+ * 1) Copyup the file
  * 2) Rename the file to '.unionfsoriginal inode#counter' - obviously
  * stolen from NFS's silly rename
  */
@@ -111,7 +112,8 @@ static int find_new_branch_index(struct file *file, int 
bindex,
return -1;
 }
 
-/* put all references held by upper struct file and free lower file pointer
+/*
+ * put all references held by upper struct file and free lower file pointer
  * array
  */
 static void cleanup_file(struct file *file)
@@ -129,7 +131,7 @@ static void cleanup_file(struct file *file)
int i;  /* holds (possibly) updated branch index */
i = find_new_branch_index(file, bindex, sb);
if (i  0)
-   printk(KERN_ERR unionfs: no supberlock for 
+   printk(KERN_ERR unionfs: no superblock for 
   file %p\n, file);
else {
unionfs_read_lock(sb);
@@ -308,7 +310,8 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 
BUG_ON(sbgen  dgen);
 
-   /* There are two cases we are interested in.  The first is if the
+   /*
+* There are two cases we are interested in.  The first is if the
 * generation is lower than the super-block.  The second is if someone
 * has copied up this file from underneath us, we also need to refresh
 * things.
@@ -397,7 +400,8 @@ static int __open_dir(struct inode *inode, struct file 
*file)
 
unionfs_set_lower_file_idx(file, bindex, hidden_file);
 
-   /* The branchget goes after the open, because otherwise
+   /*
+* The branchget goes after the open, because otherwise
 * we would miss the reference on release.
 */
unionfs_read_lock(inode-i_sb);
@@ -422,11 +426,13 @@ static int __open_file(struct inode *inode, struct file 
*file)
bstart = fbstart(file) = dbstart(file-f_dentry);
bend = fbend(file) = dbend(file-f_dentry);
 
-   /* check for the permission for hidden file.  If the error is
+   /*
+* check for the permission for hidden

[PATCH 06/21] Unionfs: Added numerous comments

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Audited entire code for documentation.  Added comments at top of functions
where it felt necessary (i.e., function's name and size don't make it clear
what it may be doing precisely).  Reformatted some long comments.  Fixed a
few comment typos and spelling errors.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/commonfops.c |7 ---
 fs/unionfs/copyup.c |   22 --
 fs/unionfs/dentry.c |5 ++---
 fs/unionfs/file.c   |1 +
 fs/unionfs/lookup.c |3 ++-
 fs/unionfs/main.c   |8 +++-
 fs/unionfs/rename.c |   13 +
 fs/unionfs/subr.c   |   19 ++-
 fs/unionfs/super.c  |   15 +--
 9 files changed, 56 insertions(+), 37 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 666b3c7..a57471e 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -240,6 +240,7 @@ out:
return err;
 }
 
+/* perform a delayed copyup of a read-write file on a read-only branch */
 static int do_delayed_copyup(struct file *file, struct dentry *dentry)
 {
int bindex, bstart, bend, err = 0;
@@ -312,9 +313,9 @@ int unionfs_file_revalidate(struct file *file, int 
willwrite)
 
/*
 * There are two cases we are interested in.  The first is if the
-* generation is lower than the super-block.  The second is if someone
-* has copied up this file from underneath us, we also need to refresh
-* things.
+* generation is lower than the super-block.  The second is if
+* someone has copied up this file from underneath us, we also need
+* to refresh things.
 */
if (!d_deleted(dentry) 
(sbgen  fgen || dbstart(dentry) != fbstart(file))) {
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 1495778..4924685 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -18,6 +18,12 @@
 
 #include union.h
 
+/*
+ * For detailed explanation of copyup see:
+ * Documentation/filesystems/unionfs/concepts.txt
+ */
+
+/* forward definitions */
 static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
   int bstart, int new_bindex, const char *name,
   int namelen, struct file **copyup_file,
@@ -26,11 +32,6 @@ 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,
@@ -487,9 +488,9 @@ out:
 }
 
 /*
- * This function creates a copy of a file represented by 'file' which currently
- * resides in branch 'bstart' to branch 'new_bindex.'  The copy will be named
- * name.
+ * This function creates a copy of a file represented by 'file' which
+ * currently resides in branch 'bstart' to branch 'new_bindex.'  The copy
+ * will be named name.
  */
 int copyup_named_file(struct inode *dir, struct file *file, char *name,
  int bstart, int new_bindex, loff_t len)
@@ -509,8 +510,8 @@ int copyup_named_file(struct inode *dir, struct file *file, 
char *name,
 }
 
 /*
- * This function creates a copy of a file represented by 'file' which currently
- * resides in branch 'bstart' to branch 'new_bindex'.
+ * This function creates a copy of a file represented by 'file' which
+ * currently resides in branch 'bstart' to branch 'new_bindex'.
  */
 int copyup_file(struct inode *dir, struct file *file, int bstart,
int new_bindex, loff_t len)
@@ -539,6 +540,7 @@ struct dentry *create_parents(struct inode *dir, struct 
dentry *dentry,
return create_parents_named(dir, dentry, dentry-d_name.name, bindex);
 }
 
+/* purge a dentry's lower-branch states (dput/mntput, etc.) */
 static void __cleanup_dentry(struct dentry * dentry, int bindex,
 int old_bstart, int old_bend)
 {
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 46a52f7..95cea3b 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -18,7 +18,6 @@
 
 #include union.h
 
-
 /*
  * Revalidate a single dentry.
  * Assume that dentry's info node is locked.
@@ -61,8 +60,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
sbgen = atomic_read(UNIONFS_SB(dentry-d_sb)-generation);
/*
 * If we are working on an unconnected dentry, then there is no
-* revalidation to be done, because this file does not exist within the
-* namespace, and Unionfs operates on the namespace, not data.
+* revalidation to be done, because this file does not exist within
+* the namespace

[PATCH 14/21] Unionfs: Call realloc unconditionally

2007-05-23 Thread Josef 'Jeff' Sipek
krealloc already checks if the new size is greater than the old size.
Therefore, we can call realloc unconditionally - making the code simpler and
cleaner.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/lookup.c |   26 --
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index cf78c46..758c813 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -451,17 +451,17 @@ void free_dentry_private_data(struct unionfs_dentry_info 
*udi)
 /* allocate new dentry private data, free old one if necessary */
 int new_dentry_private_data(struct dentry *dentry)
 {
-   int new_size;
int size;
struct unionfs_dentry_info *info = UNIONFS_D(dentry);
+   void *p;
int unlock_on_err = 0;
 
spin_lock(dentry-d_lock);
if (!info) {
dentry-d_fsdata = kmem_cache_alloc(unionfs_dentry_cachep,
GFP_ATOMIC);
+   
info = UNIONFS_D(dentry);
-
if (!info)
goto out;
 
@@ -470,9 +470,7 @@ int new_dentry_private_data(struct dentry *dentry)
unlock_on_err = 1;
 
info-lower_paths = NULL;
-   size = 0;
-   } else
-   size = sizeof(struct path) * info-bcount;
+   }
 
info-bstart = -1;
info-bend = -1;
@@ -481,21 +479,13 @@ int new_dentry_private_data(struct dentry *dentry)
atomic_set(info-generation,
   atomic_read(UNIONFS_SB(dentry-d_sb)-generation));
 
-   new_size = sizeof(struct path) * sbmax(dentry-d_sb);
-
-   /*
-* Don't reallocate when we already have enough space.
-*/
-   if (new_size  size) {
-   void *p;
+   size = sizeof(struct path) * sbmax(dentry-d_sb);
 
-   p = krealloc(info-lower_paths, new_size, GFP_ATOMIC);
-   if (!p)
-   goto out_free;
+   p = krealloc(info-lower_paths, size, GFP_ATOMIC);
+   if (!p)
+   goto out_free;
 
-   info-lower_paths = p;
-   size = new_size;
-   }
+   info-lower_paths = p;
memset(info-lower_paths, 0, size);
 
spin_unlock(dentry-d_lock);
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/21] Unionfs: Don't leak resources when copyup fails partially

2007-05-23 Thread Josef 'Jeff' Sipek
Original-patch-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/copyup.c |   24 ++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 0975b6e..a80ece6 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -632,7 +632,7 @@ static struct dentry *create_parents_named(struct inode 
*dir,
unsigned int childnamelen;
 
int nr_dentry;
-   int count;
+   int count = 0;
 
int old_bstart;
int old_bend;
@@ -660,7 +660,6 @@ static struct dentry *create_parents_named(struct inode 
*dir,
/* assume the negative dentry of unionfs as the parent dentry */
parent_dentry = dentry;
 
-   count = 0;
/*
 * This loop finds the first parent that exists in the given branch.
 * We start building the directory structure from there.  At the end
@@ -772,6 +771,23 @@ static struct dentry *create_parents_named(struct inode 
*dir,
 hidden_dentry);
unlock_dir(hidden_parent_dentry);
if (err) {
+   struct inode *inode = hidden_dentry-d_inode;
+   /*
+* If we get here, it means that we created a 
new
+* dentry+inode, but copying permissions failed.
+* Therefore, we should delete this inode and 
dput
+* the dentry so as not to leave cruft behind.
+*
+* XXX: call dentry_iput() instead, but then we 
have
+* to export that symbol.
+*/
+   if (hidden_dentry-d_op  
hidden_dentry-d_op-d_iput)
+   
hidden_dentry-d_op-d_iput(hidden_dentry,
+   inode);
+   else
+   iput(inode);
+   hidden_dentry-d_inode = NULL;
+
dput(hidden_dentry);
hidden_dentry = ERR_PTR(err);
goto out;
@@ -786,6 +802,10 @@ static struct dentry *create_parents_named(struct inode 
*dir,
child_dentry = path[--count];
}
 out:
+   /* cleanup any leftover locks from the do/while loop above */
+   if (IS_ERR(hidden_dentry))
+   while (count)
+   unionfs_unlock_dentry(path[count--]);
kfree(path);
return hidden_dentry;
 }
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/21] Unionfs: Remove defunct unionfs_put_inode super op

2007-05-23 Thread Josef 'Jeff' Sipek
From: Erez Zadok [EMAIL PROTECTED]

Removed old workaround code that was needed to get mmap working, is no
longer needed with recent kernels.

Signed-off-by: Erez Zadok [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   20 
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 446faf8..bfd6c24 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -62,25 +62,6 @@ static void unionfs_read_inode(struct inode *inode)
inode-i_mapping-a_ops = unionfs_empty_aops;
 }
 
-static void unionfs_put_inode(struct inode *inode)
-{
-   /*
-* This is really funky stuff:
-*
-* Basically, if i_count == 1, iput will then decrement it and this
-* inode will be destroyed.  It is currently holding a reference to
-* the hidden inode.  Therefore, it needs to release that reference
-* by calling iput on the hidden inode.  iput() _will_ do it for us
-* (by calling our clear_inode), but _only_ if i_nlink == 0.  The
-* problem is, NFS keeps i_nlink == 1 for silly_rename'd files.  So
-* we must force our i_nlink to 0 here to trick iput() into calling
-* our clear_inode.
-*/
-
-   if (atomic_read(inode-i_count) == 1)
-   inode-i_nlink = 0;
-}
-
 /*
  * we now define delete_inode, because there are two VFS paths that may
  * destroy an inode: one of them calls clear inode before doing everything
@@ -938,7 +919,6 @@ out:
 
 struct super_operations unionfs_sops = {
.read_inode = unionfs_read_inode,
-   .put_inode  = unionfs_put_inode,
.delete_inode   = unionfs_delete_inode,
.put_super  = unionfs_put_super,
.statfs = unionfs_statfs,
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] New path lookup function (V4)

2007-05-23 Thread Josef 'Jeff' Sipek
The only change since V3, is the fix for a vfsmount reference leak in the
nfsctl patch (pointed out by hch).

Stackable file systems, among others, frequently need to lookup paths or
path components starting from an arbitrary point in the namespace
(identified by a dentry and a vfsmount).  Currently, such file systems use
lookup_one_len, which is frowned upon [1] as it does not pass the lookup
intent along; not passing a lookup intent, for example, can trigger BUG_ON's
when stacking on top of NFSv4.

The first patch introduces a new lookup function to allow lookup starting
from an arbitrary point in the namespace.  This approach has been suggested
by Christoph Hellwig [2].

The second patch changes sunrpc to use vfs_path_lookup.

The third patch changes nfsctl.c to use vfs_path_lookup.

The fourth patch marks link_path_walk static.

The fifth, and last patch, unexports path_walk because it is no longer
unnecessary to call it directly, and using the new vfs_path_lookup is
cleaner.

For example, the following snippet of code, looks up some/path/component
in a directory pointed to by parent_{dentry,vfsmnt}:

err = vfs_path_lookup(parent_dentry, parent_vfsmnt,
  some/path/component, 0, nd);
if (!err) {
/* exits */

...

/* once done, release the references */
path_release(nd);
} else if (err == -ENOENT) {
/* doesn't exist */
} else {
/* other error */
}

VFS functions such as lookup_create can be used on the nameidata structure
to pass the create intent to the file system.

Josef 'Jeff' Sipek.

[1] http://lkml.org/lkml/2007/3/9/95
[2] http://lkml.org/lkml/2007/5/4/51

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] sunrpc: Use vfs_path_lookup

2007-05-23 Thread Josef 'Jeff' Sipek
use vfs_path_lookup instead of open-coding the necessary functionality.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
Acked-by: Trond Myklebust [EMAIL PROTECTED]
---
 net/sunrpc/rpc_pipe.c |   16 +++-
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 5887457..db6f231 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -451,21 +451,19 @@ void rpc_put_mount(void)
 static int
 rpc_lookup_parent(char *path, struct nameidata *nd)
 {
+   struct vfsmount *mnt;
+
if (path[0] == '\0')
return -ENOENT;
-   nd-mnt = rpc_get_mount();
-   if (IS_ERR(nd-mnt)) {
+
+   mnt = rpc_get_mount();
+   if (IS_ERR(mnt)) {
printk(KERN_WARNING %s: %s failed to mount 
   pseudofilesystem \n, __FILE__, __FUNCTION__);
-   return PTR_ERR(nd-mnt);
+   return PTR_ERR(mnt);
}
-   mntget(nd-mnt);
-   nd-dentry = dget(rpc_mount-mnt_root);
-   nd-last_type = LAST_ROOT;
-   nd-flags = LOOKUP_PARENT;
-   nd-depth = 0;
 
-   if (path_walk(path, nd)) {
+   if (vfs_path_lookup(mnt-mnt_root, mnt, path, LOOKUP_PARENT, nd)) {
printk(KERN_WARNING %s: %s failed to find path %s\n,
__FILE__, __FUNCTION__, path);
rpc_put_mount();
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] fs: Mark link_path_walk static

2007-05-23 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|4 +++-
 include/linux/namei.h |1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index a30efbc..50285a1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -107,6 +107,8 @@
  * any extra contention...
  */
 
+static int fastcall link_path_walk(const char *name, struct nameidata *nd);
+
 /* In order to reduce some races, while at the same time doing additional
  * checking and hopefully speeding things up, we copy filenames to the
  * kernel data space before using them..
@@ -998,7 +1000,7 @@ return_err:
  * Retry the whole path once, forcing real lookup requests
  * instead of relying on the dcache.
  */
-int fastcall link_path_walk(const char *name, struct nameidata *nd)
+static int fastcall link_path_walk(const char *name, struct nameidata *nd)
 {
struct nameidata save = *nd;
int result;
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 4718788..d60a5eb 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -73,7 +73,6 @@ extern int FASTCALL(path_lookup(const char *, unsigned, 
struct nameidata *));
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct nameidata *);
 extern int FASTCALL(path_walk(const char *, struct nameidata *));
-extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
 extern void path_release_on_umount(struct nameidata *);
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] fs: Remove path_walk export

2007-05-23 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|3 +--
 include/linux/namei.h |1 -
 2 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 50285a1..15f45ac 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1024,7 +1024,7 @@ static int fastcall link_path_walk(const char *name, 
struct nameidata *nd)
return result;
 }
 
-int fastcall path_walk(const char * name, struct nameidata *nd)
+static int fastcall path_walk(const char * name, struct nameidata *nd)
 {
current-total_link_count = 0;
return link_path_walk(name, nd);
@@ -2810,7 +2810,6 @@ EXPORT_SYMBOL(page_symlink_inode_operations);
 EXPORT_SYMBOL(path_lookup);
 EXPORT_SYMBOL(vfs_path_lookup);
 EXPORT_SYMBOL(path_release);
-EXPORT_SYMBOL(path_walk);
 EXPORT_SYMBOL(permission);
 EXPORT_SYMBOL(vfs_permission);
 EXPORT_SYMBOL(file_permission);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index d60a5eb..e378e1f 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -72,7 +72,6 @@ extern int FASTCALL(__user_walk_fd(int dfd, const char __user 
*, unsigned, struc
 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct nameidata *);
-extern int FASTCALL(path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
 extern void path_release_on_umount(struct nameidata *);
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] nfsctl: Use vfs_path_lookup

2007-05-23 Thread Josef 'Jeff' Sipek
use vfs_path_lookup instead of open-coding the necessary functionality.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
Acked-by: NeilBrown [EMAIL PROTECTED]
---
 fs/nfsctl.c |   16 ++--
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/fs/nfsctl.c b/fs/nfsctl.c
index c043136..51f1b31 100644
--- a/fs/nfsctl.c
+++ b/fs/nfsctl.c
@@ -23,19 +23,15 @@
 static struct file *do_open(char *name, int flags)
 {
struct nameidata nd;
+   struct vfsmount *mnt;
int error;
 
-   nd.mnt = do_kern_mount(nfsd, 0, nfsd, NULL);
+   mnt = do_kern_mount(nfsd, 0, nfsd, NULL);
+   if (IS_ERR(mnt))
+   return (struct file *)mnt;
 
-   if (IS_ERR(nd.mnt))
-   return (struct file *)nd.mnt;
-
-   nd.dentry = dget(nd.mnt-mnt_root);
-   nd.last_type = LAST_ROOT;
-   nd.flags = 0;
-   nd.depth = 0;
-
-   error = path_walk(name, nd);
+   error = vfs_path_lookup(mnt-mnt_root, mnt, name, 0, nd);
+   mntput(mnt);/* drop do_kern_mount reference */
if (error)
return ERR_PTR(error);
 
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] fs: Introduce vfs_path_lookup

2007-05-23 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|   32 
 include/linux/namei.h |2 ++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 580162b..a30efbc 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1172,6 +1172,37 @@ int fastcall path_lookup(const char *name, unsigned int 
flags,
return do_path_lookup(AT_FDCWD, name, flags, nd);
 }
 
+/**
+ * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
+ * @dentry:  pointer to dentry of the base directory
+ * @mnt: pointer to vfs mount of the base directory
+ * @name: pointer to file name
+ * @flags: lookup flags
+ * @nd: pointer to nameidata
+ */
+int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
+   const char *name, unsigned int flags, 
+   struct nameidata *nd)
+{
+   int retval;
+
+   /* same as do_path_lookup */
+   nd-last_type = LAST_ROOT;
+   nd-flags = flags;
+   nd-depth = 0;
+
+   nd-mnt = mntget(mnt);
+   nd-dentry = dget(dentry);
+
+   retval = path_walk(name, nd);
+   if (unlikely(!retval  !audit_dummy_context()  nd-dentry 
+   nd-dentry-d_inode))
+   audit_inode(name, nd-dentry-d_inode);
+
+   return retval;
+
+}
+
 static int __path_lookup_intent_open(int dfd, const char *name,
unsigned int lookup_flags, struct nameidata *nd,
int open_flags, int create_mode)
@@ -2775,6 +2806,7 @@ EXPORT_SYMBOL(__page_symlink);
 EXPORT_SYMBOL(page_symlink);
 EXPORT_SYMBOL(page_symlink_inode_operations);
 EXPORT_SYMBOL(path_lookup);
+EXPORT_SYMBOL(vfs_path_lookup);
 EXPORT_SYMBOL(path_release);
 EXPORT_SYMBOL(path_walk);
 EXPORT_SYMBOL(permission);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 0ab27ba..4718788 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -70,6 +70,8 @@ extern int FASTCALL(__user_walk_fd(int dfd, const char __user 
*, unsigned, struc
 #define user_path_walk_link(name,nd) \
__user_walk_fd(AT_FDCWD, name, 0, nd)
 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
+  const char *, unsigned int, struct nameidata *);
 extern int FASTCALL(path_walk(const char *, struct nameidata *));
 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
-- 
1.5.2.rc1.165.gaf9b

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fs: Fix indentation in do_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 0262594..48078ea 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1156,11 +1156,9 @@ static int fastcall do_path_lookup(int dfd, const char 
*name,
current-total_link_count = 0;
retval = link_path_walk(name, nd);
 out:
-   if (likely(retval == 0)) {
-   if (unlikely(!audit_dummy_context()  nd  nd-dentry 
-   nd-dentry-d_inode))
+   if (unlikely(!retval  !audit_dummy_context()  nd 
+   nd-dentry  nd-dentry-d_inode))
audit_inode(name, nd-dentry-d_inode);
-   }
 out_fail:
return retval;
 
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/5] fs: Introduce vfs_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|   32 
 include/linux/namei.h |2 ++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 3449e0a..090cce4 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1175,6 +1175,37 @@ int fastcall path_lookup(const char *name, unsigned int 
flags,
return do_path_lookup(AT_FDCWD, name, flags, nd);
 }
 
+/**
+ * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
+ * @dentry:  pointer to dentry of the base directory
+ * @mnt: pointer to vfs mount of the base directory
+ * @name: pointer to file name
+ * @flags: lookup flags
+ * @nd: pointer to nameidata
+ */
+int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
+   const char *name, unsigned int flags, 
+   struct nameidata *nd)
+{
+   int retval;
+
+   /* same as do_path_lookup */
+   nd-last_type = LAST_ROOT;
+   nd-flags = flags;
+   nd-depth = 0;
+
+   nd-mnt = mntget(mnt);
+   nd-dentry = dget(dentry);
+
+   retval = path_walk(name, nd);
+   if (unlikely(!retval  !audit_dummy_context()  nd-dentry 
+   nd-dentry-d_inode))
+   audit_inode(name, nd-dentry-d_inode);
+
+   return retval;
+
+}
+
 static int __path_lookup_intent_open(int dfd, const char *name,
unsigned int lookup_flags, struct nameidata *nd,
int open_flags, int create_mode)
@@ -2799,6 +2830,7 @@ EXPORT_SYMBOL(__page_symlink);
 EXPORT_SYMBOL(page_symlink);
 EXPORT_SYMBOL(page_symlink_inode_operations);
 EXPORT_SYMBOL(path_lookup);
+EXPORT_SYMBOL(vfs_path_lookup);
 EXPORT_SYMBOL(path_release);
 EXPORT_SYMBOL(path_walk);
 EXPORT_SYMBOL(permission);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 0ab27ba..4718788 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -70,6 +70,8 @@ extern int FASTCALL(__user_walk_fd(int dfd, const char __user 
*, unsigned, struc
 #define user_path_walk_link(name,nd) \
__user_walk_fd(AT_FDCWD, name, 0, nd)
 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
+extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
+  const char *, unsigned int, struct nameidata *);
 extern int FASTCALL(path_walk(const char *, struct nameidata *));
 extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/5] fs: Remove path_walk export

2007-05-06 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|3 +--
 include/linux/namei.h |1 -
 2 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index d9eb621..7a98676 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1026,7 +1026,7 @@ static int fastcall link_path_walk(const char *name, 
struct nameidata *nd)
return result;
 }
 
-int fastcall path_walk(const char * name, struct nameidata *nd)
+static int fastcall path_walk(const char * name, struct nameidata *nd)
 {
current-total_link_count = 0;
return link_path_walk(name, nd);
@@ -2835,7 +2835,6 @@ EXPORT_SYMBOL(page_symlink_inode_operations);
 EXPORT_SYMBOL(path_lookup);
 EXPORT_SYMBOL(vfs_path_lookup);
 EXPORT_SYMBOL(path_release);
-EXPORT_SYMBOL(path_walk);
 EXPORT_SYMBOL(permission);
 EXPORT_SYMBOL(vfs_permission);
 EXPORT_SYMBOL(file_permission);
diff --git a/include/linux/namei.h b/include/linux/namei.h
index d60a5eb..e378e1f 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -72,7 +72,6 @@ extern int FASTCALL(__user_walk_fd(int dfd, const char __user 
*, unsigned, struc
 extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct nameidata *);
-extern int FASTCALL(path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
 extern void path_release_on_umount(struct nameidata *);
 
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] sunrpc: Use vfs_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
use vfs_path_lookup instead of open-coding the necessary functionality.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
Acked-by: Trond Myklebust [EMAIL PROTECTED]
---
 net/sunrpc/rpc_pipe.c |   16 +++-
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9b9ea50..2170329 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -451,21 +451,19 @@ void rpc_put_mount(void)
 static int
 rpc_lookup_parent(char *path, struct nameidata *nd)
 {
+   struct vfsmount *mnt;
+
if (path[0] == '\0')
return -ENOENT;
-   nd-mnt = rpc_get_mount();
-   if (IS_ERR(nd-mnt)) {
+
+   mnt = rpc_get_mount();
+   if (IS_ERR(mnt)) {
printk(KERN_WARNING %s: %s failed to mount 
   pseudofilesystem \n, __FILE__, __FUNCTION__);
-   return PTR_ERR(nd-mnt);
+   return PTR_ERR(mnt);
}
-   mntget(nd-mnt);
-   nd-dentry = dget(rpc_mount-mnt_root);
-   nd-last_type = LAST_ROOT;
-   nd-flags = LOOKUP_PARENT;
-   nd-depth = 0;
 
-   if (path_walk(path, nd)) {
+   if (vfs_path_lookup(mnt-mnt_root, mnt, path, LOOKUP_PARENT, nd)) {
printk(KERN_WARNING %s: %s failed to find path %s\n,
__FILE__, __FUNCTION__, path);
rpc_put_mount();
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [TRIVIAL] Small cleanups for do_path_lookup (V2)

2007-05-06 Thread Josef 'Jeff' Sipek
(For changes since V1, see the end of this email.)

The following 2 patches are trivial cleanups to do_path_lookup in namei.c.
Since these changes are trivial, they can go into 2.6.22-rc1 without any
problems.

Josef 'Jeff' Sipek (2):
  fs: Fix indentation in do_path_lookup
  fs: Use path_walk in do_path_lookup

diffstat for good measure:

 fs/namei.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

Josef 'Jeff' Sipek.

Changes since V1:

- Fixed up audit_inode condition (hch)


-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] fs: Use path_walk in do_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
Since, path_walk sets the total_link_count to 0, and calls link_path_walk,
we can just call path_walk directly.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 2a5c232..25aaf8c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1156,8 +1156,8 @@ static int fastcall do_path_lookup(int dfd, const char 
*name,
 
fput_light(file, fput_needed);
}
-   current-total_link_count = 0;
-   retval = link_path_walk(name, nd);
+
+   retval = path_walk(name, nd);
 out:
if (unlikely(!retval  !audit_dummy_context()  nd-dentry 
nd-dentry-d_inode))
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] fs: Fix indentation in do_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 7a98676..2a5c232 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1159,11 +1159,9 @@ static int fastcall do_path_lookup(int dfd, const char 
*name,
current-total_link_count = 0;
retval = link_path_walk(name, nd);
 out:
-   if (likely(retval == 0)) {
-   if (unlikely(!audit_dummy_context()  nd  nd-dentry 
+   if (unlikely(!retval  !audit_dummy_context()  nd-dentry 
nd-dentry-d_inode))
audit_inode(name, nd-dentry-d_inode);
-   }
 out_fail:
return retval;
 
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/5] fs: Mark link_path_walk static

2007-05-06 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c|4 +++-
 include/linux/namei.h |1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 090cce4..925c62e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -108,6 +108,8 @@
  * any extra contention...
  */
 
+static int fastcall link_path_walk(const char *name, struct nameidata *nd);
+
 /* In order to reduce some races, while at the same time doing additional
  * checking and hopefully speeding things up, we copy filenames to the
  * kernel data space before using them..
@@ -999,7 +1001,7 @@ return_err:
  * Retry the whole path once, forcing real lookup requests
  * instead of relying on the dcache.
  */
-int fastcall link_path_walk(const char *name, struct nameidata *nd)
+static int fastcall link_path_walk(const char *name, struct nameidata *nd)
 {
struct nameidata save = *nd;
int result;
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 4718788..d60a5eb 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -73,7 +73,6 @@ extern int FASTCALL(path_lookup(const char *, unsigned, 
struct nameidata *));
 extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
   const char *, unsigned int, struct nameidata *);
 extern int FASTCALL(path_walk(const char *, struct nameidata *));
-extern int FASTCALL(link_path_walk(const char *, struct nameidata *));
 extern void path_release(struct nameidata *);
 extern void path_release_on_umount(struct nameidata *);
 
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] nfsctl: Use vfs_path_lookup

2007-05-06 Thread Josef 'Jeff' Sipek
use vfs_path_lookup instead of open-coding the necessary functionality.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/nfsctl.c |   16 ++--
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/fs/nfsctl.c b/fs/nfsctl.c
index c043136..51f1b31 100644
--- a/fs/nfsctl.c
+++ b/fs/nfsctl.c
@@ -23,19 +23,15 @@
 static struct file *do_open(char *name, int flags)
 {
struct nameidata nd;
+   struct vfsmount *mnt;
int error;
 
-   nd.mnt = do_kern_mount(nfsd, 0, nfsd, NULL);
+   mnt = do_kern_mount(nfsd, 0, nfsd, NULL);
+   if (IS_ERR(mnt))
+   return (struct file *)mnt;
 
-   if (IS_ERR(nd.mnt))
-   return (struct file *)nd.mnt;
-
-   nd.dentry = dget(nd.mnt-mnt_root);
-   nd.last_type = LAST_ROOT;
-   nd.flags = 0;
-   nd.depth = 0;
-
-   error = path_walk(name, nd);
+   error = vfs_path_lookup(mnt-mnt_root, mnt, name, 0, nd);
+   mntput(mnt);/* drop do_kern_mount reference */
if (error)
return ERR_PTR(error);
 
-- 
1.5.2.rc1.20.g86b9

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL -mm] Unionfs updates

2007-05-05 Thread Josef 'Jeff' Sipek
The following patches (also available though the git tree) fix few small
bugs in 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 Brunyate (2):
  Unionfs: Accept MS_SILENT during remount
  Unionfs: Check remount options for being NULL

Adrian Bunk (1):
  fix unionfs compilation

 fs/unionfs/super.c |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

Josef 'Jeff' Sipek.

[EMAIL PROTECTED]


-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] Unionfs: Check remount options for being NULL

2007-05-05 Thread Josef 'Jeff' Sipek
From: Adrian Brunyate [EMAIL PROTECTED]

Signed-off-by: Adrian Brunyate [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index ee12d03..02c0cc8 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -442,7 +442,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
 * the union to a ro or rw and the VFS took care of it.  So
 * nothing to do and we're done.
 */
-   if (options[0] == '\0')
+   if (!options || options[0] == '\0')
goto out_error;
 
/*
-- 
1.5.0.3.1043.g4342

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] Unionfs: Accept MS_SILENT during remount

2007-05-05 Thread Josef 'Jeff' Sipek
From: Adrian Brunyate [EMAIL PROTECTED]

[jsipek: whitespace cleanup]
Signed-off-by: Adrian Brunyate [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index e6a6cc1..ee12d03 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -425,11 +425,12 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
unionfs_write_lock(sb);
 
/*
-* The VFS will take care of ro and rw flags, so anything else
-* is an error.  So we need to check if any other flags may have
-* been passed (none are allowed/supported as of now).
+* The VFS will take care of ro and rw flags, and we can safely
+* ignore MS_SILENT, but anything else left over is an error.  So we
+* need to check if any other flags may have been passed (none are
+* allowed/supported as of now).
 */
-   if ((*flags  ~MS_RDONLY) != 0) {
+   if ((*flags  ~(MS_RDONLY | MS_SILENT)) != 0) {
printk(KERN_WARNING
   unionfs: remount flags 0x%x unsupported\n, *flags);
err = -EINVAL;
@@ -731,7 +732,8 @@ out_no_change:
i = atomic_inc_return(UNIONFS_SB(sb)-generation);
atomic_set(UNIONFS_D(sb-s_root)-generation, i);
atomic_set(UNIONFS_I(sb-s_root-d_inode)-generation, i);
-   printk(unionfs: new generation number %d\n, i);
+   if (!(*flags  MS_SILENT)) 
+   printk(unionfs: new generation number %d\n, i);
err = 0;/* reset to success */
 
/*
-- 
1.5.0.3.1043.g4342

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] [PATCH] fix unionfs compilation

2007-05-05 Thread Josef 'Jeff' Sipek
From: Adrian Bunk [EMAIL PROTECTED]

On Sat, May 05, 2007 at 01:49:55AM -0700, Andrew Morton wrote:
...
 Changes since 2.6.21-rc7-mm2:
...
  git-unionfs.patch
...
  git trees
...

--  snip  --

...
  CC  fs/unionfs/super.o
/home/bunk/linux/kernel-2.6/linux-2.6.21-mm1/fs/unionfs/super.c: In function 
‘init_once’:
/home/bunk/linux/kernel-2.6/linux-2.6.21-mm1/fs/unionfs/super.c:822: error: 
‘SLAB_CTOR_VERIFY’ undeclared (first use in this function)
/home/bunk/linux/kernel-2.6/linux-2.6.21-mm1/fs/unionfs/super.c:822: error: 
(Each undeclared identifier is reported only once
/home/bunk/linux/kernel-2.6/linux-2.6.21-mm1/fs/unionfs/super.c:822: error: for 
each function it appears in.)
make[3]: *** [fs/unionfs/super.o] Error 1

--  snip  --

Signed-off-by: Adrian Bunk [EMAIL PROTECTED]
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/unionfs/super.c |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 02c0cc8..af5a1c5 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -821,8 +821,7 @@ static void init_once(void *v, struct kmem_cache * cachep, 
unsigned long flags)
 {
struct unionfs_inode_info *i = v;
 
-   if ((flags  (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
-   SLAB_CTOR_CONSTRUCTOR)
+   if (flags  SLAB_CTOR_CONSTRUCTOR)
inode_init_once(i-vfs_inode);
 }
 
-- 
1.5.0.3.1043.g4342

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] [TRIVIAL] Small cleanups for do_path_lookup

2007-05-05 Thread Josef 'Jeff' Sipek
The following 2 patches are trivial cleanups to do_path_lookup in namei.c.
Since these changes are trivial, they can go into 2.6.22-rc1 without any
problems.

Josef 'Jeff' Sipek (2):
  fs: Fix indentation in do_path_lookup
  fs: Use path_walk in do_path_lookup

diffstat for good measure:

 fs/namei.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Josef 'Jeff' Sipek.

[EMAIL PROTECTED]


-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] fs: Use path_walk in do_path_lookup

2007-05-05 Thread Josef 'Jeff' Sipek
Since, path_walk sets the total_link_count to 0, and calls link_path_walk,
we can just call path_walk directly.

Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 600a4e7..86f0def 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1153,8 +1153,8 @@ static int fastcall do_path_lookup(int dfd, const char 
*name,
 
fput_light(file, fput_needed);
}
-   current-total_link_count = 0;
-   retval = link_path_walk(name, nd);
+
+   retval = path_walk(name, nd);
 out:
if (likely(retval == 0)) {
if (unlikely(!audit_dummy_context()  nd  nd-dentry 
-- 
1.5.0.3.1043.g4342

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] fs: Fix indentation in do_path_lookup

2007-05-05 Thread Josef 'Jeff' Sipek
Signed-off-by: Josef 'Jeff' Sipek [EMAIL PROTECTED]
---
 fs/namei.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 0262594..600a4e7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1159,7 +1159,7 @@ out:
if (likely(retval == 0)) {
if (unlikely(!audit_dummy_context()  nd  nd-dentry 
nd-dentry-d_inode))
-   audit_inode(name, nd-dentry-d_inode);
+   audit_inode(name, nd-dentry-d_inode);
}
 out_fail:
return retval;
-- 
1.5.0.3.1043.g4342

-
To unsubscribe from this list: send the line unsubscribe linux-fsdevel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >