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 10/25] Unionfs: add un/likely conditionals on copyup ops
Date: Tue, 25 Sep 2007 23:09:49 -0400	[thread overview]
Message-ID: <11907762093928-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/copyup.c |  102 +++++++++++++++++++++++++-------------------------
 1 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 23ac4c8..e3c5f15 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -36,14 +36,14 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
 
 	/* query the actual size of the xattr list */
 	list_size = vfs_listxattr(old_lower_dentry, NULL, 0);
-	if (list_size <= 0) {
+	if (unlikely(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)) {
+	if (unlikely(!name_list || IS_ERR(name_list))) {
 		err = PTR_ERR(name_list);
 		goto out;
 	}
@@ -52,14 +52,14 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
 
 	/* 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) {
+	if (unlikely(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)) {
+	if (unlikely(!attr_value || IS_ERR(attr_value))) {
 		err = PTR_ERR(name_list);
 		goto out;
 	}
@@ -73,11 +73,11 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
 		size = vfs_getxattr(old_lower_dentry, name_list,
 				    attr_value, XATTR_SIZE_MAX);
 		mutex_unlock(&old_lower_dentry->d_inode->i_mutex);
-		if (size < 0) {
+		if (unlikely(size < 0)) {
 			err = size;
 			goto out;
 		}
-		if (size > XATTR_SIZE_MAX) {
+		if (unlikely(size > XATTR_SIZE_MAX)) {
 			err = -E2BIG;
 			goto out;
 		}
@@ -91,13 +91,13 @@ static int copyup_xattrs(struct dentry *old_lower_dentry,
 		 * temporarily get FOWNER privileges.
 		 * XXX: move entire copyup code to SIOQ.
 		 */
-		if (err == -EPERM && !capable(CAP_FOWNER)) {
+		if (unlikely(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)
+		if (unlikely(err < 0))
 			goto out;
 		name_list += strlen(name_list) + 1;
 	}
@@ -105,7 +105,7 @@ out:
 	unionfs_xattr_kfree(name_list_buf);
 	unionfs_xattr_kfree(attr_value);
 	/* Ignore if xattr isn't supported */
-	if (err == -ENOTSUPP || err == -EOPNOTSUPP)
+	if (unlikely(err == -ENOTSUPP || err == -EOPNOTSUPP))
 		err = 0;
 	return err;
 }
@@ -136,15 +136,15 @@ static int copyup_permissions(struct super_block *sb,
 		ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_FORCE |
 		ATTR_GID | ATTR_UID;
 	err = notify_change(new_lower_dentry, &newattrs);
-	if (err)
+	if (unlikely(err))
 		goto out;
 
 	/* now try to change the mode and ignore EOPNOTSUPP on symlinks */
 	newattrs.ia_mode = i->i_mode;
 	newattrs.ia_valid = ATTR_MODE | ATTR_FORCE;
 	err = notify_change(new_lower_dentry, &newattrs);
-	if (err == -EOPNOTSUPP &&
-	    S_ISLNK(new_lower_dentry->d_inode->i_mode)) {
+	if (unlikely(err == -EOPNOTSUPP &&
+		     S_ISLNK(new_lower_dentry->d_inode->i_mode))) {
 		printk(KERN_WARNING
 		       "unionfs: changing \"%s\" symlink mode unsupported\n",
 		       new_lower_dentry->d_name.name);
@@ -178,7 +178,7 @@ static int __copyup_ndentry(struct dentry *old_lower_dentry,
 
 		run_sioq(__unionfs_mkdir, &args);
 		err = args.err;
-	} else if (S_ISLNK(old_mode)) {
+	} else if (unlikely(S_ISLNK(old_mode))) {
 		args.symlink.parent = new_lower_parent_dentry->d_inode;
 		args.symlink.dentry = new_lower_dentry;
 		args.symlink.symbuf = symbuf;
@@ -186,8 +186,8 @@ static int __copyup_ndentry(struct dentry *old_lower_dentry,
 
 		run_sioq(__unionfs_symlink, &args);
 		err = args.err;
-	} else if (S_ISBLK(old_mode) || S_ISCHR(old_mode) ||
-		   S_ISFIFO(old_mode) || S_ISSOCK(old_mode)) {
+	} else if (unlikely(S_ISBLK(old_mode) || S_ISCHR(old_mode) ||
+			    S_ISFIFO(old_mode) || S_ISSOCK(old_mode))) {
 		args.mknod.parent = new_lower_parent_dentry->d_inode;
 		args.mknod.dentry = new_lower_dentry;
 		args.mknod.mode = old_mode;
@@ -198,7 +198,7 @@ static int __copyup_ndentry(struct dentry *old_lower_dentry,
 	} else if (S_ISREG(old_mode)) {
 		struct nameidata nd;
 		err = init_lower_nd(&nd, LOOKUP_CREATE);
-		if (err < 0)
+		if (unlikely(err < 0))
 			goto out;
 		args.create.nd = &nd;
 		args.create.parent = new_lower_parent_dentry->d_inode;
@@ -240,12 +240,12 @@ static int __copyup_reg_data(struct dentry *dentry,
 	input_file = dentry_open(old_lower_dentry,
 				 unionfs_lower_mnt_idx(dentry, old_bindex),
 				 O_RDONLY | O_LARGEFILE);
-	if (IS_ERR(input_file)) {
+	if (unlikely(IS_ERR(input_file))) {
 		dput(old_lower_dentry);
 		err = PTR_ERR(input_file);
 		goto out;
 	}
-	if (!input_file->f_op || !input_file->f_op->read) {
+	if (unlikely(!input_file->f_op || !input_file->f_op->read)) {
 		err = -EINVAL;
 		goto out_close_in;
 	}
@@ -256,18 +256,18 @@ static int __copyup_reg_data(struct dentry *dentry,
 	branchget(sb, new_bindex);
 	output_file = dentry_open(new_lower_dentry, output_mnt,
 				  O_RDWR | O_LARGEFILE);
-	if (IS_ERR(output_file)) {
+	if (unlikely(IS_ERR(output_file))) {
 		err = PTR_ERR(output_file);
 		goto out_close_in2;
 	}
-	if (!output_file->f_op || !output_file->f_op->write) {
+	if (unlikely(!output_file->f_op || !output_file->f_op->write)) {
 		err = -EINVAL;
 		goto out_close_out;
 	}
 
 	/* allocating a buffer */
 	buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	if (!buf) {
+	if (unlikely(!buf)) {
 		err = -ENOMEM;
 		goto out_close_out;
 	}
@@ -302,7 +302,7 @@ static int __copyup_reg_data(struct dentry *dentry,
 						 (char __user *)buf,
 						 read_bytes,
 						 &output_file->f_pos);
-		if ((write_bytes < 0) || (write_bytes < read_bytes)) {
+		if (unlikely((write_bytes < 0) || (write_bytes < read_bytes))) {
 			err = write_bytes;
 			break;
 		}
@@ -312,11 +312,11 @@ static int __copyup_reg_data(struct dentry *dentry,
 
 	kfree(buf);
 
-	if (!err)
+	if (likely(!err))
 		err = output_file->f_op->fsync(output_file,
 					       new_lower_dentry, 0);
 
-	if (err)
+	if (unlikely(err))
 		goto out_close_out;
 
 	if (copyup_file) {
@@ -399,7 +399,7 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 
 	/* Create the directory structure above this dentry. */
 	new_lower_dentry = create_parents(dir, dentry, name, new_bindex);
-	if (IS_ERR(new_lower_dentry)) {
+	if (unlikely(IS_ERR(new_lower_dentry))) {
 		err = PTR_ERR(new_lower_dentry);
 		goto out;
 	}
@@ -409,10 +409,10 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 	dget(old_lower_dentry);
 
 	/* For symlinks, we must read the link before we lock the directory. */
-	if (S_ISLNK(old_lower_dentry->d_inode->i_mode)) {
+	if (unlikely(S_ISLNK(old_lower_dentry->d_inode->i_mode))) {
 
 		symbuf = kmalloc(PATH_MAX, GFP_KERNEL);
-		if (!symbuf) {
+		if (unlikely(!symbuf)) {
 			__clear(dentry, old_lower_dentry,
 				old_bstart, old_bend,
 				new_lower_dentry, new_bindex);
@@ -427,7 +427,7 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 			(char __user *)symbuf,
 			PATH_MAX);
 		set_fs(oldfs);
-		if (err < 0) {
+		if (unlikely(err < 0)) {
 			__clear(dentry, old_lower_dentry,
 				old_bstart, old_bend,
 				new_lower_dentry, new_bindex);
@@ -443,7 +443,7 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 	err = __copyup_ndentry(old_lower_dentry, new_lower_dentry,
 			       new_lower_parent_dentry, symbuf);
 
-	if (err) {
+	if (unlikely(err)) {
 		__clear(dentry, old_lower_dentry,
 			old_bstart, old_bend,
 			new_lower_dentry, new_bindex);
@@ -455,22 +455,22 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
 		err = __copyup_reg_data(dentry, new_lower_dentry, new_bindex,
 					old_lower_dentry, old_bindex,
 					copyup_file, len);
-	if (err)
+	if (unlikely(err))
 		goto out_unlink;
 
 	/* Set permissions. */
-	if ((err = copyup_permissions(sb, old_lower_dentry,
-				      new_lower_dentry)))
+	if (unlikely((err = copyup_permissions(sb, old_lower_dentry,
+					       new_lower_dentry))))
 		goto out_unlink;
 
 #ifdef CONFIG_UNION_FS_XATTR
 	/* Selinux uses extended attributes for permissions. */
-	if ((err = copyup_xattrs(old_lower_dentry, new_lower_dentry)))
+	if (unlikely((err = copyup_xattrs(old_lower_dentry, new_lower_dentry))))
 		goto out_unlink;
 #endif /* CONFIG_UNION_FS_XATTR */
 
 	/* do not allow files getting deleted to be re-interposed */
-	if (!d_deleted(dentry))
+	if (likely(!d_deleted(dentry)))
 		unionfs_reinterpose(dentry);
 
 	goto out_unlock;
@@ -513,11 +513,11 @@ out_free:
 		dput(old_lower_dentry);
 	kfree(symbuf);
 
-	if (err)
+	if (unlikely(err))
 		goto out;
 	if (!S_ISDIR(dentry->d_inode->i_mode)) {
 		unionfs_postcopyup_release(dentry);
-		if (!unionfs_lower_inode(dentry->d_inode)) {
+		if (unlikely(!unionfs_lower_inode(dentry->d_inode))) {
 			/*
 			 * If we got here, then we copied up to an
 			 * unlinked-open file, whose name is .unionfsXXXXX.
@@ -551,7 +551,7 @@ int copyup_named_file(struct inode *dir, struct file *file, char *name,
 
 	err = copyup_dentry(dir, file->f_path.dentry, bstart, new_bindex,
 			    name, strlen(name), &output_file, len);
-	if (!err) {
+	if (likely(!err)) {
 		fbstart(file) = new_bindex;
 		unionfs_set_lower_file_idx(file, new_bindex, output_file);
 	}
@@ -573,7 +573,7 @@ int copyup_file(struct inode *dir, struct file *file, int bstart,
 	err = copyup_dentry(dir, dentry, bstart, new_bindex,
 			    dentry->d_name.name, dentry->d_name.len,
 			    &output_file, len);
-	if (!err) {
+	if (likely(!err)) {
 		fbstart(file) = new_bindex;
 		unionfs_set_lower_file_idx(file, new_bindex, output_file);
 	}
@@ -600,7 +600,7 @@ static void __cleanup_dentry(struct dentry *dentry, int bindex,
 	 * dentries except bindex
 	 */
 	for (i = loop_start; i <= loop_end; i++) {
-		if (!unionfs_lower_dentry_idx(dentry, i))
+		if (unlikely(!unionfs_lower_dentry_idx(dentry, i)))
 			continue;
 
 		if (i == bindex) {
@@ -623,9 +623,9 @@ static void __cleanup_dentry(struct dentry *dentry, int bindex,
 		}
 	}
 
-	if (new_bstart < 0)
+	if (unlikely(new_bstart < 0))
 		new_bstart = bindex;
-	if (new_bend < 0)
+	if (unlikely(new_bend < 0))
 		new_bend = bindex;
 	set_dbstart(dentry, new_bstart);
 	set_dbend(dentry, new_bend);
@@ -679,7 +679,7 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
 
 	verify_locked(dentry);
 
-	if ((err = is_robranch_super(dir->i_sb, bindex))) {
+	if (unlikely((err = is_robranch_super(dir->i_sb, bindex)))) {
 		lower_dentry = ERR_PTR(err);
 		goto out;
 	}
@@ -692,7 +692,7 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
 	/* There is no sense allocating any less than the minimum. */
 	nr_dentry = 1;
 	path = kmalloc(nr_dentry * sizeof(struct dentry *), GFP_KERNEL);
-	if (!path)
+	if (unlikely(!path))
 		goto out;
 
 	/* assume the negative dentry of unionfs as the parent dentry */
@@ -719,13 +719,13 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
 			unionfs_lower_dentry_idx(parent_dentry, bindex);
 
 		/* grow path table */
-		if (count == nr_dentry) {
+		if (unlikely(count == nr_dentry)) {
 			void *p;
 
 			nr_dentry *= 2;
 			p = krealloc(path, nr_dentry * sizeof(struct dentry *),
 				     GFP_KERNEL);
-			if (!p) {
+			if (unlikely(!p)) {
 				lower_dentry = ERR_PTR(-ENOMEM);
 				goto out;
 			}
@@ -757,7 +757,7 @@ begin:
 		/* lookup child in the underlying file system */
 		lower_dentry = lookup_one_len(childname, lower_parent_dentry,
 					      childnamelen);
-		if (IS_ERR(lower_dentry))
+		if (unlikely(IS_ERR(lower_dentry)))
 			goto out;
 	} else {
 		/*
@@ -766,7 +766,7 @@ begin:
 		 */
 		lower_dentry = lookup_one_len(name, lower_parent_dentry,
 					      strlen(name));
-		if (IS_ERR(lower_dentry))
+		if (unlikely(IS_ERR(lower_dentry)))
 			goto out;
 
 		/* Replace the current dentry (if any) with the new one */
@@ -797,11 +797,11 @@ begin:
 		run_sioq(__unionfs_mkdir, &args);
 		err = args.err;
 
-		if (!err)
+		if (likely(!err))
 			err = copyup_permissions(dir->i_sb, child_dentry,
 						 lower_dentry);
 		unlock_dir(lower_parent_dentry);
-		if (err) {
+		if (unlikely(err)) {
 			struct inode *inode = lower_dentry->d_inode;
 			/*
 			 * If we get here, it means that we created a new
@@ -836,7 +836,7 @@ begin:
 	goto begin;
 out:
 	/* cleanup any leftover locks from the do/while loop above */
-	if (IS_ERR(lower_dentry))
+	if (unlikely(IS_ERR(lower_dentry)))
 		while (count)
 			unionfs_unlock_dentry(path[count--]);
 	kfree(path);
@@ -852,7 +852,7 @@ void unionfs_postcopyup_setmnt(struct dentry *dentry)
 	struct dentry *parent, *hasone;
 	int bindex = dbstart(dentry);
 
-	if (unionfs_lower_mnt_idx(dentry, bindex))
+	if (unlikely(unionfs_lower_mnt_idx(dentry, bindex)))
 		return;
 	hasone = dentry->d_parent;
 	/* this loop should stop at root dentry */
-- 
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 ` Erez Zadok [this message]
2007-09-26  4:32   ` [PATCH 10/25] Unionfs: add un/likely conditionals on copyup ops 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 ` [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=11907762093928-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).