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 17/25] Unionfs: add un/likely conditionals on lookup ops
Date: Tue, 25 Sep 2007 23:09:56 -0400	[thread overview]
Message-ID: <1190776212879-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/lookup.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 2109714..92b5e0a 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -59,7 +59,7 @@ static noinline int is_opaque_dir(struct dentry *dentry, int bindex)
 
 	mutex_unlock(&lower_inode->i_mutex);
 
-	if (IS_ERR(wh_lower_dentry)) {
+	if (unlikely(IS_ERR(wh_lower_dentry))) {
 		err = PTR_ERR(wh_lower_dentry);
 		goto out;
 	}
@@ -119,12 +119,12 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 	case INTERPOSE_PARTIAL:
 		break;
 	case INTERPOSE_LOOKUP:
-		if ((err = new_dentry_private_data(dentry)))
+		if (unlikely((err = new_dentry_private_data(dentry))))
 			goto out;
 		break;
 	default:
 		/* default: can only be INTERPOSE_REVAL/REVAL_NEG */
-		if ((err = realloc_dentry_private_data(dentry)))
+		if (unlikely((err = realloc_dentry_private_data(dentry))))
 			goto out;
 		break;
 	}
@@ -147,7 +147,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 	namelen = dentry->d_name.len;
 
 	/* No dentries should get created for possible whiteout names. */
-	if (!is_validname(name)) {
+	if (unlikely(!is_validname(name))) {
 		err = -EPERM;
 		goto out_free;
 	}
@@ -179,7 +179,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 			unionfs_lower_dentry_idx(parent_dentry, bindex);
 
 		/* if the parent lower dentry does not exist skip this */
-		if (!(lower_dir_dentry && lower_dir_dentry->d_inode))
+		if (unlikely(!(lower_dir_dentry && lower_dir_dentry->d_inode)))
 			continue;
 
 		/* also skip it if the parent isn't a directory. */
@@ -189,7 +189,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 		/* Reuse the whiteout name because its value doesn't change. */
 		if (!whname) {
 			whname = alloc_whname(name, namelen);
-			if (IS_ERR(whname)) {
+			if (unlikely(IS_ERR(whname))) {
 				err = PTR_ERR(whname);
 				goto out_free;
 			}
@@ -198,7 +198,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);
-		if (IS_ERR(wh_lower_dentry)) {
+		if (unlikely(IS_ERR(wh_lower_dentry))) {
 			dput(first_lower_dentry);
 			unionfs_mntput(first_dentry, first_dentry_offset);
 			err = PTR_ERR(wh_lower_dentry);
@@ -207,7 +207,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 
 		if (wh_lower_dentry->d_inode) {
 			/* We found a whiteout so lets give up. */
-			if (S_ISREG(wh_lower_dentry->d_inode->i_mode)) {
+			if (likely(S_ISREG(wh_lower_dentry->d_inode->i_mode))) {
 				set_dbend(dentry, bindex);
 				set_dbopaque(dentry, bindex);
 				dput(wh_lower_dentry);
@@ -228,7 +228,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
 
 		/* Now do regular lookup; lookup foo */
 		lower_dentry = lookup_one_len(name, lower_dir_dentry, namelen);
-		if (IS_ERR(lower_dentry)) {
+		if (unlikely(IS_ERR(lower_dentry))) {
 			dput(first_lower_dentry);
 			unionfs_mntput(first_dentry, first_dentry_offset);
 			err = PTR_ERR(lower_dentry);
@@ -321,7 +321,7 @@ out_negative:
 		first_lower_dentry = lookup_one_len(name, lower_dir_dentry,
 						    namelen);
 		first_dentry_offset = bindex;
-		if (IS_ERR(first_lower_dentry)) {
+		if (unlikely(IS_ERR(first_lower_dentry))) {
 			err = PTR_ERR(first_lower_dentry);
 			goto out;
 		}
@@ -381,12 +381,12 @@ out_positive:
 	 * dentry.
 	 */
 	d_interposed = unionfs_interpose(dentry, dentry->d_sb, lookupmode);
-	if (IS_ERR(d_interposed))
+	if (unlikely(IS_ERR(d_interposed)))
 		err = PTR_ERR(d_interposed);
 	else if (d_interposed)
 		dentry = d_interposed;
 
-	if (err)
+	if (unlikely(err))
 		goto out_drop;
 
 	goto out;
@@ -452,7 +452,7 @@ int unionfs_partial_lookup(struct dentry *dentry)
 		err = 0;
 		goto out;
 	}
-	if (IS_ERR(tmp)) {
+	if (unlikely(IS_ERR(tmp))) {
 		err = PTR_ERR(tmp);
 		goto out;
 	}
@@ -476,13 +476,13 @@ int unionfs_init_dentry_cache(void)
 
 void unionfs_destroy_dentry_cache(void)
 {
-	if (unionfs_dentry_cachep)
+	if (likely(unionfs_dentry_cachep))
 		kmem_cache_destroy(unionfs_dentry_cachep);
 }
 
 void free_dentry_private_data(struct dentry *dentry)
 {
-	if (!dentry || !dentry->d_fsdata)
+	if (unlikely(!dentry || !dentry->d_fsdata))
 		return;
 	kmem_cache_free(unionfs_dentry_cachep, dentry->d_fsdata);
 	dentry->d_fsdata = NULL;
@@ -498,7 +498,7 @@ static inline int __realloc_dentry_private_data(struct dentry *dentry)
 
 	size = sizeof(struct path) * sbmax(dentry->d_sb);
 	p = krealloc(info->lower_paths, size, GFP_ATOMIC);
-	if (!p)
+	if (unlikely(!p))
 		return -ENOMEM;
 
 	info->lower_paths = p;
@@ -518,7 +518,7 @@ static inline int __realloc_dentry_private_data(struct dentry *dentry)
 /* UNIONFS_D(dentry)->lock must be locked */
 static int realloc_dentry_private_data(struct dentry *dentry)
 {
-	if (!__realloc_dentry_private_data(dentry))
+	if (likely(!__realloc_dentry_private_data(dentry)))
 		return 0;
 
 	kfree(UNIONFS_D(dentry)->lower_paths);
@@ -534,7 +534,7 @@ int new_dentry_private_data(struct dentry *dentry)
 	BUG_ON(info);
 
 	info = kmem_cache_alloc(unionfs_dentry_cachep, GFP_ATOMIC);
-	if (!info)
+	if (unlikely(!info))
 		return -ENOMEM;
 
 	mutex_init(&info->lock);
@@ -544,7 +544,7 @@ int new_dentry_private_data(struct dentry *dentry)
 
 	dentry->d_fsdata = info;
 
-	if (!__realloc_dentry_private_data(dentry))
+	if (likely(!__realloc_dentry_private_data(dentry)))
 		return 0;
 
 	mutex_unlock(&info->lock);
@@ -602,7 +602,7 @@ int init_lower_nd(struct nameidata *nd, unsigned int flags)
 #endif /* ALLOC_LOWER_ND_FILE */
 
 	memset(nd, 0, sizeof(struct nameidata));
-	if (!flags)
+	if (unlikely(!flags))
 		return err;
 
 	switch (flags) {
@@ -614,7 +614,7 @@ int init_lower_nd(struct nameidata *nd, unsigned int flags)
 		nd->intent.open.flags |= (FMODE_READ | FMODE_WRITE);
 #ifdef ALLOC_LOWER_ND_FILE
 		file = kzalloc(sizeof(struct file), GFP_KERNEL);
-		if (!file) {
+		if (unlikely(!file)) {
 			err = -ENOMEM;
 			break; /* exit switch statement and thus return */
 		}
@@ -641,7 +641,7 @@ void release_lower_nd(struct nameidata *nd, int err)
 {
 	if (!nd->intent.open.file)
 		return;
-	else if (!err)
+	else if (likely(!err))
 		release_open_intent(nd);
 #ifdef ALLOC_LOWER_ND_FILE
 	kfree(nd->intent.open.file);
-- 
1.5.2.2


  parent reply	other threads:[~2007-09-26  3:31 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 ` Erez Zadok [this message]
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 ` [PATCH 20/25] Unionfs: add un/likely conditionals on rename ops Erez Zadok
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=1190776212879-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).