Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>
---
 fs/unionfs/main.c  |   98 ++++++++++++++++++++++++++-------------------------
 fs/unionfs/super.c |   90 ++++++++++++++++++++++++------------------------
 2 files changed, 95 insertions(+), 93 deletions(-)

diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 8595750..82cb35a 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -32,13 +32,13 @@ static void unionfs_fill_inode(struct dentry *dentry,
 
        for (bindex = bstart; bindex <= bend; bindex++) {
                lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
-               if (!lower_dentry) {
+               if (unlikely(!lower_dentry)) {
                        unionfs_set_lower_inode_idx(inode, bindex, NULL);
                        continue;
                }
 
                /* Initialize the lower inode to the new lower inode. */
-               if (!lower_dentry->d_inode)
+               if (unlikely(!lower_dentry->d_inode))
                        continue;
 
                unionfs_set_lower_inode_idx(inode, bindex,
@@ -52,7 +52,7 @@ static void unionfs_fill_inode(struct dentry *dentry,
        lower_inode = unionfs_lower_inode(inode);
 
        /* Use different set of inode ops for symlinks & directories */
-       if (S_ISLNK(lower_inode->i_mode))
+       if (unlikely(S_ISLNK(lower_inode->i_mode)))
                inode->i_op = &unionfs_symlink_iops;
        else if (S_ISDIR(lower_inode->i_mode))
                inode->i_op = &unionfs_dir_iops;
@@ -62,8 +62,10 @@ static void unionfs_fill_inode(struct dentry *dentry,
                inode->i_fop = &unionfs_dir_fops;
 
        /* properly initialize special inodes */
-       if (S_ISBLK(lower_inode->i_mode) || S_ISCHR(lower_inode->i_mode) ||
-           S_ISFIFO(lower_inode->i_mode) || S_ISSOCK(lower_inode->i_mode))
+       if (unlikely(S_ISBLK(lower_inode->i_mode) ||
+                    S_ISCHR(lower_inode->i_mode) ||
+                    S_ISFIFO(lower_inode->i_mode) ||
+                    S_ISSOCK(lower_inode->i_mode)))
                init_special_inode(inode, lower_inode->i_mode,
                                   lower_inode->i_rdev);
 
@@ -122,14 +124,14 @@ struct dentry *unionfs_interpose(struct dentry *dentry, 
struct super_block *sb,
 
                UNIONFS_I(inode)->lower_inodes =
                        kcalloc(sbmax(sb), sizeof(struct inode *), GFP_KERNEL);
-               if (!UNIONFS_I(inode)->lower_inodes) {
+               if (unlikely(!UNIONFS_I(inode)->lower_inodes)) {
                        err = -ENOMEM;
                        goto out;
                }
        } else {
                /* get unique inode number for unionfs */
                inode = iget(sb, iunique(sb, UNIONFS_ROOT_INO));
-               if (!inode) {
+               if (unlikely(!inode)) {
                        err = -EACCES;
                        goto out;
                }
@@ -149,7 +151,7 @@ skip:
                break;
        case INTERPOSE_LOOKUP:
                spliced = d_splice_alias(inode, dentry);
-               if (IS_ERR(spliced))
+               if (unlikely(IS_ERR(spliced)))
                        err = PTR_ERR(spliced);
                else if (spliced && spliced != dentry) {
                        /*
@@ -181,7 +183,7 @@ skip:
        goto out;
 
 out_spliced:
-       if (!err)
+       if (likely(!err))
                return spliced;
 out:
        return ERR_PTR(err);
@@ -203,12 +205,12 @@ void unionfs_reinterpose(struct dentry *dentry)
        bend = dbend(dentry);
        for (bindex = bstart; bindex <= bend; bindex++) {
                lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
-               if (!lower_dentry)
+               if (unlikely(!lower_dentry))
                        continue;
 
-               if (!lower_dentry->d_inode)
+               if (unlikely(!lower_dentry->d_inode))
                        continue;
-               if (unionfs_lower_inode_idx(inode, bindex))
+               if (unlikely(unionfs_lower_inode_idx(inode, bindex)))
                        continue;
                unionfs_set_lower_inode_idx(inode, bindex,
                                            igrab(lower_dentry->d_inode));
@@ -227,11 +229,11 @@ void unionfs_reinterpose(struct dentry *dentry)
 int check_branch(struct nameidata *nd)
 {
        /* XXX: remove in ODF code -- stacking unions allowed there */
-       if (!strcmp(nd->dentry->d_sb->s_type->name, "unionfs"))
+       if (unlikely(!strcmp(nd->dentry->d_sb->s_type->name, "unionfs")))
                return -EINVAL;
-       if (!nd->dentry->d_inode)
+       if (unlikely(!nd->dentry->d_inode))
                return -ENOENT;
-       if (!S_ISDIR(nd->dentry->d_inode->i_mode))
+       if (unlikely(!S_ISDIR(nd->dentry->d_inode->i_mode)))
                return -ENOTDIR;
        return 0;
 }
@@ -245,7 +247,7 @@ static int is_branch_overlap(struct dentry *dent1, struct 
dentry *dent2)
        while ((dent != dent2) && (dent->d_parent != dent))
                dent = dent->d_parent;
 
-       if (dent == dent2)
+       if (unlikely(dent == dent2))
                return 1;
 
        dent = dent2;
@@ -260,7 +262,7 @@ static int is_branch_overlap(struct dentry *dent1, struct 
dentry *dent2)
  */
 int __parse_branch_mode(const char *name)
 {
-       if (!name)
+       if (unlikely(!name))
                return 0;
        if (!strcmp(name, "ro"))
                return MAY_READ;
@@ -302,7 +304,7 @@ static int parse_dirs_option(struct super_block *sb, struct 
unionfs_dentry_info
        struct dentry *dent1;
        struct dentry *dent2;
 
-       if (options[0] == '\0') {
+       if (unlikely(options[0] == '\0')) {
                printk(KERN_WARNING "unionfs: no branches specified\n");
                err = -EINVAL;
                goto out;
@@ -319,14 +321,14 @@ static int parse_dirs_option(struct super_block *sb, 
struct unionfs_dentry_info
        /* allocate space for underlying pointers to lower dentry */
        UNIONFS_SB(sb)->data =
                kcalloc(branches, sizeof(struct unionfs_data), GFP_KERNEL);
-       if (!UNIONFS_SB(sb)->data) {
+       if (unlikely(!UNIONFS_SB(sb)->data)) {
                err = -ENOMEM;
                goto out;
        }
 
        lower_root_info->lower_paths =
                kcalloc(branches, sizeof(struct path), GFP_KERNEL);
-       if (!lower_root_info->lower_paths) {
+       if (unlikely(!lower_root_info->lower_paths)) {
                err = -ENOMEM;
                goto out;
        }
@@ -339,7 +341,7 @@ static int parse_dirs_option(struct super_block *sb, struct 
unionfs_dentry_info
 
                if (!name)
                        continue;
-               if (!*name) {   /* bad use of ':' (extra colons) */
+               if (unlikely(!*name)) { /* bad use of ':' (extra colons)) */
                        err = -EINVAL;
                        goto out;
                }
@@ -351,20 +353,20 @@ static int parse_dirs_option(struct super_block *sb, 
struct unionfs_dentry_info
                        *mode++ = '\0';
 
                perms = parse_branch_mode(mode);
-               if (!bindex && !(perms & MAY_WRITE)) {
+               if (unlikely(!bindex && !(perms & MAY_WRITE))) {
                        err = -EINVAL;
                        goto out;
                }
 
                err = path_lookup(name, LOOKUP_FOLLOW, &nd);
-               if (err) {
+               if (unlikely(err)) {
                        printk(KERN_WARNING "unionfs: error accessing "
                               "lower directory '%s' (error %d)\n",
                               name, err);
                        goto out;
                }
 
-               if ((err = check_branch(&nd))) {
+               if (unlikely((err = check_branch(&nd)))) {
                        printk(KERN_WARNING "unionfs: lower directory "
                               "'%s' is not a valid branch\n", name);
                        path_release(&nd);
@@ -384,7 +386,7 @@ static int parse_dirs_option(struct super_block *sb, struct 
unionfs_dentry_info
                bindex++;
        }
 
-       if (branches == 0) {
+       if (unlikely(branches == 0)) {
                printk(KERN_WARNING "unionfs: no branches specified\n");
                err = -EINVAL;
                goto out;
@@ -411,7 +413,7 @@ static int parse_dirs_option(struct super_block *sb, struct 
unionfs_dentry_info
                dent1 = lower_root_info->lower_paths[i].dentry;
                for (j = i + 1; j < branches; j++) {
                        dent2 = lower_root_info->lower_paths[j].dentry;
-                       if (is_branch_overlap(dent1, dent2)) {
+                       if (unlikely(is_branch_overlap(dent1, dent2))) {
                                printk(KERN_WARNING "unionfs: branches %d and "
                                       "%d overlap\n", i, j);
                                err = -EINVAL;
@@ -421,7 +423,7 @@ static int parse_dirs_option(struct super_block *sb, struct 
unionfs_dentry_info
        }
 
 out:
-       if (err) {
+       if (unlikely(err)) {
                for (i = 0; i < branches; i++)
                        if (lower_root_info->lower_paths[i].dentry) {
                                dput(lower_root_info->lower_paths[i].dentry);
@@ -462,7 +464,7 @@ static struct unionfs_dentry_info *unionfs_parse_options(
        err = -ENOMEM;
        lower_root_info =
                kzalloc(sizeof(struct unionfs_dentry_info), GFP_KERNEL);
-       if (!lower_root_info)
+       if (unlikely(!lower_root_info))
                goto out_error;
        lower_root_info->bstart = -1;
        lower_root_info->bend = -1;
@@ -473,7 +475,7 @@ static struct unionfs_dentry_info *unionfs_parse_options(
                char *endptr;
                int intval;
 
-               if (!optname || !*optname)
+               if (unlikely(!optname || !*optname))
                        continue;
 
                optarg = strchr(optname, '=');
@@ -484,28 +486,28 @@ static struct unionfs_dentry_info *unionfs_parse_options(
                 * All of our options take an argument now. Insert ones that
                 * don't, above this check.
                 */
-               if (!optarg) {
+               if (unlikely(!optarg)) {
                        printk("unionfs: %s requires an argument.\n", optname);
                        err = -EINVAL;
                        goto out_error;
                }
 
                if (!strcmp("dirs", optname)) {
-                       if (++dirsfound > 1) {
+                       if (unlikely(++dirsfound > 1)) {
                                printk(KERN_WARNING
                                       "unionfs: multiple dirs specified\n");
                                err = -EINVAL;
                                goto out_error;
                        }
                        err = parse_dirs_option(sb, lower_root_info, optarg);
-                       if (err)
+                       if (unlikely(err))
                                goto out_error;
                        continue;
                }
 
                /* All of these options require an integer argument. */
                intval = simple_strtoul(optarg, &endptr, 0);
-               if (*endptr) {
+               if (unlikely(*endptr)) {
                        printk(KERN_WARNING
                               "unionfs: invalid %s option '%s'\n",
                               optname, optarg);
@@ -518,7 +520,7 @@ static struct unionfs_dentry_info *unionfs_parse_options(
                       "unionfs: unrecognized option '%s'\n", optname);
                goto out_error;
        }
-       if (dirsfound != 1) {
+       if (unlikely(dirsfound != 1)) {
                printk(KERN_WARNING "unionfs: dirs option required\n");
                err = -EINVAL;
                goto out_error;
@@ -563,11 +565,11 @@ static struct dentry *unionfs_d_alloc_root(struct 
super_block *sb)
 {
        struct dentry *ret = NULL;
 
-       if (sb) {
+       if (likely(sb)) {
                static const struct qstr name = {.name = "/",.len = 1 };
 
                ret = d_alloc(NULL, &name);
-               if (ret) {
+               if (likely(ret)) {
                        ret->d_op = &unionfs_dops;
                        ret->d_sb = sb;
                        ret->d_parent = ret;
@@ -587,7 +589,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
        struct unionfs_dentry_info *lower_root_info = NULL;
        int bindex, bstart, bend;
 
-       if (!raw_data) {
+       if (unlikely(!raw_data)) {
                printk(KERN_WARNING
                       "unionfs: read_super: missing data argument\n");
                err = -EINVAL;
@@ -596,7 +598,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
 
        /* Allocate superblock private data */
        sb->s_fs_info = kzalloc(sizeof(struct unionfs_sb_info), GFP_KERNEL);
-       if (!UNIONFS_SB(sb)) {
+       if (unlikely(!UNIONFS_SB(sb))) {
                printk(KERN_WARNING "unionfs: read_super: out of memory\n");
                err = -ENOMEM;
                goto out;
@@ -608,7 +610,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
        UNIONFS_SB(sb)->high_branch_id = -1; /* -1 == invalid branch ID */
 
        lower_root_info = unionfs_parse_options(sb, raw_data);
-       if (IS_ERR(lower_root_info)) {
+       if (unlikely(IS_ERR(lower_root_info))) {
                printk(KERN_WARNING
                       "unionfs: read_super: error while parsing options "
                       "(err = %ld)\n", PTR_ERR(lower_root_info));
@@ -616,7 +618,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
                lower_root_info = NULL;
                goto out_free;
        }
-       if (lower_root_info->bstart == -1) {
+       if (unlikely(lower_root_info->bstart == -1)) {
                err = -ENOENT;
                goto out_free;
        }
@@ -637,14 +639,14 @@ static int unionfs_read_super(struct super_block *sb, 
void *raw_data,
 
        /* See comment next to the definition of unionfs_d_alloc_root */
        sb->s_root = unionfs_d_alloc_root(sb);
-       if (!sb->s_root) {
+       if (unlikely(!sb->s_root)) {
                err = -ENOMEM;
                goto out_dput;
        }
 
        /* link the upper and lower dentries */
        sb->s_root->d_fsdata = NULL;
-       if ((err = new_dentry_private_data(sb->s_root)))
+       if (unlikely((err = new_dentry_private_data(sb->s_root))))
                goto out_freedpd;
 
        /* Set the lower dentries for s_root */
@@ -670,7 +672,7 @@ static int unionfs_read_super(struct super_block *sb, void 
*raw_data,
         */
        err = PTR_ERR(unionfs_interpose(sb->s_root, sb, 0));
        unionfs_unlock_dentry(sb->s_root);
-       if (!err)
+       if (likely(!err))
                goto out;
        /* else fall through */
 
@@ -734,17 +736,17 @@ static int __init init_unionfs_fs(void)
 
        printk("Registering unionfs " UNIONFS_VERSION "\n");
 
-       if ((err = unionfs_init_filldir_cache()))
+       if (unlikely((err = unionfs_init_filldir_cache())))
                goto out;
-       if ((err = unionfs_init_inode_cache()))
+       if (unlikely((err = unionfs_init_inode_cache())))
                goto out;
-       if ((err = unionfs_init_dentry_cache()))
+       if (unlikely((err = unionfs_init_dentry_cache())))
                goto out;
-       if ((err = init_sioq()))
+       if (unlikely((err = init_sioq())))
                goto out;
        err = register_filesystem(&unionfs_fs_type);
 out:
-       if (err) {
+       if (unlikely(err)) {
                stop_sioq();
                unionfs_destroy_filldir_cache();
                unionfs_destroy_inode_cache();
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 4e0fe7c..b07bcb7 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -44,7 +44,7 @@ static void unionfs_read_inode(struct inode *inode)
 
        size = sbmax(inode->i_sb) * sizeof(struct inode *);
        info->lower_inodes = kzalloc(size, GFP_KERNEL);
-       if (!info->lower_inodes) {
+       if (unlikely(!info->lower_inodes)) {
                printk(KERN_ERR "unionfs: no kernel memory when allocating "
                       "lower-pointer array!\n");
                BUG();
@@ -90,7 +90,7 @@ static void unionfs_put_super(struct super_block *sb)
        int leaks = 0;
 
        spd = UNIONFS_SB(sb);
-       if (!spd)
+       if (unlikely(!spd))
                return;
 
        bstart = sbstart(sb);
@@ -98,7 +98,7 @@ static void unionfs_put_super(struct super_block *sb)
 
        /* Make sure we have no leaks of branchget/branchput. */
        for (bindex = bstart; bindex <= bend; bindex++)
-               if (branch_count(sb, bindex) != 0) {
+               if (unlikely(branch_count(sb, bindex) != 0)) {
                        printk("unionfs: branch %d has %d references left!\n",
                               bindex, branch_count(sb, bindex));
                        leaks = 1;
@@ -126,7 +126,7 @@ static int unionfs_statfs(struct dentry *dentry, struct 
kstatfs *buf)
        unionfs_read_lock(sb);
        unionfs_lock_dentry(dentry);
 
-       if (!__unionfs_d_revalidate_chain(dentry, NULL, false)) {
+       if (unlikely(!__unionfs_d_revalidate_chain(dentry, NULL, false))) {
                err = -ESTALE;
                goto out;
        }
@@ -170,17 +170,17 @@ static noinline int do_remount_mode_option(char *optarg, 
int cur_branches,
        struct nameidata nd;
 
        /* by now, optarg contains the branch name */
-       if (!*optarg) {
+       if (unlikely(!*optarg)) {
                printk("unionfs: no branch specified for mode change.\n");
                goto out;
        }
-       if (!modename) {
+       if (unlikely(!modename)) {
                printk("unionfs: branch \"%s\" requires a mode.\n", optarg);
                goto out;
        }
        *modename++ = '\0';
        perms = __parse_branch_mode(modename);
-       if (perms == 0) {
+       if (unlikely(perms == 0)) {
                printk("unionfs: invalid mode \"%s\" for \"%s\".\n",
                       modename, optarg);
                goto out;
@@ -193,7 +193,7 @@ static noinline int do_remount_mode_option(char *optarg, 
int cur_branches,
         * uniqueness.
         */
        err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
-       if (err) {
+       if (unlikely(err)) {
                printk(KERN_WARNING "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
                       optarg, err);
@@ -204,7 +204,7 @@ static noinline int do_remount_mode_option(char *optarg, 
int cur_branches,
                    nd.dentry == new_lower_paths[idx].dentry)
                        break;
        path_release(&nd);      /* no longer needed */
-       if (idx == cur_branches) {
+       if (unlikely(idx == cur_branches)) {
                err = -ENOENT;  /* err may have been reset above */
                printk(KERN_WARNING "unionfs: branch \"%s\" "
                       "not found\n", optarg);
@@ -236,7 +236,7 @@ static noinline int do_remount_del_option(char *optarg, int 
cur_branches,
         * uniqueness.
         */
        err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
-       if (err) {
+       if (unlikely(err)) {
                printk(KERN_WARNING "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
                       optarg, err);
@@ -247,14 +247,14 @@ static noinline int do_remount_del_option(char *optarg, 
int cur_branches,
                    nd.dentry == new_lower_paths[idx].dentry)
                        break;
        path_release(&nd);      /* no longer needed */
-       if (idx == cur_branches) {
+       if (unlikely(idx == cur_branches)) {
                printk(KERN_WARNING "unionfs: branch \"%s\" "
                       "not found\n", optarg);
                err = -ENOENT;
                goto out;
        }
        /* check if there are any open files on the branch to be deleted */
-       if (atomic_read(&new_data[idx].open_files) > 0) {
+       if (unlikely(atomic_read(&new_data[idx].open_files) > 0)) {
                err = -EBUSY;
                goto out;
        }
@@ -320,7 +320,7 @@ static noinline int do_remount_add_option(char *optarg, int 
cur_branches,
         * uniqueness.
         */
        err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
-       if (err) {
+       if (unlikely(err)) {
                printk(KERN_WARNING "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
                       optarg, err);
@@ -331,7 +331,7 @@ static noinline int do_remount_add_option(char *optarg, int 
cur_branches,
                    nd.dentry == new_lower_paths[idx].dentry)
                        break;
        path_release(&nd);      /* no longer needed */
-       if (idx == cur_branches) {
+       if (unlikely(idx == cur_branches)) {
                printk(KERN_WARNING "unionfs: branch \"%s\" "
                       "not found\n", optarg);
                err = -ENOENT;
@@ -350,13 +350,13 @@ found_insertion_point:
                *modename++ = '\0';
        perms = parse_branch_mode(modename);
 
-       if (!new_branch || !*new_branch) {
+       if (unlikely(!new_branch || !*new_branch)) {
                printk(KERN_WARNING "unionfs: null new branch\n");
                err = -EINVAL;
                goto out;
        }
        err = path_lookup(new_branch, LOOKUP_FOLLOW, &nd);
-       if (err) {
+       if (unlikely(err)) {
                printk(KERN_WARNING "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
                       new_branch, err);
@@ -369,7 +369,7 @@ found_insertion_point:
         * because this code base doesn't support stacking unionfs: the ODF
         * code base supports that correctly.
         */
-       if ((err = check_branch(&nd))) {
+       if (unlikely((err = check_branch(&nd)))) {
                printk(KERN_WARNING "unionfs: lower directory "
                       "\"%s\" is not a valid branch\n", optarg);
                path_release(&nd);
@@ -453,7 +453,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
         * need to check if any other flags may have been passed (none are
         * allowed/supported as of now).
         */
-       if ((*flags & ~(MS_RDONLY | MS_SILENT)) != 0) {
+       if (unlikely((*flags & ~(MS_RDONLY | MS_SILENT)) != 0)) {
                printk(KERN_WARNING
                       "unionfs: remount flags 0x%x unsupported\n", *flags);
                err = -EINVAL;
@@ -465,7 +465,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
         * the union to a "ro" or "rw" and the VFS took care of it.  So
         * nothing to do and we're done.
         */
-       if (!options || options[0] == '\0')
+       if (unlikely(!options || options[0] == '\0'))
                goto out_error;
 
        /*
@@ -474,7 +474,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
         * strsep modifies the string and we need it later.
         */
        optionstmp = tmp_to_free = kstrdup(options, GFP_KERNEL);
-       if (!optionstmp) {
+       if (unlikely(!optionstmp)) {
                err = -ENOMEM;
                goto out_free;
        }
@@ -484,7 +484,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
        while ((optname = strsep(&optionstmp, ",")) != NULL) {
                char *optarg;
 
-               if (!optname || !*optname)
+               if (unlikely(!optname || !*optname))
                        continue;
 
                optarg = strchr(optname, '=');
@@ -498,7 +498,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
        }
        kfree(tmp_to_free);
        /* after all changes, will we have at least one branch left? */
-       if ((new_branches + add_branches - del_branches) < 1) {
+       if (unlikely((new_branches + add_branches - del_branches) < 1)) {
                printk(KERN_WARNING
                       "unionfs: no branches left after remount\n");
                err = -EINVAL;
@@ -521,14 +521,14 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
        /* allocate space for new pointers to lower dentry */
        tmp_data = kcalloc(max_branches,
                           sizeof(struct unionfs_data), GFP_KERNEL);
-       if (!tmp_data) {
+       if (unlikely(!tmp_data)) {
                err = -ENOMEM;
                goto out_free;
        }
        /* allocate space for new pointers to lower paths */
        tmp_lower_paths = kcalloc(max_branches,
                                  sizeof(struct path), GFP_KERNEL);
-       if (!tmp_lower_paths) {
+       if (unlikely(!tmp_lower_paths)) {
                err = -ENOMEM;
                goto out_free;
        }
@@ -556,7 +556,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
        while ((optname = strsep(&options, ",")) != NULL) {
                char *optarg;
 
-               if (!optname || !*optname)
+               if (unlikely(!optname || !*optname))
                        continue;
                /*
                 * At this stage optname holds a comma-delimited option, but
@@ -579,7 +579,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
                 * that don't above this check.)  So at this stage optname
                 * contains the CMD part and optarg contains the ARG part.
                 */
-               if (!optarg || !*optarg) {
+               if (unlikely(!optarg || !*optarg)) {
                        printk("unionfs: all remount options require "
                               "an argument (%s).\n", optname);
                        err = -EINVAL;
@@ -591,10 +591,10 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
                                                    tmp_data,
                                                    tmp_lower_paths,
                                                    &new_high_branch_id);
-                       if (err)
+                       if (unlikely(err))
                                goto out_release;
                        new_branches++;
-                       if (new_branches > UNIONFS_MAX_BRANCHES) {
+                       if (unlikely(new_branches > UNIONFS_MAX_BRANCHES)) {
                                printk("unionfs: command exceeds "
                                       "%d branches\n", UNIONFS_MAX_BRANCHES);
                                err = -E2BIG;
@@ -606,7 +606,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
                        err = do_remount_del_option(optarg, new_branches,
                                                    tmp_data,
                                                    tmp_lower_paths);
-                       if (err)
+                       if (unlikely(err))
                                goto out_release;
                        new_branches--;
                        continue;
@@ -615,7 +615,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
                        err = do_remount_mode_option(optarg, new_branches,
                                                     tmp_data,
                                                     tmp_lower_paths);
-                       if (err)
+                       if (unlikely(err))
                                goto out_release;
                        continue;
                }
@@ -629,7 +629,7 @@ static int unionfs_remount_fs(struct super_block *sb, int 
*flags,
                 * actually process the ro/rw remount options, we have to
                 * return 0 from this function.
                 */
-               if (!strcmp("dirs", optname)) {
+               if (unlikely(!strcmp("dirs", optname))) {
                        printk(KERN_WARNING
                               "unionfs: remount ignoring option \"%s\".\n",
                               optname);
@@ -652,7 +652,7 @@ out_no_change:
         * have to be re-read.
         *******************************************************************/
 
-       if (!(tmp_data[0].branchperms & MAY_WRITE)) {
+       if (unlikely(!(tmp_data[0].branchperms & MAY_WRITE))) {
                printk("unionfs: leftmost branch cannot be read-only "
                       "(use \"remount,ro\" to create a read-only union)\n");
                err = -EINVAL;
@@ -662,7 +662,7 @@ out_no_change:
        /* (re)allocate space for new pointers to lower dentry */
        size = new_branches * sizeof(struct unionfs_data);
        new_data = krealloc(tmp_data, size, GFP_KERNEL);
-       if (!new_data) {
+       if (unlikely(!new_data)) {
                err = -ENOMEM;
                goto out_release;
        }
@@ -670,7 +670,7 @@ out_no_change:
        /* allocate space for new pointers to lower paths */
        size = new_branches * sizeof(struct path);
        new_lower_paths = krealloc(tmp_lower_paths, size, GFP_KERNEL);
-       if (!new_lower_paths) {
+       if (unlikely(!new_lower_paths)) {
                err = -ENOMEM;
                goto out_release;
        }
@@ -678,7 +678,7 @@ out_no_change:
        /* allocate space for new pointers to lower inodes */
        new_lower_inodes = kcalloc(new_branches,
                                   sizeof(struct inode *), GFP_KERNEL);
-       if (!new_lower_inodes) {
+       if (unlikely(!new_lower_inodes)) {
                err = -ENOMEM;
                goto out_release;
        }
@@ -765,7 +765,7 @@ out_no_change:
        i = atomic_inc_return(&UNIONFS_SB(sb)->generation);
        atomic_set(&UNIONFS_D(sb->s_root)->generation, i);
        atomic_set(&UNIONFS_I(sb->s_root->d_inode)->generation, i);
-       if (!(*flags & MS_SILENT))
+       if (likely(!(*flags & MS_SILENT)))
                printk("unionfs: new generation number %d\n", i);
        /* finally, update the root dentry's times */
        unionfs_copy_attr_times(sb->s_root->d_inode);
@@ -781,7 +781,7 @@ out_no_change:
         */
 out_release:
        /* no need to cleanup/release anything in tmp_data */
-       if (tmp_lower_paths)
+       if (likely(tmp_lower_paths))
                for (i=0; i<new_branches; i++)
                        pathput(&tmp_lower_paths[i]);
 out_free:
@@ -823,10 +823,10 @@ static void unionfs_clear_inode(struct inode *inode)
         */
        bstart = ibstart(inode);
        bend = ibend(inode);
-       if (bstart >= 0) {
+       if (likely(bstart >= 0)) {
                for (bindex = bstart; bindex <= bend; bindex++) {
                        lower_inode = unionfs_lower_inode_idx(inode, bindex);
-                       if (!lower_inode)
+                       if (unlikely(!lower_inode))
                                continue;
                        iput(lower_inode);
                }
@@ -841,7 +841,7 @@ static struct inode *unionfs_alloc_inode(struct super_block 
*sb)
        struct unionfs_inode_info *i;
 
        i = kmem_cache_alloc(unionfs_inode_cachep, GFP_KERNEL);
-       if (!i)
+       if (unlikely(!i))
                return NULL;
 
        /* memset everything up to the inode to 0 */
@@ -872,7 +872,7 @@ int unionfs_init_inode_cache(void)
                kmem_cache_create("unionfs_inode_cache",
                                  sizeof(struct unionfs_inode_info), 0,
                                  SLAB_RECLAIM_ACCOUNT, init_once);
-       if (!unionfs_inode_cachep)
+       if (unlikely(!unionfs_inode_cachep))
                err = -ENOMEM;
        return err;
 }
@@ -880,7 +880,7 @@ int unionfs_init_inode_cache(void)
 /* unionfs inode cache destructor */
 void unionfs_destroy_inode_cache(void)
 {
-       if (unionfs_inode_cachep)
+       if (likely(unionfs_inode_cachep))
                kmem_cache_destroy(unionfs_inode_cachep);
 }
 
@@ -920,7 +920,7 @@ static void unionfs_umount_begin(struct vfsmount *mnt, int 
flags)
        struct vfsmount *lower_mnt;
        int bindex, bstart, bend;
 
-       if (!(flags & MNT_FORCE))
+       if (likely(!(flags & MNT_FORCE)))
                /*
                 * we are not being MNT_FORCE'd, therefore we should emulate
                 * old behavior
@@ -959,7 +959,7 @@ static int unionfs_show_options(struct seq_file *m, struct 
vfsmount *mnt)
        unionfs_lock_dentry(sb->s_root);
 
        tmp_page = (char*) __get_free_page(GFP_KERNEL);
-       if (!tmp_page) {
+       if (unlikely(!tmp_page)) {
                ret = -ENOMEM;
                goto out;
        }
@@ -972,7 +972,7 @@ static int unionfs_show_options(struct seq_file *m, struct 
vfsmount *mnt)
                path = d_path(unionfs_lower_dentry_idx(sb->s_root, bindex),
                              unionfs_lower_mnt_idx(sb->s_root, bindex),
                              tmp_page, PAGE_SIZE);
-               if (IS_ERR(path)) {
+               if (unlikely(IS_ERR(path))) {
                        ret = PTR_ERR(path);
                        goto out;
                }
-- 
1.5.2.2

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to