linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	hch@infradead.org, viro@ftp.linux.org.uk,
	bharata@linux.vnet.ibm.com, j.blunck@tu-harburg.de,
	Erez Zadok <ezk@cs.sunysb.edu>,
	"Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
Subject: [PATCH 22/32] Unionfs: handling lower vfsmount fixes
Date: Sun,  2 Sep 2007 22:20:45 -0400	[thread overview]
Message-ID: <11887860583755-git-send-email-jsipek@cs.sunysb.edu> (raw)
In-Reply-To: <1188786055371-git-send-email-jsipek@cs.sunysb.edu>

From: Erez Zadok <ezk@cs.sunysb.edu>

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

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 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 = unionfs_lower_mnt_idx(dentry, bindex);
+	if (!mnt) {
+		if (bindex < 0)
+			return;
+		if (!mnt && bindex >= 0) {
+			return;
+		}
+	}
+	mntput(mnt);
+}
+
 
-	BUG_ON(bindex < 0);
 
-	mntput(unionfs_lower_mnt_idx(dentry, bindex));
-}
 #endif	/* not _UNION_H_ */
-- 
1.5.2.2.238.g7cbf2f2


  parent reply	other threads:[~2007-09-03  2:24 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-03  2:20 [GIT PULL -mm] Unionfs/fsstack/eCryptfs updates/cleanups/fixes Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 01/32] VFS: export release_open_intent symbol Josef 'Jeff' Sipek
2007-09-03 16:29   ` Satyam Sharma
2007-09-03 17:38     ` Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 02/32] VFS/fsstack: remove 3rd argument to fsstack_copy_attr_all Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 03/32] VFS/fsstack: cpp endif comments Josef 'Jeff' Sipek
2007-09-03  6:39   ` Jan Engelhardt
2007-09-03 23:43     ` Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 04/32] Unionfs: fixed compilation error Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 05/32] Unionfs: do not use fsstack_copy_attr_all Josef 'Jeff' Sipek
2007-09-03  6:43   ` Jan Engelhardt
2007-09-03  2:20 ` [PATCH 06/32] Unionfs: copyright corrections and updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 07/32] Unionfs: cpp endif comments Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 08/32] Unionfs: cache-coherency - update inode times Josef 'Jeff' Sipek
2007-09-03  6:48   ` Jan Engelhardt
2007-09-03  2:20 ` [PATCH 09/32] Unionfs: cache-coherency - dentries Josef 'Jeff' Sipek
2007-09-03  6:52   ` Jan Engelhardt
2007-09-03 14:08     ` Josef 'Jeff' Sipek
2007-09-03 14:23       ` Jan Engelhardt
2007-09-03 23:39     ` [PATCH 1/1] " Josef 'Jeff' Sipek
2007-09-06 16:43       ` Josef 'Jeff' Sipek
2007-09-06 16:45         ` Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 10/32] Unionfs: cache-coherency - file flush Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 11/32] Unionfs: cache-coherency and fixes for unionfs_rename Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 12/32] Unionfs: documentation updates Josef 'Jeff' Sipek
2007-09-03  6:59   ` Jan Engelhardt
2007-09-03 14:04     ` Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 13/32] Unionfs: copyup updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 14/32] Unionfs: file_revalidate updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 15/32] Unionfs: implement f/async Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 16/32] Unionfs: minor file_release updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 17/32] Unionfs: interpose updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 18/32] Unionfs: unionfs_ioctl bug fixes Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 19/32] Unionfs: partial_lookup update Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 20/32] Unionfs: lower nameidata support Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 21/32] Unionfs: mmap fixes Josef 'Jeff' Sipek
2007-09-03  2:20 ` Josef 'Jeff' Sipek [this message]
2007-09-03  2:20 ` [PATCH 23/32] Unionfs: mount-time option parsing fix Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 24/32] Unionfs: remove old nfsro option Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 25/32] Unionfs: readonly branch test fix Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 26/32] Unionfs: minor remount fixes Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 27/32] Unionfs: extended attributes fixes Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 28/32] Unionfs: use file f_path field Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 29/32] Unionfs: assorted comment and style updates Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 30/32] Unionfs: update unionfs version number Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 31/32] Unionfs: debugging and validation of fan-out invariants Josef 'Jeff' Sipek
2007-09-03  2:20 ` [PATCH 32/32] Unionfs: unionfs_create rewrite Josef 'Jeff' Sipek
2007-09-03  3:48 ` [GIT PULL -mm] Unionfs/fsstack/eCryptfs updates/cleanups/fixes Al Boldi
2007-09-03 16:18   ` Erez Zadok
2007-09-03 18:26     ` Al Boldi
2007-09-03 18:42       ` Erez Zadok

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11887860583755-git-send-email-jsipek@cs.sunysb.edu \
    --to=jsipek@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=ezk@cs.sunysb.edu \
    --cc=hch@infradead.org \
    --cc=j.blunck@tu-harburg.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).