commit bb651a55a0fbf4e1c4f172846f1baf88f0dc1d82
Author: Erez Zadok <[EMAIL PROTECTED]>
Date: Tue Sep 25 00:56:45 2007 -0400
Unionfs: add un/likely conditionals on lookup ops
Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index da89ced..11c4d84 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);
@@ -233,7 +233,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
lower_dentry = lookup_one_len_nd(name, lower_dir_dentry,
namelen, nd);
- 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);
@@ -331,7 +331,7 @@ out_negative:
lookup_one_len_nd(name, lower_dir_dentry,
namelen, nd);
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;
}
@@ -391,12 +391,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;
@@ -462,7 +462,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;
}
@@ -486,13 +486,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;
@@ -508,7 +508,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;
@@ -528,7 +528,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);
@@ -544,7 +544,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);
@@ -554,7 +554,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);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs