lkml.org 
[lkml]   [2006]   [Oct]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] VFS: Make d_materialise_unique() enforce directory uniqueness
On Thu, 19 Oct 2006 17:03:58 -0400
Trond Myklebust <Trond.Myklebust@netapp.com> wrote:

> +static struct dentry *__d_unalias(struct dentry *dentry, struct dentry *alias)
> +{
> + struct mutex *m1 = NULL, *m2 = NULL;
> + struct dentry *ret;
> +
> + /* If alias and dentry share a parent, then no extra locks required */
> + if (alias->d_parent == dentry->d_parent)
> + goto out_unalias;
> +
> + /* Check for loops */
> + ret = ERR_PTR(-ELOOP);
> + if (d_isparent(alias, dentry))
> + goto out_err;
> +
> + /* See lock_rename() */
> + ret = ERR_PTR(-EBUSY);
> + if (!mutex_trylock(&dentry->d_sb->s_vfs_rename_mutex))
> + goto out_err;
> + m1 = &dentry->d_sb->s_vfs_rename_mutex;
> + if (!mutex_trylock(&alias->d_parent->d_inode->i_mutex))
> + goto out_err;
> + m2 = &alias->d_parent->d_inode->i_mutex;
> +out_unalias:
> + d_move_locked(alias, dentry);
> + ret = alias;
> +out_err:
> + spin_unlock(&dcache_lock);
> + if (m2)
> + mutex_unlock(m2);
> + if (m1)
> + mutex_unlock(m1);
> + return ret;
> +}

The locking in there is, of course, gruesome. There is no way in which it
can be made reliable?

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

\
 
 \ /
  Last update: 2006-10-20 06:43    [W:1.457 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site