unionfs_lock_dentry(dentry->d_parent);
valid = __unionfs_d_revalidate_chain(dentry->d_parent, nd, false);
unionfs_unlock_dentry(dentry->d_parent);
- if (!valid) {
+ if (unlikely(!valid)) {
err = -ESTALE; /* same as what real_lookup does */
goto out;
}
* We _always_ create on branch 0
*/
lower_dentry = unionfs_lower_dentry_idx(dentry, 0);
- if (lower_dentry) {
+ if (likely(lower_dentry)) {
/*
* check if whiteout exists in this branch, i.e. lookup .wh.foo
* first.
*/
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
- if (IS_ERR(name)) {
+ if (unlikely(IS_ERR(name))) {
err = PTR_ERR(name);
goto out;
}
wh_dentry = lookup_one_len(name, lower_dentry->d_parent,
dentry->d_name.len + UNIONFS_WHLEN);
- if (IS_ERR(wh_dentry)) {
+ if (unlikely(IS_ERR(wh_dentry))) {
err = PTR_ERR(wh_dentry);
wh_dentry = NULL;
goto out;
}
- if (wh_dentry->d_inode) {
+ if (unlikely(wh_dentry->d_inode)) {
/*
* .wh.foo has been found, so let's unlink it
*/
err = vfs_unlink(lower_dir_dentry->d_inode, wh_dentry);
unlock_dir(lower_dir_dentry);
- if (err) {
+ if (unlikely(err)) {
printk("unionfs_create: could not unlink "
"whiteout, err = %d\n", err);
goto out;
*/
lower_dentry = create_parents(parent, dentry,
dentry->d_name.name, 0);
- if (IS_ERR(lower_dentry)) {
+ if (unlikely(IS_ERR(lower_dentry))) {
err = PTR_ERR(lower_dentry);
goto out;
}
}
lower_parent_dentry = lock_parent(lower_dentry);
- if (IS_ERR(lower_parent_dentry)) {
+ if (unlikely(IS_ERR(lower_parent_dentry))) {
err = PTR_ERR(lower_parent_dentry);
goto out;
}
err = init_lower_nd(&lower_nd, LOOKUP_CREATE);
- if (err < 0)
+ if (unlikely(err < 0))
goto out;
err = vfs_create(lower_parent_dentry->d_inode, lower_dentry, mode,
&lower_nd);
release_lower_nd(&lower_nd, err);
- if (!err) {
+ if (likely(!err)) {
err = PTR_ERR(unionfs_interpose(dentry, parent->i_sb, 0));
- if (!err) {
+ if (likely(!err)) {
unionfs_copy_attr_times(parent);
fsstack_copy_inode_size(parent,
lower_parent_dentry->d_inode);
dput(wh_dentry);
kfree(name);
- if (!err)
+ if (likely(!err))
unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
unionfs_read_unlock(dentry->d_sb);
unionfs_check_inode(parent);
- if (!err) {
+ if (likely(!err)) {
unionfs_check_dentry(dentry->d_parent);
unionfs_check_nd(nd);
}
nd->dentry = path_save.dentry;
nd->mnt = path_save.mnt;
}
- if (!IS_ERR(ret)) {
+ if (likely(!IS_ERR(ret))) {
if (ret)
dentry = ret;
/* parent times may have changed */
unionfs_read_lock(old_dentry->d_sb);
unionfs_double_lock_dentry(new_dentry, old_dentry);
- if (!__unionfs_d_revalidate_chain(old_dentry, NULL, false)) {
+ if (unlikely(!__unionfs_d_revalidate_chain(old_dentry, NULL, false))) {
err = -ESTALE;
goto out;
}
- if (new_dentry->d_inode &&
- !__unionfs_d_revalidate_chain(new_dentry, NULL, false)) {
+ if (unlikely(new_dentry->d_inode &&
+ !__unionfs_d_revalidate_chain(new_dentry, NULL, false))) {
err = -ESTALE;
goto out;
}
* .wh.foo first. If present, delete it
*/
name = alloc_whname(new_dentry->d_name.name, new_dentry->d_name.len);
- if (IS_ERR(name)) {
+ if (unlikely(IS_ERR(name))) {
err = PTR_ERR(name);
goto out;
}
whiteout_dentry = lookup_one_len(name, lower_new_dentry->d_parent,
new_dentry->d_name.len +
UNIONFS_WHLEN);
- if (IS_ERR(whiteout_dentry)) {
+ if (unlikely(IS_ERR(whiteout_dentry))) {
err = PTR_ERR(whiteout_dentry);
goto out;
}
/* found a .wh.foo entry, unlink it and then call vfs_link() */
lower_dir_dentry = lock_parent(whiteout_dentry);
err = is_robranch_super(new_dentry->d_sb, dbstart(new_dentry));
- if (!err)
+ if (likely(!err))
err = vfs_unlink(lower_dir_dentry->d_inode,
whiteout_dentry);
unlock_dir(lower_dir_dentry);
lower_dir_dentry = NULL;
dput(whiteout_dentry);
- if (err)
+ if (unlikely(err))
goto out;
}
new_dentry->d_name.name,
dbstart(old_dentry));
err = PTR_ERR(lower_new_dentry);
- if (IS_COPYUP_ERR(err))
+ if (unlikely(IS_COPYUP_ERR(err)))
goto docopyup;
- if (!lower_new_dentry || IS_ERR(lower_new_dentry))
+ if (likely(!lower_new_dentry || IS_ERR(lower_new_dentry)))
goto out;
}
lower_new_dentry = unionfs_lower_dentry(new_dentry);
unlock_dir(lower_dir_dentry);
docopyup:
- if (IS_COPYUP_ERR(err)) {
+ if (unlikely(IS_COPYUP_ERR(err))) {
int old_bstart = dbstart(old_dentry);
int bindex;
bindex, old_dentry->d_name.name,
old_dentry->d_name.len, NULL,
old_dentry->d_inode->i_size);
- if (!err) {
+ if (likely(!err)) {
lower_new_dentry =
create_parents(dir, new_dentry,
new_dentry->d_name.name,
}
check_link:
- if (err || !lower_new_dentry->d_inode)
+ if (unlikely(err || !lower_new_dentry->d_inode))
goto out;
/* Its a hard link, so use the same inode */
d_drop(new_dentry);
kfree(name);
- if (!err)
+ if (likely(!err))
unionfs_postcopyup_setmnt(new_dentry);
unionfs_unlock_dentry(new_dentry);
unionfs_read_lock(dentry->d_sb);
unionfs_lock_dentry(dentry);
- if (dentry->d_inode &&
- !__unionfs_d_revalidate_chain(dentry, NULL, false)) {
+ if (unlikely(dentry->d_inode &&
+ !__unionfs_d_revalidate_chain(dentry, NULL, false))) {
err = -ESTALE;
goto out;
}
* first. If present, delete it
*/
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
- if (IS_ERR(name)) {
+ if (unlikely(IS_ERR(name))) {
err = PTR_ERR(name);
goto out;
}
whiteout_dentry =
lookup_one_len(name, lower_dentry->d_parent,
dentry->d_name.len + UNIONFS_WHLEN);
- if (IS_ERR(whiteout_dentry)) {
+ if (unlikely(IS_ERR(whiteout_dentry))) {
err = PTR_ERR(whiteout_dentry);
goto out;
}
unlock_dir(lower_dir_dentry);
- if (err) {
+ if (unlikely(err)) {
/* exit if the error returned was NOT -EROFS */
- if (!IS_COPYUP_ERR(err))
+ if (unlikely(!IS_COPYUP_ERR(err)))
goto out;
/*
* should now try to create symlink in the another
lower_dentry = create_parents(dir, dentry,
dentry->d_name.name,
bindex);
- if (!lower_dentry || IS_ERR(lower_dentry)) {
- if (IS_ERR(lower_dentry))
+ if (unlikely(!lower_dentry || IS_ERR(lower_dentry))) {
+ if (unlikely(IS_ERR(lower_dentry)))
err = PTR_ERR(lower_dentry);
printk(KERN_DEBUG "unionfs: lower dentry "
}
unlock_dir(lower_dir_dentry);
- if (err || !lower_dentry->d_inode) {
+ if (unlikely(err || !lower_dentry->d_inode)) {
/*
* break out of for loop if error returned was NOT
* -EROFS.
*/
- if (!IS_COPYUP_ERR(err))
+ if (unlikely(!IS_COPYUP_ERR(err)))
break;
} else {
/*
*/
err = PTR_ERR(unionfs_interpose(dentry,
dir->i_sb, 0));
- if (!err) {
+ if (likely(!err)) {
fsstack_copy_attr_times(dir,
lower_dir_dentry->
d_inode);
d_drop(dentry);
kfree(name);
- if (!err)
+ if (likely(!err))
unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
unionfs_read_lock(dentry->d_sb);
unionfs_lock_dentry(dentry);
- if (dentry->d_inode &&
- !__unionfs_d_revalidate_chain(dentry, NULL, false)) {
+ if (unlikely(dentry->d_inode &&
+ !__unionfs_d_revalidate_chain(dentry, NULL, false))) {
err = -ESTALE;
goto out;
}
* first.
*/
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
- if (IS_ERR(name)) {
+ if (unlikely(IS_ERR(name))) {
err = PTR_ERR(name);
goto out;
}
whiteout_dentry = lookup_one_len(name, lower_dentry->d_parent,
dentry->d_name.len + UNIONFS_WHLEN);
- if (IS_ERR(whiteout_dentry)) {
+ if (unlikely(IS_ERR(whiteout_dentry))) {
err = PTR_ERR(whiteout_dentry);
goto out;
}
unlock_dir(lower_parent_dentry);
- if (err) {
+ if (unlikely(err)) {
/* exit if the error returned was NOT -EROFS */
- if (!IS_COPYUP_ERR(err))
+ if (unlikely(!IS_COPYUP_ERR(err)))
goto out;
bstart--;
} else
lower_dentry = create_parents(parent, dentry,
dentry->d_name.name,
bindex);
- if (!lower_dentry || IS_ERR(lower_dentry)) {
+ if (unlikely(!lower_dentry || IS_ERR(lower_dentry))) {
printk(KERN_DEBUG "unionfs: lower dentry "
" NULL for bindex = %d\n", bindex);
continue;
lower_parent_dentry = lock_parent(lower_dentry);
- if (IS_ERR(lower_parent_dentry)) {
+ if (unlikely(IS_ERR(lower_parent_dentry))) {
err = PTR_ERR(lower_parent_dentry);
goto out;
}
unlock_dir(lower_parent_dentry);
/* did the mkdir succeed? */
- if (err)
+ if (unlikely(err))
break;
for (i = bindex + 1; i < bend; i++) {
* err.
*/
err = PTR_ERR(unionfs_interpose(dentry, parent->i_sb, 0));
- if (!err) {
+ if (likely(!err)) {
unionfs_copy_attr_times(parent);
fsstack_copy_inode_size(parent,
lower_parent_dentry->d_inode);
}
err = make_dir_opaque(dentry, dbstart(dentry));
- if (err) {
+ if (unlikely(err)) {
printk(KERN_ERR "unionfs: mkdir: error creating "
".wh.__dir_opaque: %d\n", err);
goto out;
kfree(name);
- if (!err)
+ if (likely(!err))
unionfs_copy_attr_times(dentry->d_inode);
unionfs_unlock_dentry(dentry);
unionfs_check_inode(parent);
unionfs_read_lock(dentry->d_sb);
unionfs_lock_dentry(dentry);
- if (dentry->d_inode &&
- !__unionfs_d_revalidate_chain(dentry, NULL, false)) {
+ if (unlikely(dentry->d_inode &&
+ !__unionfs_d_revalidate_chain(dentry, NULL, false))) {
err = -ESTALE;
goto out;
}
* first.
*/
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
- if (IS_ERR(name)) {
+ if (unlikely(IS_ERR(name))) {
err = PTR_ERR(name);
goto out;
}
whiteout_dentry = lookup_one_len(name, lower_dentry->d_parent,
dentry->d_name.len + UNIONFS_WHLEN);
- if (IS_ERR(whiteout_dentry)) {
+ if (unlikely(IS_ERR(whiteout_dentry))) {
err = PTR_ERR(whiteout_dentry);
goto out;
}
unlock_dir(lower_parent_dentry);
- if (err) {
- if (!IS_COPYUP_ERR(err))
+ if (unlikely(err)) {
+ if (unlikely(!IS_COPYUP_ERR(err)))
goto out;
bstart--;
} else
lower_dentry = create_parents(dir, dentry,
dentry->d_name.name,
bindex);
- if (IS_ERR(lower_dentry)) {
+ if (unlikely(IS_ERR(lower_dentry))) {
printk(KERN_DEBUG "unionfs: failed to create "
"parents on %d, err = %ld\n",
bindex, PTR_ERR(lower_dentry));
}
lower_parent_dentry = lock_parent(lower_dentry);
- if (IS_ERR(lower_parent_dentry)) {
+ if (unlikely(IS_ERR(lower_parent_dentry))) {
err = PTR_ERR(lower_parent_dentry);
goto out;
}
err = vfs_mknod(lower_parent_dentry->d_inode,
lower_dentry, mode, dev);
- if (err) {
+ if (unlikely(err)) {
unlock_dir(lower_parent_dentry);
break;
}
* err.
*/
err = PTR_ERR(unionfs_interpose(dentry, dir->i_sb, 0));
- if (!err) {
+ if (likely(!err)) {
fsstack_copy_attr_times(dir,
lower_parent_dentry->d_inode);
fsstack_copy_inode_size(dir,
kfree(name);
- if (!err)
+ if (likely(!err))
unionfs_postcopyup_setmnt(dentry);
unionfs_unlock_dentry(dentry);
unionfs_read_lock(dentry->d_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;
}
lower_dentry = unionfs_lower_dentry(dentry);
- if (!lower_dentry->d_inode->i_op ||
- !lower_dentry->d_inode->i_op->readlink) {
+ if (unlikely(!lower_dentry->d_inode->i_op ||
+ !lower_dentry->d_inode->i_op->readlink)) {
err = -EINVAL;
goto out;
}
err = lower_dentry->d_inode->i_op->readlink(lower_dentry,
buf, bufsiz);
- if (err > 0)
+ if (likely(err > 0))
fsstack_copy_attr_atime(dentry->d_inode,
lower_dentry->d_inode);
/* This is freed by the put_link method assuming a successful call. */
buf = kmalloc(len, GFP_KERNEL);
- if (!buf) {
+ if (unlikely(!buf)) {
err = -ENOMEM;
goto out;
}
set_fs(KERNEL_DS);
err = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len);
set_fs(old_fs);
- if (err < 0) {
+ if (unlikely(err < 0)) {
kfree(buf);
buf = NULL;
goto out;
unionfs_read_lock(dentry->d_sb);
unionfs_lock_dentry(dentry);
- if (!__unionfs_d_revalidate_chain(dentry, nd, false))
+ if (unlikely(!__unionfs_d_revalidate_chain(dentry, nd, false)))
printk("unionfs: put_link failed to revalidate dentry\n");
unionfs_unlock_dentry(dentry);
/*
* Nobody gets write access to an immutable file.
*/
- if (IS_IMMUTABLE(inode))
+ if (unlikely(IS_IMMUTABLE(inode)))
return -EACCES;
/*
* For all other branches than the first one, we ignore
bstart = ibstart(inode);
bend = ibend(inode);
- if (bstart < 0 || bend < 0) {
+ if (unlikely(bstart < 0 || bend < 0)) {
/*
* With branch-management, we can get a stale inode here.
* If so, we return ESTALE back to link_path_walk, which
for (bindex = bstart; bindex <= bend; bindex++) {
lower_inode = unionfs_lower_inode_idx(inode, bindex);
- if (!lower_inode)
+ if (unlikely(!lower_inode))
continue;
/*
* we don't have to check for files, if we are checking for
* directories.
*/
- if (!is_file && !S_ISDIR(lower_inode->i_mode))
+ if (unlikely(!is_file && !S_ISDIR(lower_inode->i_mode)))
continue;
/*
* The permissions are an intersection of the overall directory
* permissions, so we fail if one fails.
*/
- if (err)
+ if (unlikely(err))
goto out;
/* only the leftmost file matters. */
if (is_file || write_mask) {
if (is_file && write_mask) {
err = get_write_access(lower_inode);
- if (!err)
+ if (unlikely(!err))
put_write_access(lower_inode);
}
break;
unionfs_read_lock(dentry->d_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;
}
for (bindex = bstart; (bindex <= bend) || (bindex == bstart);
bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
- if (!lower_dentry)
+ if (unlikely(!lower_dentry))
continue;
BUG_ON(lower_dentry->d_inode == NULL);
dentry->d_name.len,
NULL, size);
- if (!err) {
+ if (unlikely(!err)) {
copyup = 1;
lower_dentry =
unionfs_lower_dentry(dentry);
}
err = notify_change(lower_dentry, ia);
- if (err)
+ if (unlikely(err))
goto out;
break;
}
if (ia->ia_valid & ATTR_SIZE) {
if (ia->ia_size != i_size_read(inode)) {
err = vmtruncate(inode, ia->ia_size);
- if (err)
+ if (unlikely(err))
printk("unionfs_setattr: vmtruncate failed\n");
}
}