linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erez Zadok <ezk@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	viro@ftp.linux.org.uk, hch@infradead.org,
	Erez Zadok <ezk@cs.sunysb.edu>
Subject: [PATCH 20/25] Unionfs: add un/likely conditionals on rename ops
Date: Tue, 25 Sep 2007 23:09:59 -0400	[thread overview]
Message-ID: <11907762133982-git-send-email-ezk@cs.sunysb.edu> (raw)
In-Reply-To: <11907762042481-git-send-email-ezk@cs.sunysb.edu>

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
---
 fs/unionfs/rename.c |   96 +++++++++++++++++++++++++-------------------------
 1 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 7b8fe39..92c4515 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -39,7 +39,7 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			create_parents(new_dentry->d_parent->d_inode,
 				       new_dentry, new_dentry->d_name.name,
 				       bindex);
-		if (IS_ERR(lower_new_dentry)) {
+		if (unlikely(IS_ERR(lower_new_dentry))) {
 			printk(KERN_DEBUG "unionfs: error creating directory "
 			       "tree for rename, bindex = %d, err = %ld\n",
 			       bindex, PTR_ERR(lower_new_dentry));
@@ -50,7 +50,7 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 	wh_name = alloc_whname(new_dentry->d_name.name,
 			       new_dentry->d_name.len);
-	if (IS_ERR(wh_name)) {
+	if (unlikely(IS_ERR(wh_name))) {
 		err = PTR_ERR(wh_name);
 		goto out;
 	}
@@ -58,14 +58,14 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	lower_wh_dentry = lookup_one_len(wh_name, lower_new_dentry->d_parent,
 					 new_dentry->d_name.len +
 					 UNIONFS_WHLEN);
-	if (IS_ERR(lower_wh_dentry)) {
+	if (unlikely(IS_ERR(lower_wh_dentry))) {
 		err = PTR_ERR(lower_wh_dentry);
 		goto out;
 	}
 
 	if (lower_wh_dentry->d_inode) {
 		/* get rid of the whiteout that is existing */
-		if (lower_new_dentry->d_inode) {
+		if (unlikely(lower_new_dentry->d_inode)) {
 			printk(KERN_WARNING "unionfs: both a whiteout and a "
 			       "dentry exist when doing a rename!\n");
 			err = -EIO;
@@ -81,7 +81,7 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 		dput(lower_wh_dentry);
 		unlock_dir(lower_wh_dir_dentry);
-		if (err)
+		if (unlikely(err))
 			goto out;
 	} else
 		dput(lower_wh_dentry);
@@ -93,7 +93,7 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
 
 	err = is_robranch_super(old_dentry->d_sb, bindex);
-	if (err)
+	if (unlikely(err))
 		goto out_unlock;
 
 	/*
@@ -105,14 +105,14 @@ static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		whname = alloc_whname(old_dentry->d_name.name,
 				      old_dentry->d_name.len);
 		err = PTR_ERR(whname);
-		if (IS_ERR(whname))
+		if (unlikely(IS_ERR(whname)))
 			goto out_unlock;
 		*wh_old = lookup_one_len(whname, lower_old_dir_dentry,
 					 old_dentry->d_name.len +
 					 UNIONFS_WHLEN);
 		kfree(whname);
 		err = PTR_ERR(*wh_old);
-		if (IS_ERR(*wh_old)) {
+		if (unlikely(IS_ERR(*wh_old))) {
 			*wh_old = NULL;
 			goto out_unlock;
 		}
@@ -129,7 +129,7 @@ out_unlock:
 	dput(lower_old_dentry);
 
 out:
-	if (!err) {
+	if (likely(!err)) {
 		/* Fixup the new_dentry. */
 		if (bindex < dbstart(new_dentry))
 			set_dbstart(new_dentry, bindex);
@@ -174,8 +174,8 @@ static int do_unionfs_rename(struct inode *old_dir,
 	/* Rename source to destination. */
 	err = __unionfs_rename(old_dir, old_dentry, new_dir, new_dentry,
 			       old_bstart, &wh_old);
-	if (err) {
-		if (!IS_COPYUP_ERR(err))
+	if (unlikely(err)) {
+		if (unlikely(!IS_COPYUP_ERR(err)))
 			goto out;
 		do_copyup = old_bstart - 1;
 	} else
@@ -190,7 +190,7 @@ static int do_unionfs_rename(struct inode *old_dir,
 		struct dentry *unlink_dir_dentry;
 
 		unlink_dentry = unionfs_lower_dentry_idx(new_dentry, bindex);
-		if (!unlink_dentry)
+		if (unlikely(!unlink_dentry))
 			continue;
 
 		unlink_dir_dentry = lock_parent(unlink_dentry);
@@ -205,15 +205,15 @@ static int do_unionfs_rename(struct inode *old_dir,
 			unionfs_get_nlinks(new_dentry->d_parent->d_inode);
 
 		unlock_dir(unlink_dir_dentry);
-		if (!err) {
+		if (likely(!err)) {
 			if (bindex != new_bstart) {
 				dput(unlink_dentry);
 				unionfs_set_lower_dentry_idx(new_dentry,
 							     bindex, NULL);
 			}
-		} else if (IS_COPYUP_ERR(err)) {
+		} else if (unlikely(IS_COPYUP_ERR(err))) {
 			do_copyup = bindex - 1;
-		} else if (revert) {
+		} else if (unlikely(revert)) {
 			dput(wh_old);
 			goto revert;
 		}
@@ -231,7 +231,7 @@ static int do_unionfs_rename(struct inode *old_dir,
 					    old_dentry->d_name.len,
 					    NULL, old_dentry->d_inode->i_size);
 			/* if copyup failed, try next branch to the left */
-			if (err)
+			if (unlikely(err))
 				continue;
 			dput(wh_old);
 			bwh_old = bindex;
@@ -245,7 +245,7 @@ static int do_unionfs_rename(struct inode *old_dir,
 	/* make it opaque */
 	if (S_ISDIR(old_dentry->d_inode->i_mode)) {
 		err = make_dir_opaque(old_dentry, dbstart(old_dentry));
-		if (err)
+		if (unlikely(err))
 			goto revert;
 	}
 
@@ -254,10 +254,10 @@ static int do_unionfs_rename(struct inode *old_dir,
 	 * (1) There is more than one underlying instance of source.
 	 * (2) We did a copy_up
 	 */
-	if ((old_bstart != old_bend) || (do_copyup != -1)) {
+	if (unlikely((old_bstart != old_bend) || (do_copyup != -1))) {
 		struct dentry *lower_parent;
 		struct nameidata nd;
-		if (!wh_old || wh_old->d_inode || bwh_old < 0) {
+		if (unlikely(!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);
@@ -265,13 +265,13 @@ static int do_unionfs_rename(struct inode *old_dir,
 			goto out;
 		}
 		err = init_lower_nd(&nd, LOOKUP_CREATE);
-		if (err < 0)
+		if (unlikely(err < 0))
 			goto out;
 		lower_parent = lock_parent(wh_old);
 		local_err = vfs_create(lower_parent->d_inode, wh_old, S_IRUGO,
 				       &nd);
 		unlock_dir(lower_parent);
-		if (!local_err)
+		if (likely(!local_err))
 			set_dbopaque(old_dentry, bwh_old);
 		else {
 			/*
@@ -292,30 +292,30 @@ out:
 revert:
 	/* Do revert here. */
 	local_err = unionfs_refresh_lower_dentry(new_dentry, old_bstart);
-	if (local_err) {
+	if (unlikely(local_err)) {
 		printk(KERN_WARNING "unionfs: revert failed in rename: "
 		       "the new refresh failed.\n");
 		eio = -EIO;
 	}
 
 	local_err = unionfs_refresh_lower_dentry(old_dentry, old_bstart);
-	if (local_err) {
+	if (unlikely(local_err)) {
 		printk(KERN_WARNING "unionfs: revert failed in rename: "
 		       "the old refresh failed.\n");
 		eio = -EIO;
 		goto revert_out;
 	}
 
-	if (!unionfs_lower_dentry_idx(new_dentry, bindex) ||
-	    !unionfs_lower_dentry_idx(new_dentry, bindex)->d_inode) {
+	if (unlikely(!unionfs_lower_dentry_idx(new_dentry, bindex) ||
+		     !unionfs_lower_dentry_idx(new_dentry, bindex)->d_inode)) {
 		printk(KERN_WARNING "unionfs: revert failed in rename: "
 		       "the object disappeared from under us!\n");
 		eio = -EIO;
 		goto revert_out;
 	}
 
-	if (unionfs_lower_dentry_idx(old_dentry, bindex) &&
-	    unionfs_lower_dentry_idx(old_dentry, bindex)->d_inode) {
+	if (unlikely(unionfs_lower_dentry_idx(old_dentry, bindex) &&
+		     unionfs_lower_dentry_idx(old_dentry, bindex)->d_inode)) {
 		printk(KERN_WARNING "unionfs: revert failed in rename: "
 		       "the object was created underneath us!\n");
 		eio = -EIO;
@@ -326,16 +326,16 @@ revert:
 				     old_dir, old_dentry, old_bstart, NULL);
 
 	/* If we can't fix it, then we cop-out with -EIO. */
-	if (local_err) {
+	if (unlikely(local_err)) {
 		printk(KERN_WARNING "unionfs: revert failed in rename!\n");
 		eio = -EIO;
 	}
 
 	local_err = unionfs_refresh_lower_dentry(new_dentry, bindex);
-	if (local_err)
+	if (unlikely(local_err))
 		eio = -EIO;
 	local_err = unionfs_refresh_lower_dentry(old_dentry, bindex);
-	if (local_err)
+	if (unlikely(local_err))
 		eio = -EIO;
 
 revert_out:
@@ -351,7 +351,7 @@ static struct dentry *lookup_whiteout(struct dentry *dentry)
 	struct dentry *parent, *lower_parent, *wh_dentry;
 
 	whname = alloc_whname(dentry->d_name.name, dentry->d_name.len);
-	if (IS_ERR(whname))
+	if (unlikely(IS_ERR(whname)))
 		return (void *)whname;
 
 	parent = dget_parent(dentry);
@@ -361,11 +361,11 @@ static struct dentry *lookup_whiteout(struct dentry *dentry)
 	wh_dentry = ERR_PTR(-ENOENT);
 	for (bindex = bstart; bindex <= bend; bindex++) {
 		lower_parent = unionfs_lower_dentry_idx(parent, bindex);
-		if (!lower_parent)
+		if (unlikely(!lower_parent))
 			continue;
 		wh_dentry = lookup_one_len(whname, lower_parent,
 					   dentry->d_name.len + UNIONFS_WHLEN);
-		if (IS_ERR(wh_dentry))
+		if (unlikely(IS_ERR(wh_dentry)))
 			continue;
 		if (wh_dentry->d_inode)
 			break;
@@ -389,10 +389,10 @@ static int may_rename_dir(struct dentry *dentry)
 	int err, bstart;
 
 	err = check_empty(dentry, NULL);
-	if (err == -ENOTEMPTY) {
-		if (is_robranch(dentry))
+	if (unlikely(err == -ENOTEMPTY)) {
+		if (unlikely(is_robranch(dentry)))
 			return -EXDEV;
-	} else if (err)
+	} else if (likely(err))
 		return err;
 
 	bstart = dbstart(dentry);
@@ -402,7 +402,7 @@ static int may_rename_dir(struct dentry *dentry)
 	set_dbstart(dentry, bstart + 1);
 	err = check_empty(dentry, NULL);
 	set_dbstart(dentry, bstart);
-	if (err == -ENOTEMPTY)
+	if (unlikely(err == -ENOTEMPTY))
 		err = -EXDEV;
 	return err;
 }
@@ -416,12 +416,12 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	unionfs_read_lock(old_dentry->d_sb);
 	unionfs_double_lock_dentry(old_dentry, new_dentry);
 
-	if (!__unionfs_d_revalidate_chain(old_dentry, NULL, false)) {
+	if (unlikely(!__unionfs_d_revalidate_chain(old_dentry, NULL, false))) {
 		err = -ESTALE;
 		goto out;
 	}
-	if (!d_deleted(new_dentry) && new_dentry->d_inode &&
-	    !__unionfs_d_revalidate_chain(new_dentry, NULL, false)) {
+	if (unlikely(!d_deleted(new_dentry) && new_dentry->d_inode &&
+		     !__unionfs_d_revalidate_chain(new_dentry, NULL, false))) {
 		err = -ESTALE;
 		goto out;
 	}
@@ -431,11 +431,11 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	else
 		err = may_rename_dir(old_dentry);
 
-	if (err)
+	if (unlikely(err))
 		goto out;
 
 	err = unionfs_partial_lookup(new_dentry);
-	if (err)
+	if (unlikely(err))
 		goto out;
 
 	/*
@@ -443,11 +443,11 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 * simply override it even if the whited-out dir is not empty.
 	 */
 	wh_dentry = lookup_whiteout(new_dentry);
-	if (!IS_ERR(wh_dentry))
+	if (likely(!IS_ERR(wh_dentry)))
 		dput(wh_dentry);
 	else if (new_dentry->d_inode) {
-		if (S_ISDIR(old_dentry->d_inode->i_mode) !=
-		    S_ISDIR(new_dentry->d_inode->i_mode)) {
+		if (unlikely(S_ISDIR(old_dentry->d_inode->i_mode) !=
+			     S_ISDIR(new_dentry->d_inode->i_mode))) {
 			err = S_ISDIR(old_dentry->d_inode->i_mode) ?
 				-ENOTDIR : -EISDIR;
 			goto out;
@@ -457,7 +457,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 			struct unionfs_dir_state *namelist;
 			/* check if this unionfs directory is empty or not */
 			err = check_empty(new_dentry, &namelist);
-			if (err)
+			if (unlikely(err))
 				goto out;
 
 			if (!is_robranch(new_dentry))
@@ -467,13 +467,13 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
 			free_rdstate(namelist);
 
-			if (err)
+			if (unlikely(err))
 				goto out;
 		}
 	}
 	err = do_unionfs_rename(old_dir, old_dentry, new_dir, new_dentry);
 out:
-	if (err)
+	if (unlikely(err))
 		/* clear the new_dentry stuff created */
 		d_drop(new_dentry);
 	else {
-- 
1.5.2.2


  parent reply	other threads:[~2007-09-26  3:32 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-26  3:09 [GIT PULL -mm] 00/25 Unionfs updates/cleanups/fixes Erez Zadok
2007-09-26  3:09 ` [PATCH 01/25] Unionfs: Simplify unionfs_get_nlinks Erez Zadok
2007-09-26  3:09 ` [PATCH 02/25] Unionfs: Remove unused #defines Erez Zadok
2007-09-26  3:09 ` [PATCH 03/25] Unionfs: display informational messages only if debug is on Erez Zadok
2007-09-26  8:36   ` Jan Engelhardt
2007-09-26 14:01     ` Erez Zadok
2007-09-26 15:24       ` Jan Engelhardt
2007-09-26 15:28         ` Erez Zadok
2007-09-26  3:09 ` [PATCH 04/25] Unionfs: cache-coherency fixes Erez Zadok
2007-09-26  3:09 ` [PATCH 05/25] Unionfs: cast page->index loff_t before shifting Erez Zadok
2007-09-26  8:31   ` Christoph Hellwig
2007-09-26 13:44     ` Erez Zadok
2007-09-26  3:09 ` [PATCH 06/25] Unionfs: minor coding style updates Erez Zadok
2007-09-26  3:09 ` [PATCH 07/25] Unionfs: add lower nameidata debugging support Erez Zadok
2007-09-26  3:09 ` [PATCH 08/25] Unionfs: lower nameidata support for nfsv4 Erez Zadok
2007-09-26  3:09 ` [PATCH 09/25] Unionfs: add un/likely conditionals on common fileops Erez Zadok
2007-09-26  3:09 ` [PATCH 10/25] Unionfs: add un/likely conditionals on copyup ops Erez Zadok
2007-09-26  4:32   ` Kok, Auke
2007-09-26 13:40     ` Erez Zadok
2007-09-26 15:23       ` Kyle Moffett
2007-09-26 15:43         ` Erez Zadok
2007-09-26 16:47           ` Jan Engelhardt
2007-09-26 16:51             ` Erez Zadok
2007-09-26 18:34       ` Adrian Bunk
2007-09-26  3:09 ` [PATCH 11/25] Unionfs: add un/likely conditionals on debug ops Erez Zadok
2007-09-26 21:34   ` roel
2007-09-26  3:09 ` [PATCH 12/25] Unionfs: add un/likely conditionals on dentry ops Erez Zadok
2007-09-26  3:09 ` [PATCH 13/25] Unionfs: add un/likely conditionals on dir ops Erez Zadok
2007-09-26 21:40   ` roel
2007-09-27 14:28     ` Erez Zadok
2007-09-26  3:09 ` [PATCH 14/25] Unionfs: add un/likely conditionals on headers Erez Zadok
2007-09-26  3:09 ` [PATCH 15/25] Unionfs: add un/likely conditionals on fileops Erez Zadok
2007-09-26  3:09 ` [PATCH 16/25] Unionfs: add un/likely conditionals on inode ops Erez Zadok
2007-09-26  3:09 ` [PATCH 17/25] Unionfs: add un/likely conditionals on lookup ops Erez Zadok
2007-09-26  3:09 ` [PATCH 18/25] Unionfs: add un/likely conditionals on super ops Erez Zadok
2007-09-26  3:09 ` [PATCH 19/25] Unionfs: add un/likely conditionals on mmap ops Erez Zadok
2007-09-26  3:09 ` Erez Zadok [this message]
2007-09-26  3:10 ` [PATCH 21/25] Unionfs: add un/likely conditionals on readdir ops Erez Zadok
2007-09-26  3:10 ` [PATCH 22/25] Unionfs: add un/likely conditionals on common subr Erez Zadok
2007-09-26  3:10 ` [PATCH 23/25] Unionfs: add un/likely conditionals on unlink ops Erez Zadok
2007-09-26  3:10 ` [PATCH 24/25] Unionfs: add un/likely conditionals on xattr ops Erez Zadok
2007-09-26  3:10 ` [PATCH 25/25] Unionfs: use poison.h for safe poison pointers 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=11907762133982-git-send-email-ezk@cs.sunysb.edu \
    --to=ezk@cs.sunysb.edu \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --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).