lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <11907762113652-git-send-email-ezk@cs.sunysb.edu>
Date:	Tue, 25 Sep 2007 23:09:54 -0400
From:	Erez Zadok <ezk@...sunysb.edu>
To:	akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	viro@....linux.org.uk, hch@...radead.org,
	Erez Zadok <ezk@...sunysb.edu>
Subject: [PATCH 15/25] Unionfs: add un/likely conditionals on fileops

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

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index d8eaaa5..06ca1fa 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -24,13 +24,13 @@ static ssize_t unionfs_read(struct file *file, char __user *buf,
 	int err;
 
 	unionfs_read_lock(file->f_path.dentry->d_sb);
-	if ((err = unionfs_file_revalidate(file, false)))
+	if (unlikely((err = unionfs_file_revalidate(file, false))))
 		goto out;
 	unionfs_check_file(file);
 
 	err = do_sync_read(file, buf, count, ppos);
 
-	if (err >= 0)
+	if (likely(err >= 0))
 		touch_atime(unionfs_lower_mnt(file->f_path.dentry),
 			    unionfs_lower_dentry(file->f_path.dentry));
 
@@ -47,16 +47,16 @@ 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, false)))
+	if (unlikely((err = unionfs_file_revalidate(file, false))))
 		goto out;
 	unionfs_check_file(file);
 
 	err = generic_file_aio_read(iocb, iov, nr_segs, pos);
 
-	if (err == -EIOCBQUEUED)
+	if (unlikely(err == -EIOCBQUEUED))
 		err = wait_on_sync_kiocb(iocb);
 
-	if (err >= 0)
+	if (likely(err >= 0))
 		touch_atime(unionfs_lower_mnt(file->f_path.dentry),
 			    unionfs_lower_dentry(file->f_path.dentry));
 
@@ -72,13 +72,13 @@ static ssize_t unionfs_write(struct file *file, const char __user *buf,
 	int err = 0;
 
 	unionfs_read_lock(file->f_path.dentry->d_sb);
-	if ((err = unionfs_file_revalidate(file, true)))
+	if (unlikely((err = unionfs_file_revalidate(file, true))))
 		goto out;
 	unionfs_check_file(file);
 
 	err = do_sync_write(file, buf, count, ppos);
 	/* update our inode times upon a successful lower write */
-	if (err >= 0) {
+	if (likely(err >= 0)) {
 		unionfs_copy_attr_times(file->f_path.dentry->d_inode);
 		unionfs_check_file(file);
 	}
@@ -104,7 +104,7 @@ static int unionfs_mmap(struct file *file, struct vm_area_struct *vma)
 
 	/* 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)))
+	if (unlikely((err = unionfs_file_revalidate(file, willwrite))))
 		goto out;
 	unionfs_check_file(file);
 
@@ -119,19 +119,19 @@ static int unionfs_mmap(struct file *file, struct vm_area_struct *vma)
 	 * generic_file_readonly_mmap returns in that case).
 	 */
 	lower_file = unionfs_lower_file(file);
-	if (willwrite && !lower_file->f_mapping->a_ops->writepage) {
+	if (unlikely(willwrite && !lower_file->f_mapping->a_ops->writepage)) {
 		err = -EINVAL;
 		printk("unionfs: branch %d file system does not support "
 		       "writeable mmap\n", fbstart(file));
 	} else {
 		err = generic_file_mmap(file, vma);
-		if (err)
+		if (unlikely(err))
 			printk("unionfs: generic_file_mmap failed %d\n", err);
 	}
 
 out:
 	unionfs_read_unlock(file->f_path.dentry->d_sb);
-	if (!err) {
+	if (likely(!err)) {
 		/* copyup could cause parent dir times to change */
 		unionfs_copy_attr_times(file->f_path.dentry->d_parent->d_inode);
 		unionfs_check_file(file);
@@ -149,7 +149,7 @@ int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
 	int err = -EINVAL;
 
 	unionfs_read_lock(file->f_path.dentry->d_sb);
-	if ((err = unionfs_file_revalidate(file, true)))
+	if (unlikely((err = unionfs_file_revalidate(file, true))))
 		goto out;
 	unionfs_check_file(file);
 
@@ -159,14 +159,14 @@ int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
 		goto out;
 
 	inode = dentry->d_inode;
-	if (!inode) {
+	if (unlikely(!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)
+		if (unlikely(!lower_inode || !lower_inode->i_fop->fsync))
 			continue;
 		lower_file = unionfs_lower_file_idx(file, bindex);
 		lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
@@ -175,7 +175,7 @@ int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
 						lower_dentry,
 						datasync);
 		mutex_unlock(&lower_inode->i_mutex);
-		if (err)
+		if (unlikely(err))
 			goto out;
 	}
 
@@ -196,7 +196,7 @@ int unionfs_fasync(int fd, struct file *file, int flag)
 	int err = 0;
 
 	unionfs_read_lock(file->f_path.dentry->d_sb);
-	if ((err = unionfs_file_revalidate(file, true)))
+	if (unlikely((err = unionfs_file_revalidate(file, true))))
 		goto out;
 	unionfs_check_file(file);
 
@@ -207,20 +207,20 @@ int unionfs_fasync(int fd, struct file *file, int flag)
 
 	dentry = file->f_path.dentry;
 	inode = dentry->d_inode;
-	if (!inode) {
+	if (unlikely(!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)
+		if (unlikely(!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)
+		if (unlikely(err))
 			goto out;
 	}
 
-- 
1.5.2.2

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ